Explorar el Código

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

叶仕杰 hace 4 años
padre
commit
be8aca930c
Se han modificado 23 ficheros con 2864 adiciones y 38 borrados
  1. 13 0
      business/base-service/src/main/java/com/yihu/jw/utils/StringUtil.java
  2. 89 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareCancelLogDO.java
  3. 193 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareFeeDetailDO.java
  4. 70 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareItemDictDO.java
  5. 578 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareOrderDO.java
  6. 79 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringConclusionDO.java
  7. 678 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java
  8. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/hospital/message/SystemMessageDO.java
  9. 1 1
      svr/svr-base/src/main/resources/bootstrap.yml
  10. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/lifeCare/LifeCareCancelLogDao.java
  11. 11 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/lifeCare/LifeCareFeeDetailDao.java
  12. 19 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/lifeCare/LifeCareItemDictDao.java
  13. 11 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/lifeCare/LifeCareOrderDao.java
  14. 99 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/DoctorLifeCareEndpoint.java
  15. 126 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PatientLifeCareEndpoint.java
  16. 1 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java
  17. 14 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  18. 512 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  19. 2 21
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  20. 0 9
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java
  21. 29 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  22. 326 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  23. 0 1
      svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java

+ 13 - 0
business/base-service/src/main/java/com/yihu/jw/utils/StringUtil.java

@ -12,6 +12,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -1437,4 +1438,16 @@ public class StringUtil {
        return dest;
    }
    /**
     * 生成随机
     * @return
     */
    private String getRandomIntStr(){
        Random rand = new Random();
        int i = rand.nextInt(); //int范围类的随机数
        i = rand.nextInt(100); //生成0-100以内的随机数
        i = (int)(Math.random() * 100000000); //0-100以内的随机数,用Matn.random()方式
        return String.valueOf(i);
    }
}

+ 89 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareCancelLogDO.java

@ -0,0 +1,89 @@
package com.yihu.jw.entity.care.lifeCare;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
* 工单取消记录实体
*
* Created by yeshijie on 2021/3/29.
*
*/
@Entity
@Table(name = "base_life_care_cancel_log")
public class LifeCareCancelLogDO extends UuidIdentityEntity {
    /**
	 * 工单id
	 */
	private String orderId;
    /**
	 * 居民code
	 */
	private String patient;
    /**
	 * 取消类型:1-调度员取消,2-居民取消
	 */
	private Integer cancelType;
    /**
	 * 取消理由
	 */
	private String cancelReason;
    /**
	 * 取消时间
	 */
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
	private Date time;
	@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 = "cancel_type")
    public Integer getCancelType() {
        return cancelType;
    }
    public void setCancelType(Integer cancelType) {
        this.cancelType = cancelType;
    }
	@Column(name = "cancel_reason")
    public String getCancelReason() {
        return cancelReason;
    }
    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }
	@Column(name = "time")
    public Date getTime() {
        return time;
    }
    public void setTime(Date time) {
        this.time = time;
    }
}

+ 193 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareFeeDetailDO.java

@ -0,0 +1,193 @@
package com.yihu.jw.entity.care.lifeCare;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
/**
* 服务工单价格明细(服务项价格,医生出诊费用)实体
*
* Created by yeshijie on 2021/3/26.
*
*/
@Entity
@Table(name = "base_life_care_fee_detail")
public class LifeCareFeeDetailDO extends UuidIdentityEntityWithOperator {
    /**
     * 支付方式
     */
    public enum Type {
        servicePackageItem(1, "服务包的服务项费用"),
        doctor(2,"医生出诊费用");
        private Integer type;
        private String desc;
        Type(Integer type, String desc) {
            this.type = type;
            this.desc = desc;
        }
        public Integer getType() {
            return type;
        }
        public void setType(Integer type) {
            this.type = type;
        }
    }
    /**
     * 状态
     */
    public enum Status {
        patient(1, "居民新增(预约)"),
        doctorAdd(2,"医生新增"),
        doctorDel(3,"医生删除");
        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;
        }
    }
    /**
	 * 工单id
	 */
	private String orderId;
    /**
	 * 费用类型,1-服务项费用,2-医生出诊费用
	 */
	private Integer type;
    /**
	 * 居民请求的服务项code,医生出诊费用code
	 */
	private String code;
    /**
	 * 居民请求的服务项名称,医生出诊费用名称
	 */
	private String name;
    /**
	 * 费用
	 */
	private BigDecimal fee;
    /**
	 * 折扣费用
	 */
	private BigDecimal feeDiscount;
    /**
	 * 数量
	 */
	private Integer number;
    /**
	 * 状态,1-居民新增(预约),2-医生新增,3-医生删除
	 */
	private Integer status;
    /**
     * 付款状态:0未付款 1已付款
     */
    private Integer payStatus;
	@Column(name = "order_id")
    public String getOrderId() {
        return orderId;
    }
    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }
	@Column(name = "type")
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
	@Column(name = "code")
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
	@Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
	@Column(name = "fee")
    public BigDecimal getFee() {
        return fee;
    }
    public void setFee(BigDecimal fee) {
        this.fee = fee;
    }
	@Column(name = "fee_discount")
    public BigDecimal getFeeDiscount() {
        return feeDiscount;
    }
    public void setFeeDiscount(BigDecimal feeDiscount) {
        this.feeDiscount = feeDiscount;
    }
	@Column(name = "number")
    public Integer getNumber() {
        return number;
    }
    public void setNumber(Integer number) {
        this.number = number;
    }
	@Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "pay_status")
    public Integer getPayStatus() {
        return payStatus;
    }
    public void setPayStatus(Integer payStatus) {
        this.payStatus = payStatus;
    }
}

+ 70 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareItemDictDO.java

@ -0,0 +1,70 @@
package com.yihu.jw.entity.care.lifeCare;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
/**
 * Created by yeshijie on 2021/3/26.
 */
@Entity
@Table(name = "base_life_care_item_dict")
public class LifeCareItemDictDO extends UuidIdentityEntity{
    private String code;
    private String name;
    private String remark;//'备注'
    private BigDecimal price;//价格
    private Integer sort;//排序字段
    private Integer del;//删除标志 1正常,0删除
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    public BigDecimal getPrice() {
        return price;
    }
    public void setPrice(BigDecimal price) {
        this.price = price;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 578 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareOrderDO.java

@ -0,0 +1,578 @@
package com.yihu.jw.entity.care.lifeCare;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
/**
 * Created by yeshijie on 2021/3/26.
 */
@Entity
@Table(name = "base_life_care_order")
public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
    /**
     * 工单状态
     */
    public enum Status {
        cancel(-1, "已取消"),
        waitForAccept(1, "待(医生)接单"),
        complete(2,"已完成");
        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;
        }
    }
    /**
     * 取消类型
     */
    public enum CancelType {
        patient(2,"居民取消"),
        doctor(3, "医生取消");
        private Integer type;
        private String desc;
        CancelType(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 number;
    /**
     * 代理发起工单的居民code,替父母,孩子等发起工单
     */
    private String proxyPatient;
    /**
     * 代理发起工单的居民code,替父母,孩子等发起工单
     */
    private String proxyPatientName;
    /**
     * 代理发起工单的居民联系电话
     */
    private String proxyPatientPhone;
    /**
     * 被服务的居民code,发起工单的居民的亲属
     */
    private String patient;
    /**
     * 被服务的居民姓名,发起工单的居民的亲属
     */
    private String patientName;
    /**
     * 被服务的居民联系电话
     */
    private String patientPhone;
    /**
     * 发起人与被服务人的关系:自己,父亲,母亲,儿子等
     */
    private String patientRelation;
    /**
     * 居民期望服务时间
     */
    private String patientExpectedServeTime;
    /**
     * 居民自己服务描述
     */
    private String serveDesc;
    /**
     * 服务的区
     */
    private String serveTown;
    /**
     * 服务详细地址
     */
    private String serveAddress;
    /**
     * 服务地址纬度
     */
    private String serveLat;
    /**
     * 服务地址经度
     */
    private String serveLon;
    /**
     * 调度员备注
     */
    private String remark;
    /**
     * 服务总费用
     */
    private BigDecimal totalFee;
    /**
     * 居民期望服务的医生姓名
     */
    private String expectedDoctorName;
    /**
     * 接单的医生code
     */
    private String doctor;
    /**
     * 接单的医生name
     */
    private String doctorName;
    /**
     * 接单的医生类型:医生,健管师,护士等
     */
    private String doctorType;
    /**
     * 医生完成现场照片,最多6张,逗号分隔
     */
    private String completeImgs;
    /**
     * 服务完成笔记
     */
    private String completeRemark;
    /**
     * 工单状态:
     * 待服务 1、已完成 2 、已取消 -1
     */
    private Integer status;
    /**
     * 工单完成时间(对工单评价完即工单完成)
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date completeTime;
    /**
     * 取消类型:2-居民取消
     */
    private Integer cancelType;
    /**
     * 取消理由
     */
    private String cancelReason;
    /**
     * 取消时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date cancelTime;
    /**
     * 付款方式:1-微信支付,2-线下支付(居民自己向医院支付,具体怎么支付由医院来定)
     */
    private Integer payWay;
    /**
     * 支付流水号
     */
    private String payNumber;
    /**
     * 支付时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date payTime;
    /**
     * 工单对应的服务项
     */
    private List<LifeCareFeeDetailDO> feeDetailList;
    /**
     * 患者性别
     */
    private String sex;
    /**
     * 患者年龄
     */
    private Integer age;
    /**
     * 患者头像
     */
    private String photo;
    /**
     * 会话id
     */
    private String sessionId;
    /**
     * 服务机构
     */
    private String hospital;
    private Integer type;//发起工单类型(1本人发起 2家人待预约 3医生代预约)
    private String relationCode;//业务关联
    @Column(name = "number")
    public String getNumber() {
        return number;
    }
    public void setNumber(String number) {
        this.number = number;
    }
    @Column(name = "proxy_patient")
    public String getProxyPatient() {
        return proxyPatient;
    }
    public void setProxyPatient(String proxyPatient) {
        this.proxyPatient = proxyPatient;
    }
    @Column(name = "proxy_patient_name")
    public String getProxyPatientName() {
        return proxyPatientName;
    }
    public void setProxyPatientName(String proxyPatientName) {
        this.proxyPatientName = proxyPatientName;
    }
    @Column(name = "proxy_patient_phone")
    public String getProxyPatientPhone() {
        return proxyPatientPhone;
    }
    public void setProxyPatientPhone(String proxyPatientPhone) {
        this.proxyPatientPhone = proxyPatientPhone;
    }
    @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 = "patient_phone")
    public String getPatientPhone() {
        return patientPhone;
    }
    public void setPatientPhone(String patientPhone) {
        this.patientPhone = patientPhone;
    }
    @Column(name = "patient_relation")
    public String getPatientRelation() {
        return patientRelation;
    }
    public void setPatientRelation(String patientRelation) {
        this.patientRelation = patientRelation;
    }
    @Column(name = "patient_expected_serve_time")
    public String getPatientExpectedServeTime() {
        return patientExpectedServeTime;
    }
    public void setPatientExpectedServeTime(String patientExpectedServeTime) {
        this.patientExpectedServeTime = patientExpectedServeTime;
    }
    @Column(name = "serve_desc")
    public String getServeDesc() {
        return serveDesc;
    }
    public void setServeDesc(String serveDesc) {
        this.serveDesc = serveDesc;
    }
    @Column(name = "serve_town")
    public String getServeTown() {
        return serveTown;
    }
    public void setServeTown(String serveTown) {
        this.serveTown = serveTown;
    }
    @Column(name = "serve_address")
    public String getServeAddress() {
        return serveAddress;
    }
    public void setServeAddress(String serveAddress) {
        this.serveAddress = serveAddress;
    }
    @Column(name = "serve_lat")
    public String getServeLat() {
        return serveLat;
    }
    public void setServeLat(String serveLat) {
        this.serveLat = serveLat;
    }
    @Column(name = "serve_lon")
    public String getServeLon() {
        return serveLon;
    }
    public void setServeLon(String serveLon) {
        this.serveLon = serveLon;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "expected_doctor_name")
    public String getExpectedDoctorName() {
        return expectedDoctorName;
    }
    public void setExpectedDoctorName(String expectedDoctorName) {
        this.expectedDoctorName = expectedDoctorName;
    }
    @Column(name = "total_fee")
    public BigDecimal getTotalFee() {
        return totalFee;
    }
    public void setTotalFee(BigDecimal totalFee) {
        this.totalFee = totalFee;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "doctor_type")
    public String getDoctorType() {
        return doctorType;
    }
    public void setDoctorType(String doctorType) {
        this.doctorType = doctorType;
    }
    @Column(name = "complete_imgs")
    public String getCompleteImgs() {
        return completeImgs;
    }
    public void setCompleteImgs(String completeImgs) {
        this.completeImgs = completeImgs;
    }
    @Column(name = "complete_remark")
    public String getCompleteRemark() {
        return completeRemark;
    }
    public void setCompleteRemark(String completeRemark) {
        this.completeRemark = completeRemark;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "complete_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCompleteTime() {
        return completeTime;
    }
    public void setCompleteTime(Date completeTime) {
        this.completeTime = completeTime;
    }
    @Column(name = "cancel_type")
    public Integer getCancelType() {
        return cancelType;
    }
    public void setCancelType(Integer cancelType) {
        this.cancelType = cancelType;
    }
    @Column(name = "cancel_reason")
    public String getCancelReason() {
        return cancelReason;
    }
    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }
    @Column(name = "cancel_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCancelTime() {
        return cancelTime;
    }
    public void setCancelTime(Date cancelTime) {
        this.cancelTime = cancelTime;
    }
    @Column(name = "pay_way")
    public Integer getPayWay() {
        return payWay;
    }
    public void setPayWay(Integer payWay) {
        this.payWay = payWay;
    }
    @Column(name = "pay_number")
    public String getPayNumber() {
        return payNumber;
    }
    public void setPayNumber(String payNumber) {
        this.payNumber = payNumber;
    }
    @Column(name = "pay_time")
    public Date getPayTime() {
        return payTime;
    }
    public void setPayTime(Date payTime) {
        this.payTime = payTime;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Transient
    public List<LifeCareFeeDetailDO> getFeeDetailList() {
        return feeDetailList;
    }
    public void setFeeDetailList(List<LifeCareFeeDetailDO> feeDetailList) {
        this.feeDetailList = feeDetailList;
    }
    @Transient
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
    @Transient
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }
    @Transient
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
    @Transient
    public String getSessionId() {
        return sessionId;
    }
    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "relation_code")
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
}

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

@ -0,0 +1,79 @@
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 orerId;//工单id
    private String patient;//工单服务的居民
    private String patientName;//居民姓名
    private String doctor;//医生
    private String doctorName;//医生姓名
    private Integer status;//处置状态 1已确认安全 2已转送医疗机构 3已处置完成
    private String conclusion;//处置小结
    public String getOrerId() {
        return orerId;
    }
    public void setOrerId(String orerId) {
        this.orerId = orerId;
    }
    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;
    }
}

+ 678 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java

@ -0,0 +1,678 @@
package com.yihu.jw.entity.care.securitymonitoring;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * 安防监护 服务工单
 * Created by yeshijie on 2021/4/1.
 */
@Entity
@Table(name = "base_security_monitoring_order")
public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    /**
     * 工单状态:-1-已取消,1-待处置,2-前往居民定位,3-已签到,4-已登记小结,5-待补录,6-待评价,7-已完成
     */
    public enum Status {
        cancel(-1, "已取消"),
        waitForSend(1, "待处置"),
        waitForAccept(2, "前往居民定位"),
        signed(3, "已签到"),
        registerSummary(4, "已登记小结,"),
        waitForAdded(5, "待补录"),
        waitForCommnet(5, "待评价"),
        complete(6,"已完成");
        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;
        }
    }
    /**
     * 取消类型
     */
    public enum CancelType {
        patient(2,"居民取消"),
        doctor(3, "医生取消");
        private Integer type;
        private String desc;
        CancelType(Integer type, String desc) {
            this.type = type;
            this.desc = desc;
        }
        public Integer getType() {
            return type;
        }
        public void setType(Integer type) {
            this.type = type;
        }
    }
    /**
     * 检查报告补录方式
     */
    public enum ExamPaperUploadWay {
        photo(1, "拍照补录"),
        interfaceData(2,"接口数据");
        private Integer type;
        private String desc;
        ExamPaperUploadWay(Integer type, String desc) {
            this.type = type;
            this.desc = desc;
        }
        public Integer getType() {
            return type;
        }
        public void setType(Integer type) {
            this.type = type;
        }
    }
    /**
     * 医生签到方式
     */
    public enum DoctorSignWay {
        locate(1, "定位"),
        sacn(2,"扫码");
        private Integer type;
        private String desc;
        DoctorSignWay(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 number;
    /**
     * 被服务的居民code,发起工单的居民的亲属
     */
    private String patient;
    /**
     * 被服务的居民姓名,发起工单的居民的亲属
     */
    private String patientName;
    /**
     * 被服务的居民联系电话
     */
    private String patientPhone;
    /**
     * 居民自己服务描述
     */
    private String serveDesc;
    /**
     * 上门服务的区
     */
    private String serveTown;
    /**
     * 上门服务详细地址
     */
    private String serveAddress;
    /**
     * 上门服务地址纬度
     */
    private String serveLat;
    /**
     * 上门服务地址经度
     */
    private String serveLon;
    /**
     * 备注
     */
    private String remark;
    /**
     * 接单的医生code
     */
    private String doctor;
    /**
     * 接单的医生name
     */
    private String doctorName;
    /**
     * 接单的医生类型:医生,健管师,护士等
     */
    private String doctorType;
    /**
     * 医生预计到达时间
     */
    private String doctorArrivingTime;
    /**
     * 医生签到时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date doctorSignTime;
    /**
     * 医生签到方式:1-定位,2-扫码
     */
    private Integer doctorSignWay;
    /**
     * 医生签到位置,记录详细地址
     */
    private String doctorSignLocation;
    /**
     * 医生签到照片
     */
    private String doctorSignImg;
    /**
     * 医生诊疗现场照片,最多9张,逗号分隔
     */
    private String presentImgs;
    /**
     * 是否需要上传补录报告:0-不需要,1-需要,待补录;2-需要,已补录
     */
    private Integer examPaperStatus;
    /**
     * 医生上传居民的化验检查报告照片
     */
    private String examPaperImgs;
    /**
     * 化验检查报告补录时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date examPaperUploadTime;
    /**
     * 化验检查报告补录方式,1-拍照补录,2-接口数据
     */
    private Integer examPaperUploadWay;
    /**
     * 工单状态:-1-已取消,1-待处置,2-前往居民定位,3-已签到,4-已登记小结,5-待补录,6-待评价,7-已完成
     */
    private Integer status;
    /**
     * 工单完成时间(对工单评价完即工单完成)
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date completeTime;
    /**
     * 取消类型:1-医生取消,2-居民取消
     */
    private Integer cancelType;
    /**
     * 取消理由
     */
    private String cancelReason;
    /**
     * 取消时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date cancelTime;
    /**
     * 服务小结
     */
    private SecurityMonitoringOrderDO monitoringOrder;
    /**
     * 服务医生响应时间(第一条咨询或者接单时间)
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date serviceResponseTime;
    /**
     * 患者性别
     */
    private String sex;
    /**
     * 患者年龄
     */
    private Integer age;
    /**
     * 患者头像
     */
    private String photo;
    /**
     * 人群类型名称
     */
    private String typeValue;
    /**
     * 会话id
     */
    private String sessionId;
    /**
     * 服务机构
     */
    private String hospital;
    private Integer conclusionStatus;//服务小结登记状态:1待补录;2-已补录
    private Integer type;//发起工单类型(1本人发起 2家人待预约 3医生代预约)
    private String relationCode;//业务关联
    private String serviceStatus;//服务类型 1-预约项目 2-即时项目
    private String orderInfo;//工单详情 0-未推送 1-未确认 2-已确认
    /**
     * 快捷类型,1是快捷类型,其他值不是
     */
    private String shortcutType;
    @Column(name = "number")
    public String getNumber() {
        return number;
    }
    public void setNumber(String number) {
        this.number = number;
    }
    @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 = "patient_phone")
    public String getPatientPhone() {
        return patientPhone;
    }
    public void setPatientPhone(String patientPhone) {
        this.patientPhone = patientPhone;
    }
    @Column(name = "serve_desc")
    public String getServeDesc() {
        return serveDesc;
    }
    public void setServeDesc(String serveDesc) {
        this.serveDesc = serveDesc;
    }
    @Column(name = "serve_town")
    public String getServeTown() {
        return serveTown;
    }
    public void setServeTown(String serveTown) {
        this.serveTown = serveTown;
    }
    @Column(name = "serve_address")
    public String getServeAddress() {
        return serveAddress;
    }
    public void setServeAddress(String serveAddress) {
        this.serveAddress = serveAddress;
    }
    @Column(name = "serve_lat")
    public String getServeLat() {
        return serveLat;
    }
    public void setServeLat(String serveLat) {
        this.serveLat = serveLat;
    }
    @Column(name = "serve_lon")
    public String getServeLon() {
        return serveLon;
    }
    public void setServeLon(String serveLon) {
        this.serveLon = serveLon;
    }
    @Column(name = "remark")
    public String getRemark() {
        return remark;
    }
    public void setRemark(String remark) {
        this.remark = remark;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "doctor_type")
    public String getDoctorType() {
        return doctorType;
    }
    public void setDoctorType(String doctorType) {
        this.doctorType = doctorType;
    }
    @Column(name = "doctor_arriving_time")
    public String getDoctorArrivingTime() {
        return doctorArrivingTime;
    }
    public void setDoctorArrivingTime(String doctorArrivingTime) {
        this.doctorArrivingTime = doctorArrivingTime;
    }
    @Column(name = "doctor_sign_time")
    public Date getDoctorSignTime() {
        return doctorSignTime;
    }
    public void setDoctorSignTime(Date doctorSignTime) {
        this.doctorSignTime = doctorSignTime;
    }
    @Column(name = "doctor_sign_way")
    public Integer getDoctorSignWay() {
        return doctorSignWay;
    }
    public void setDoctorSignWay(Integer doctorSignWay) {
        this.doctorSignWay = doctorSignWay;
    }
    @Column(name = "doctor_sign_location")
    public String getDoctorSignLocation() {
        return doctorSignLocation;
    }
    public void setDoctorSignLocation(String doctorSignLocation) {
        this.doctorSignLocation = doctorSignLocation;
    }
    @Column(name = "doctor_sign_img")
    public String getDoctorSignImg() {
        return doctorSignImg;
    }
    public void setDoctorSignImg(String doctorSignImg) {
        this.doctorSignImg = doctorSignImg;
    }
    @Column(name = "present_imgs")
    public String getPresentImgs() {
        return presentImgs;
    }
    public void setPresentImgs(String presentImgs) {
        this.presentImgs = presentImgs;
    }
    @Column(name = "exam_paper_status")
    public Integer getExamPaperStatus() {
        return examPaperStatus;
    }
    public void setExamPaperStatus(Integer examPaperStatus) {
        this.examPaperStatus = examPaperStatus;
    }
    @Column(name = "exam_paper_imgs")
    public String getExamPaperImgs() {
        return examPaperImgs;
    }
    public void setExamPaperImgs(String examPaperImgs) {
        this.examPaperImgs = examPaperImgs;
    }
    @Column(name = "exam_paper_upload_time")
    public Date getExamPaperUploadTime() {
        return examPaperUploadTime;
    }
    public void setExamPaperUploadTime(Date examPaperUploadTime) {
        this.examPaperUploadTime = examPaperUploadTime;
    }
    @Column(name = "exam_paper_upload_way")
    public Integer getExamPaperUploadWay() {
        return examPaperUploadWay;
    }
    public void setExamPaperUploadWay(Integer examPaperUploadWay) {
        this.examPaperUploadWay = examPaperUploadWay;
    }
    @Column(name = "status")
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @Column(name = "complete_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCompleteTime() {
        return completeTime;
    }
    public void setCompleteTime(Date completeTime) {
        this.completeTime = completeTime;
    }
    @Column(name = "cancel_type")
    public Integer getCancelType() {
        return cancelType;
    }
    public void setCancelType(Integer cancelType) {
        this.cancelType = cancelType;
    }
    @Column(name = "cancel_reason")
    public String getCancelReason() {
        return cancelReason;
    }
    public void setCancelReason(String cancelReason) {
        this.cancelReason = cancelReason;
    }
    @Column(name = "cancel_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCancelTime() {
        return cancelTime;
    }
    public void setCancelTime(Date cancelTime) {
        this.cancelTime = cancelTime;
    }
    @Column(name = "hospital")
    public String getHospital() {
        return hospital;
    }
    public void setHospital(String hospital) {
        this.hospital = hospital;
    }
    @Transient
    public SecurityMonitoringOrderDO getMonitoringOrder() {
        return monitoringOrder;
    }
    public void setMonitoringOrder(SecurityMonitoringOrderDO monitoringOrder) {
        this.monitoringOrder = monitoringOrder;
    }
    @Column(name = "service_response_time")
    public Date getServiceResponseTime() {
        return serviceResponseTime;
    }
    public void setServiceResponseTime(Date serviceResponseTime) {
        this.serviceResponseTime = serviceResponseTime;
    }
    @Transient
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
    @Transient
    public Integer getAge() {
        return age;
    }
    public void setAge(Integer age) {
        this.age = age;
    }
    @Transient
    public String getPhoto() {
        return photo;
    }
    public void setPhoto(String photo) {
        this.photo = photo;
    }
    @Transient
    public String getTypeValue() {
        return typeValue;
    }
    public void setTypeValue(String typeValue) {
        this.typeValue = typeValue;
    }
    @Transient
    public String getSessionId() {
        return sessionId;
    }
    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    @Column(name = "relation_code")
    public String getRelationCode() {
        return relationCode;
    }
    public void setRelationCode(String relationCode) {
        this.relationCode = relationCode;
    }
    @Column(name = "service_status")
    public String getServiceStatus() {
        return serviceStatus;
    }
    public void setServiceStatus(String serviceStatus) {
        this.serviceStatus = serviceStatus;
    }
    @Column(name = "order_info")
    public String getOrderInfo() {
        return orderInfo;
    }
    public void setOrderInfo(String orderInfo) {
        this.orderInfo = orderInfo;
    }
    @Column(name = "shortcut_type")
    public String getShortcutType() {
        return shortcutType;
    }
    public void setShortcutType(String shortcutType) {
        this.shortcutType = shortcutType;
    }
    public Integer getConclusionStatus() {
        return conclusionStatus;
    }
    public void setConclusionStatus(Integer conclusionStatus) {
        this.conclusionStatus = conclusionStatus;
    }
}

+ 1 - 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开头
     */
    private String type;
    /**

+ 1 - 1
svr/svr-base/src/main/resources/bootstrap.yml

@ -1,6 +1,6 @@
spring:
  application:
    name: svr-base
    name: svr-base-ysj
  cloud:
    config:
      failFast: true

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

@ -0,0 +1,12 @@
package com.yihu.jw.care.dao.lifeCare;
import com.yihu.jw.entity.care.lifeCare.LifeCareCancelLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2021/3/29.
 */
public interface LifeCareCancelLogDao extends PagingAndSortingRepository<LifeCareCancelLogDO, String>, JpaSpecificationExecutor<LifeCareCancelLogDO> {
}

+ 11 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/lifeCare/LifeCareFeeDetailDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.care.dao.lifeCare;
import com.yihu.jw.entity.care.lifeCare.LifeCareFeeDetailDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2021/3/26.
 */
public interface LifeCareFeeDetailDao extends PagingAndSortingRepository<LifeCareFeeDetailDO, String>, JpaSpecificationExecutor<LifeCareFeeDetailDO> {
}

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

@ -0,0 +1,19 @@
package com.yihu.jw.care.dao.lifeCare;
import com.yihu.jw.entity.base.servicePackage.ServicePackageItemDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareItemDictDO;
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 yeshijie on 2021/3/26.
 */
public interface LifeCareItemDictDao  extends PagingAndSortingRepository<LifeCareItemDictDO, String>, JpaSpecificationExecutor<LifeCareItemDictDO> {
    @Query("from LifeCareItemDictDO w where  w.del=1 order by sort asc")
    List<LifeCareItemDictDO> findByAll();
}

+ 11 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/lifeCare/LifeCareOrderDao.java

@ -0,0 +1,11 @@
package com.yihu.jw.care.dao.lifeCare;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by yeshijie on 2021/3/26.
 */
public interface LifeCareOrderDao extends PagingAndSortingRepository<LifeCareOrderDO, String>, JpaSpecificationExecutor<LifeCareOrderDO> {
}

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

@ -0,0 +1,99 @@
package com.yihu.jw.care.endpoint.lifeCare;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created by yeshijie on 2021/3/26.
 */
@RestController
@RequestMapping(value = "doctor/lifeCare")
@Api(value = "医生端-生活照料", description = "医生端-生活照料相关", tags = {"医生端-生活照料相关"})
public class DoctorLifeCareEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private LifeCareOrderService lifeCareOrderService;
    @GetMapping(value = "queryBriefList")
    @ApiOperation(value = "调度员查询工单列表")
    public PageEnvelop queryBriefList(
            @ApiParam(name = "doctorCode", value = "医生code") @RequestParam(value = "doctorCode", required = true) String doctorCode,
            @ApiParam(name = "patientName", value = "居民姓名或身份证") @RequestParam(value = "patientName", required = false) String patientName,
            @ApiParam(name = "phone", value = "手机号码") @RequestParam(value = "phone", required = false) String phone,
            @ApiParam(name = "status", value = "工单状态") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try{
            JSONObject result = lifeCareOrderService.queryBriefList(doctorCode, patientName, phone, status, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            Long count = result.getLongValue(ResponseContant.count);
            return PageEnvelop.getSuccessListWithPage("查询成功",(List<Map<String,Object>>)result.get(ResponseContant.resultMsg),page,size,count);
        }catch (Exception e){
            e.printStackTrace();
        }
        return PageEnvelop.getError("查询失败");
    }
    @GetMapping("/topStatusBarNum")
    @ApiOperation(value = "顶部状态栏订单分类tab")
    public ObjEnvelop topStatusBarNum(
            @ApiParam(name = "doctor", value = "医生code")
            @RequestParam(value = "doctor", required = true) String doctor) {
        try {
            Map<String, Integer> map = lifeCareOrderService.getNumGroupByStatus(doctor);
            return ObjEnvelop.getSuccess("获取成功",map);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败!" ,-1);
        }
    }
    @GetMapping("getByOrderId")
    @ApiOperation(value = "根据工单id获取相应的工单")
    public ObjEnvelop getByOrderId(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId) {
        try {
            // 根据orderId获取工单信息
            LifeCareOrderDO doorServiceOrderDO = lifeCareOrderService.getServiceOrderById(orderId);
            return ObjEnvelop.getSuccess("获取成功", doorServiceOrderDO);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败" ,-1);
        }
    }
    @PostMapping("completeOrder")
    @ApiOperation(value = "记录完成情况")
    public Envelop completeOrder(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId,
            @ApiParam(value = "附件", name = "completeImgs")
            @RequestParam(value = "completeImgs", required = false) String completeImgs,
            @ApiParam(value = "完成服务记录", name = "completeRemark")
            @RequestParam(value = "completeRemark", required = true) String completeRemark) {
        try {
           lifeCareOrderService.completeOrder(orderId, completeImgs, completeRemark);
            return Envelop.getSuccess("记录成功");
        } catch (Exception e) {
            e.printStackTrace();
            return Envelop.getError( "记录失败" ,-1);
        }
    }
}

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

@ -0,0 +1,126 @@
package com.yihu.jw.care.endpoint.lifeCare;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.lifeCare.LifeCareOrderService;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by yeshijie on 2021/3/26.
 */
@RestController
@RequestMapping(value = "patient/lifeCare")
@Api(value = "居民端-生活照料", description = "生活照料相关", tags = {"居民端-生活照料相关"})
public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
    @Autowired
    private LifeCareOrderService lifeCareOrderService;
    @PostMapping(value = "create")
    @ApiOperation(value = "申请生活照料")
    public Envelop create(@ApiParam(name = "jsonData", value = "Json数据", required = true) @RequestParam String jsonData) {
        JSONObject result = new JSONObject();
        try{
            result = lifeCareOrderService.create(jsonData);
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("操作失败",-1);
        }
        if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
            return Envelop.getError(result.getString(ResponseContant.resultMsg),-1);
        }
        return success(result);
    }
    @PostMapping(value = "cancelOrder")
    @ApiOperation(value = "取消工单")
    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) {
        JSONObject result = new JSONObject();
        try{
            result = lifeCareOrderService.cancelOrder(orderId, 2, reason);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg),-1);
            }
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("操作失败",-1);
        }
        return success(result.get(ResponseContant.resultMsg));
    }
    @GetMapping(value = "queryInfoStatusCountList")
    @ApiOperation(value = "统计生活照料工单各状态下的数量列表")
    public Envelop queryInfoStatusCountList(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patient) {
        try {
            JSONObject result = lifeCareOrderService.queryInfoStatusCountList(patient);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg),-1);
            }
            return success(result.get(ResponseContant.resultMsg));
        }catch (Exception e){
            e.printStackTrace();
            return Envelop.getError("查询失败",-1);
        }
    }
    @GetMapping(value = "infoList")
    @ApiOperation(value = "查询工单记录")
    public PageEnvelop page(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "status", value = "工单状态,状态为全部时不传") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try {
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status, page, size);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
            }
            int count = result.getIntValue(ResponseContant.count);
            return success((List) result.get(ResponseContant.resultMsg), count, page, size);
        }catch (Exception e){
            e.printStackTrace();
            return PageEnvelop.getError("查询失败", -1);
        }
    }
    @GetMapping(value = "findItemDict")
    @ApiOperation(value = "查找服务项字典")
    public ListEnvelop findItemDict() {
        try {
            return ListEnvelop.getSuccess("查询成功",lifeCareOrderService.findItemDict());
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping("getByOrderId")
    @ApiOperation(value = "根据工单id获取相应的工单")
    public ObjEnvelop getByOrderId(
            @ApiParam(value = "工单id", name = "orderId")
            @RequestParam(value = "orderId", required = true) String orderId) {
        try {
            // 根据orderId获取工单信息
            LifeCareOrderDO doorServiceOrderDO = lifeCareOrderService.getServiceOrderById(orderId);
            return ObjEnvelop.getSuccess("获取成功", doorServiceOrderDO);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "获取失败" ,-1);
        }
    }
}

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

@ -1,6 +1,5 @@
package com.yihu.jw.care.endpoint.patient;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ServicesAuth;
import com.yihu.jw.care.aop.ServicesAuthAOP;
import com.yihu.jw.care.service.patient.CarePatientService;
@ -86,8 +85,7 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "id", value = "居民id")
            @RequestParam(value = "id", required = true) String id) {
        try{
            JSONObject result = patientService.findPatientById(id);
            return success("获取成功",result);
            return success("获取成功",patientService.findPatientById(id));
        }catch (Exception e){
            e.printStackTrace();
            return failed("获取失败",-1);

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

@ -13,6 +13,7 @@ import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import com.yihu.jw.patient.dao.BasePatientDao;
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;
@ -47,6 +48,18 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ServicePackageService servicePackageService;
    @GetMapping(value = "findSignOrg")
    @ApiOperation(value = "查找签约机构")
    public ListEnvelop findSignOrg (
            @ApiParam(name = "patient", value = "医生code", required = true)
            @RequestParam(value = "patient",required = true) String patient) throws Exception {
        try{
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findSignOrg(patient));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "signRecordPage")
    @ApiOperation(value = "获取签约记录分页")
@ -240,7 +253,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
                if(archiveDO!=null){
                    return success(archiveDO);
                }else {
                    return failed("您所提交的居民信息已存在,请勿重复建档");
                    return failed("您所提交的居民信息已存在,请勿重复建档",-1);
                }
            }
            archiveService.createArchive(patientDO,doctorId);

+ 512 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java

@ -0,0 +1,512 @@
package com.yihu.jw.care.service.lifeCare;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.lifeCare.LifeCareCancelLogDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareFeeDetailDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareItemDictDao;
import com.yihu.jw.care.dao.lifeCare.LifeCareOrderDao;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareCancelLogDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareFeeDetailDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareItemDictDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.entity.EntityUtils;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
/**
 * Created by yeshijie on 2021/3/26.
 */
@Service
public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCareOrderDao> {
    private Logger logger = LoggerFactory.getLogger(LifeCareOrderService.class);
    @Autowired
    private LifeCareOrderDao lifeCareOrderDao;
    @Autowired
    private LifeCareFeeDetailDao lifeCareFeeDetailDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private LifeCareItemDictDao lifeCareItemDictDao;
    @Autowired
    private MessageUtil messageUtil;
    @Autowired
    private LifeCareCancelLogDao lifeCareCancelLogDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BasePatientWechatDao basePatientWechatDao;
    @Value("${wechat.id}")
    private String wxId;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    /**
     * 记录完成情况
     * @param orderId
     * @param complereImgs
     * @param completeRemark
     */
    public void completeOrder(String orderId,String complereImgs,String completeRemark){
        LifeCareOrderDO lifeCareOrderDO = lifeCareOrderDao.findOne(orderId);
        if(lifeCareOrderDO.getStatus().equals(LifeCareOrderDO.Status.waitForAccept.getType())){
            lifeCareOrderDO.setStatus(2);
            lifeCareOrderDO.setCompleteImgs(complereImgs);
            lifeCareOrderDO.setCompleteRemark(completeRemark);
            lifeCareOrderDO.setCompleteTime(new Date());
            lifeCareOrderDao.save(lifeCareOrderDO);
        }
    }
    /**
     * 根据id获取服务工单信息
     * @param id
     * @return
     */
    public LifeCareOrderDO getServiceOrderById(String id) throws Exception {
        LifeCareOrderDO lifeCareOrderDO = lifeCareOrderDao.findOne(id);
        if (null == lifeCareOrderDO) {
            return null;
        }
        BasePatientDO patient = patientDao.findById(lifeCareOrderDO.getPatient());
        if (patient != null) {
            String sex = IdCardUtil.getSexForIdcard_new(patient.getIdcard());
            int age = IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(),patient.getBirthday());
            lifeCareOrderDO.setSex("1".equals(sex) ? "男" : "2".equals(sex) ? "女" : "未知");
            lifeCareOrderDO.setAge(age);
            lifeCareOrderDO.setPhoto(patient.getPhoto());
        }
        // 获取服务次数
        lifeCareOrderDO.setFeeDetailList(getFeeDetails(id));
        return lifeCareOrderDO;
    }
    /**
     * 根据工单id获取服务工单-服务项价格
     * @param orderId
     * @return
     */
    public List<LifeCareFeeDetailDO> getFeeDetails(String orderId) {
        String sql = "SELECT * from base_life_care_fee_detail d where order_id='"+orderId+"' ";
        List<LifeCareFeeDetailDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(LifeCareFeeDetailDO.class));
        return list;
    }
    /**
     * 顶部状态栏订单各分类总条数
     * @param doctor
     * @return
     */
    public Map<String, Integer> getNumGroupByStatus(String doctor) {
        List<BaseDoctorHospitalDO> doctorHospitalDOs = doctorHospitalDao.findByDoctorCode(doctor);
        String hospital = doctorHospitalDOs.get(0).getOrgCode();
        String sql = "SELECT a.status, COUNT(DISTINCT a.id) as num FROM base_life_care_order a " ;
        sql +=  "  WHERE  a.hospital = ? group BY a.status";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql, hospital);
        Map<String, Integer> map = new HashMap<>();
        //状态 待服务 1、已完成 2 、已取消 -1
        map.put("1",0);
        map.put("2",0);
        map.put("-1",0);
        int total = 0;
        for (Map<String, Object> one:list){
            map.put(String.valueOf(one.get("status")), Integer.valueOf(String.valueOf(one.get("num"))));
            total+=Integer.valueOf(String.valueOf(one.get("num")));
        }
        map.put("total", total);
        return map;
    }
    /**
     * 医生/助老员-查询-工单列表
     *
     * @return
     */
    public JSONObject queryBriefList(String doctorCode,String name,String phone,Integer status,int page, int size) {
        JSONObject result = new JSONObject();
        List<BaseDoctorHospitalDO> doctorHospitalDOs = doctorHospitalDao.findByDoctorCode(doctorCode);
        String hospital = doctorHospitalDOs.get(0).getOrgCode();
        name = null == name ? "" : name;
        phone = null == phone ? "" : phone;
        status = null == status ? -100 : status;
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : page * size;
        StringBuffer buffer = new StringBuffer();
        if (StringUtils.isNoneBlank(name)){
            buffer.append(" AND (o.`patient_name` like '%"+name+"%' or p.idcard like '%"+name+"%')");
        }else if (StringUtils.isNoneBlank(phone)){
            buffer.append(" AND o.`proxy_patient_phone` like '%"+phone+"%'");
        }
        String sql = "SELECT " +
                "  p.name AS patientName, " +
                "  p.photo AS photo, " +
                "  case p.sex  " +
                "  when 1 then '男'  " +
                "  when 2 then '女' " +
                "  end AS sex, " +
                "  TIMESTAMPDIFF(year,p.birthday,NOW()) AS age," +
                "  o.id as orderId, " +
                "  o.patient_phone as phone, " +
                "  o.proxy_patient as proxyPatient, " +
                "  o.patient as patient, " +
                "  o.number as number, " +
                "  o.patient_expected_serve_time as serveTime, o.doctor, o.doctor_name as doctorName, " +
                "  o.serve_address as address, " +
                "  o.serve_lon as lon, " +
                "  o.serve_lat as lat, " +
                "  o.`status` as status " +
                " FROM " +
                " ( base_life_care_order o " +
                " LEFT JOIN base_patient p ON o.patient = p.id ) "+
                " WHERE " +
                "  o.hospital = '{hospital}' and o.type != 3 " +buffer+
                " AND ( o.`status` = {status} OR -100 = {status} ) " +
                " ORDER BY o.create_time desc " +
                " LIMIT {start},{end};";
        String finalSql = sql.replace("{hospital}", hospital)
                .replace("{status}", String.valueOf(status))
                .replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
        String countSql = "SELECT  " +
                "   count(o.id)  " +
                " FROM  " +
                "   base_life_care_order o  " +
                " LEFT JOIN base_patient p ON o.patient = p.id " +
                " WHERE  " +
                "  o.hospital = '{hospital}' " +buffer+
                " AND (o.`status` = {status} or -100 = {status})";
        String finqlCountSql = countSql.replace("{hospital}", hospital)
                .replace("{status}", String.valueOf(status));
        List<Map<String,Object>> sqlResultlist;
        try {
            sqlResultlist = jdbcTemplate.queryForList(finalSql);
            for (Map<String,Object> orderDO:sqlResultlist){
                orderDO.put("feeDetails",getFeeDetails(orderDO.get("orderId").toString()));
            }
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库查询【调度员】生活照料工单列表信息失败:" + e.getMessage());
            return result;
        }
        Long count;
        try {
            count = jdbcTemplate.queryForObject(finqlCountSql, Long.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, "从数据库统计【调度员】生活照料工单数量失败:" + e.getMessage());
            return result;
        }
        
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, sqlResultlist);
        JSONObject countItem = new JSONObject();
        countItem.put("count", count);
        result.putAll(countItem);
        return result;
    }
    /**
     * 查找服务项字典
     * @return
     */
    public List<LifeCareItemDictDO> findItemDict(){
        return lifeCareItemDictDao.findByAll();
    }
    /**
     * 居民端-查询生活照料工单列表
     *
     * @return
     */
    public JSONObject queryInfoList(String patient,Integer status, int page, int size) {
        JSONObject result = new JSONObject();
        status = null == status ? -100 : status;
        int start = 0 == page ? page++ : (page - 1) * size;
        int end = 0 == size ? 15 : size;
        String sql = "SELECT *  FROM  base_life_care_order o " +
                " WHERE (o.patient = '{patient}' or o.proxy_patient = '{patient}') "+
                " AND (o.`status` = {status} or -100 = {status})" +
                "  group by o.id " +
                " ORDER BY o.create_time desc" +
                " LIMIT {start},{end} ";
        String finalSql = sql.replace("{patient}", patient)
                .replace("{status}", String.valueOf(status))
                .replace("{start}", String.valueOf(start))
                .replace("{end}", String.valueOf(end));
        String countSql = "SELECT count(DISTINCT o.id) FROM base_life_care_order o " +
                " WHERE  " +
                "  (o.patient = '{patient}' or o.proxy_patient = '{patient}') " +
                " AND (o.`status` = {status} or -100 = {status})";
        String finqlCountSql = countSql.replace("{patient}", patient)
                .replace("{status}", String.valueOf(status));
        List<LifeCareOrderDO> sqlResultlist= jdbcTemplate.query(finalSql,new BeanPropertyRowMapper(LifeCareOrderDO.class));
        for (LifeCareOrderDO orderDO:sqlResultlist){
            orderDO.setFeeDetailList(getFeeDetails(orderDO.getId()));
        }
        Integer count = jdbcTemplate.queryForObject(finqlCountSql, Integer.class);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, sqlResultlist);
        JSONObject countItem = new JSONObject();
        countItem.put("count", count);
        result.putAll(countItem);
        return result;
    }
    /**
     * 居民端-统计生活照料工单各状态下的数量列表(预约咨询记录)
     *
     * @return
     */
    public JSONObject queryInfoStatusCountList(String patient) {
        JSONObject result = new JSONObject();
        int total = 0;
        Map<String,Object> res = new HashedMap();
        //状态 待服务 1、已完成 2 、已取消 -1
        res.put("1",0);
        res.put("2",0);
        res.put("-1",0);
        String countSql = "SELECT " +
                "  count(o.id) as count, " +
                "  o.status as status " +
                " FROM " +
                "  base_life_care_order o " +
                " WHERE " +
                "  o.patient = '"+ patient + "' " +
                " GROUP BY o.`status`";
        List<Map<String,Object>> countMapList = jdbcTemplate.queryForList(countSql);
        for(Map<String,Object> map:countMapList){
            int c = Integer.valueOf(map.get("count").toString());
            total +=c;
            res.put(String.valueOf(map.get("status")),c);
        }
        res.put("total",total);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, res);
        return result;
    }
    /**
     * 取消工单
     * @param orderId
     * @param type 取消类型
     * @param reason 取消理由
     */
    public JSONObject cancelOrder(String orderId,int type,String reason){
        JSONObject result = new JSONObject();
        LifeCareOrderDO orderDO = lifeCareOrderDao.findOne(orderId);
        if(null == orderDO){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "【取消工单】该工单不存在:," + orderId;
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        if(orderDO.getStatus().equals(LifeCareOrderDO.Status.waitForAccept.getType())){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "只有医生服务前的工单才可取消:," + orderId;
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        orderDO.setCancelType(type);
        orderDO.setCancelTime(new Date());
        orderDO.setCancelReason(reason);
        //如果是调度员取消,推送IM取消工单json消息,
        orderDO.setStatus(LifeCareOrderDO.Status.cancel.getType());
        this.save(orderDO);
        if(type == LifeCareOrderDO.CancelType.patient.getType()){  //居民取消,消息列表也应该不显示
            messageUtil.updateLifeCareMessage(orderDO,new String[]{"502","503","530"},"patientCancel");
        }
        //保存取消记录
        LifeCareCancelLogDO cancelLogDO = new LifeCareCancelLogDO();
        cancelLogDO.setOrderId(orderId);
        cancelLogDO.setPatient(orderDO.getProxyPatient());
        cancelLogDO.setCancelType(type);
        cancelLogDO.setCancelReason(reason);
        cancelLogDO.setTime(orderDO.getCancelTime());
        lifeCareCancelLogDao.save(cancelLogDO);
        // 发送微信模板消息,通知居民工单已取消(smyyyqx-上门预约已取消)
//        String first = "key1,您好,您的上门预约服务已退回,点击查看原因";
//        BasePatientDO patient = patientDao.findById(orderDO.getPatient());
//        first  = first.replace("key1", null != patient.getName() ? patient.getName() : "");
//        JSONObject json = new JSONObject();
//        json.put("id", orderDO.getId());
//        List<BasePatientWechatDo> basePatientWechatDos = basePatientWechatDao.findByWechatIdAndPatientId(wxId,patient.getId());
//        if(basePatientWechatDos.size()>0){
//            String openId = basePatientWechatDos.get(0).getOpenid();
//            messageUtil.putTemplateWxMessage(wxId,"template_process_feedback","smyyyqx",openId,first,null,null,30,json, DateUtil.dateToChineseDate(new Date()),"生活照料已取消");
//        }
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, "工单服务已取消!");
        return result;
    }
    /**
     * 申请生活照料
     *
     * @param jsonData
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject create(String jsonData) {
        logger.info("申请生活照料jsonData参数:" + jsonData);
        JSONObject result = new JSONObject();
        JSONObject jsonObjectParam;
        try {
            jsonObjectParam = JSONObject.parseObject(jsonData);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "参数转换成JSON对象异常:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        LifeCareOrderDO orderDO = null;
        try {
            orderDO = EntityUtils.jsonToEntity(jsonObjectParam.get("order").toString(), LifeCareOrderDO.class);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "生活照料工单服务基本信息:" + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        orderDO.setCreateTime(new Date());
        orderDO.setCreateUser(orderDO.getProxyPatient());
        orderDO.setCreateUserName(orderDO.getProxyPatientName());
        if(StringUtils.isEmpty(orderDO.getPatient())){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前服务对象code为空,请联系管理员检查参数!patient = " + orderDO.getPatient();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        if(StringUtils.isEmpty(orderDO.getProxyPatient())){
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "当前代理对象code为空,请联系管理员检查参数!proxyPatient = " + orderDO.getProxyPatient();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return result;
        }
        orderDO.setCreateTime(new Date());
        //判断创建生活照料类型,发起类型(1本人发起 2家人待预约 3医生代预约)
        if(orderDO.getProxyPatient().equals(orderDO.getPatient())){
            orderDO.setType(1);
        }else if(!orderDO.getProxyPatient().equals(orderDO.getPatient())){
            orderDO.setType(2);
        }
        this.save(orderDO);
        result.put("orderId",orderDO.getId());
        //新增工单与服务项费用关联关系
        if (orderWithPackageItemFeeAdd(result, jsonObjectParam, orderDO,null)) {return result;}
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg, orderDO);
        return result;
    }
    @Transactional(rollbackFor = Exception.class)
    public boolean orderWithPackageItemFeeAdd(JSONObject result, JSONObject jsonObjectParam, LifeCareOrderDO order,String doctorId) {
        List<LifeCareFeeDetailDO> feeDetailDOList = order.getFeeDetailList();
        BigDecimal totalFee = order.getTotalFee();
        if(null == totalFee){
            totalFee = new BigDecimal(0);
        }
        for ( LifeCareFeeDetailDO feeDetailDO : feeDetailDOList) {
            try {
                //工单主表中记录总费用
                totalFee = totalFee.add(feeDetailDO.getFee().multiply(BigDecimal.valueOf(feeDetailDO.getNumber())));
            } catch (Exception e) {
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                String failMsg = "工单主表中记录总费用时," + e.getMessage();
                result.put(ResponseContant.resultMsg, failMsg);
                logger.error(failMsg);
                return true;
            }
            // 服务项可能一开始由居民预约,后期由医生新增或医生删除
            Integer status = jsonObjectParam.getInteger("status");
            if(null == status || status == 1){
                feeDetailDO.setStatus(LifeCareFeeDetailDO.Status.patient.getType());
            }else{
                feeDetailDO.setStatus(status);
            }
            feeDetailDO.setOrderId(order.getId());
            if(StringUtils.isBlank(feeDetailDO.getId())) {
                feeDetailDO.setCreateTime(new Date());
            }else {
                feeDetailDO.setUpdateTime(new Date());
            }
            if(StringUtils.isBlank(feeDetailDO.getId())){
                feeDetailDO.setPayStatus(0);
            }
        }
        try {
            lifeCareFeeDetailDao.save(feeDetailDOList);
        } catch (Exception e) {
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            String failMsg = "保存服务费用到数据库异常:," + e.getMessage();
            result.put(ResponseContant.resultMsg, failMsg);
            logger.error(failMsg);
            return true;
        }
        return false;
    }
}

+ 2 - 21
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -1,16 +1,13 @@
package com.yihu.jw.care.service.patient;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Service;
@ -84,24 +81,8 @@ public class CarePatientService<T, R extends CrudRepository> extends BaseJpaServ
     * @param patientId
     * @return
     */
    public JSONObject findPatientById(String patientId) throws Exception{
        JSONObject result = new JSONObject();
        if(StringUtils.isEmpty(patientId)){
            result.put("result","parameter patientId is null");
            return result;
        }
        BasePatientDO patientDO = basePatientDao.findById(patientId);
        if(patientDO == null){
            result.put("result","not exist patient for id:"+patientId);
            return result;
        }
        PatientMedicareCardDO card = basePatientMedicardCardService.findByTypeAndPatientCodeAndDel("A_01",patientId,"1");
        if(card != null){
            patientDO.setSsc(card.getCode());
        }
        result.put("patient",patientDO);
        return result;
    public BasePatientDO findPatientById(String patientId) throws Exception{
        return basePatientDao.findById(patientId);
    }
}

+ 0 - 9
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java

@ -4,7 +4,6 @@ import com.yihu.jw.care.dao.sign.ArchiveDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
@ -97,14 +96,6 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
        patientDO.setPatientStatus("1");
        patientDao.save(patientDO);
        PatientMedicareCardDO cardDO = new PatientMedicareCardDO();
        cardDO.setCode(patientDO.getSsc());
        cardDO.setDel("1");
        cardDO.setPatientCode(patientDO.getId());
        cardDO.setType("A_01");
        cardDO.setParentType("A");
        patientMedicareCardDao.save(cardDO);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
        ArchiveDO archiveDO = new ArchiveDO();
        archiveDO.setArchiveOperatorName(doctorDO.getName());

+ 29 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.sign.*;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.PatientMedicareCardDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageDO;
@ -22,11 +23,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 *
@ -62,6 +67,29 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    @Autowired
    private StringRedisTemplate redisTemplate;
    /**
     * 查找签约机构
     * @param patient
     * @return
     */
    public List<BaseOrgDO> findSignOrg(String patient){
        String sql = "SELECT " +
                " DISTINCT o.* " +
                "FROM " +
                " base_service_package_sign_record sr, " +
                " base_service_package_record r, " +
                " base_service_package_item i, " +
                " base_org o " +
                "WHERE " +
                " sr.id = r.sign_id and sr.patient = '"+patient+"'" +
                "AND r.service_package_id = i.service_package_id " +
                "AND i.del = 1 " +
                "and i.org_code = o.code " +
                "AND sr.`status` = 1";
        List<BaseOrgDO> list = jdbcTemplate.query(sql,new BeanPropertyRowMapper(BaseOrgDO.class));
        return list;
    }
    /**
     * 获取居民签约的服务项
     * @param patientId

+ 326 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -0,0 +1,326 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.wx.BasePatientWechatDo;
import com.yihu.jw.entity.base.wx.WxAccessTokenDO;
import com.yihu.jw.entity.base.wx.WxTemplateConfigDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
import com.yihu.jw.wechat.dao.WxAccessTokenDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
import com.yihu.jw.wechat.service.WxAccessTokenService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
import java.util.UUID;
/**
 * Created by liub on 2020/12/28.
 */
@Component
public class MessageUtil {
    private static Logger logger = LoggerFactory.getLogger(MessageUtil.class);
    @Autowired
    private WxAccessTokenService wxAccessTokenService;
    @Value("${hospital.url}")
    private String serverUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private WeixinMessagePushUtils weixinMessagePushUtils;
    @Autowired
    private WxTemplateConfigDao wxTemplateConfigDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private SystemMessageDao systemMessageDao;
    @Autowired
    private WxAccessTokenDao wxAccessTokenDao;
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private BasePatientDao basePatientDao;
    //发送微信模板消息
    private  String sendMessageUrl = "http://172.16.100.37:8090/hospitalPortal-sms/sms/sendMessage";
    /**
     * @param wxId
     * @param patient       患者id
     * @param cardNo
     * @param first
     * @param noticeContent
     * @param remark
     * @param redirectUrl
     * @return
     */
    public String sendWXMes(String wxId, String patient, String cardNo, String first, String noticeContent, String remark, String redirectUrl) {
        String msg = "first:" + first + "contentMsg:" + noticeContent + "remark:" + remark;
        logger.info("发送的信息=" + msg);
        JSONObject params = new JSONObject();
        params.put("transType", "sms.hospital.notice");
        params.put("merchId", "3501000014");
        JSONObject p = new JSONObject();
        String openId = "";
        if (StringUtils.isNotBlank(patient)) {
            String sql = "select * from base_patient_wechat where wechat_id='" + wxId + "'and patient_id='" + patient + "' ";
            List<BasePatientWechatDo> paientWechatDos = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(BasePatientWechatDo.class));
            if (paientWechatDos != null && paientWechatDos.size() > 0) {
                openId = paientWechatDos.get(0).getOpenid();
                p.put("openId", openId);
            }
        } else {
            p.put("cardNo", cardNo);
        }
        p.put("first", first);
        p.put("noticeTime", DateUtil.dateToStr(new Date(), "yyyy-MM-dd HH:mm:ss"));
        p.put("noticeContent", noticeContent);
        if (StringUtils.isNotBlank(redirectUrl)) {
            p.put("redirectUrl", redirectUrl);
        }
        p.put("remark", remark);
        params.put("param", p);
        logger.info("params :" + params.toString());
        if (StringUtils.isNotBlank(openId) || StringUtils.isNotBlank(cardNo)) {
            String rs = HttpUtil.sendPost(sendMessageUrl, params.toJSONString());
            JSONObject rsJson = JSON.parseObject(rs);
            String resCode = rsJson.getString("respCode");
            if ("000000".equals(resCode)) {
                return "1";
            }
            return "0";
        } else {
            return "-1";
        }
    }
    public String ehospitalNotice(String userName, String idCard, String phone, String title, String content, String contentString, String url) {
        String msg = "first:" + title + "contentMsg:" + content + "remark:" + contentString;
        logger.info("发送的信息=" + msg);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("userName", userName);
        jsonObject.put("idCard", idCard);
        jsonObject.put("phone", phone);
        jsonObject.put("title", title);
        jsonObject.put("url", url);
        jsonObject.put("content", content);
        jsonObject.put("contentString", contentString);
        System.out.println(serverUrl);
        String responseMsg = httpClientUtil.sendPost(serverUrl + "/interface/ehospitalNoticePush.htm", jsonObject.toString());
        logger.info("ehospitalNoticePushResult:" + responseMsg);
        return responseMsg;
    }
    //推送模板消息
    public void putTemplateWxMessage(WxTemplateConfigDO newConfig,String openId,Integer type,JSONObject json){
        try {
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(newConfig.getWechatId());
            if (wxAccessTokenDO == null) {
                logger.info("wx_access_token表获取为空,wechatId" + newConfig.getWechatId());
                return;
            }
            newConfig = setTemPlateUrl(newConfig,type,openId,json);
            //发起微信消息模板推送
            logger.info("微信模板消息推送前");
            weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), openId, newConfig);
            logger.info("微信模板消息推送后");
        }catch (Exception e){
            logger.info("微信模板推送异常");
            e.printStackTrace();
        }
    }
    //推送模板消息
    /**
     *
     * @param wechatId
     * @param templateName
     * @param scene
     * @param openId
     * @param first
     * @param url 跳转链接
     * @param remark
     * @param type  模板通知类型
     * @param josn 用于对跳转连接的修改,
     * @param keywords
     */
    public void putTemplateWxMessage(String wechatId, String templateName, String scene, String openId, String first,String url, String remark, Integer type,JSONObject josn,String ...keywords) {
        try {
            System.out.println(wechatId);
            WxAccessTokenDO wxAccessTokenDO = wxAccessTokenService.getWxAccessTokenById(wechatId);
            if (wxAccessTokenDO == null) {
                logger.info("wx_access_token表获取为空,wechatId" + wechatId);
                return;
            }
            WxTemplateConfigDO templateConfig = wxTemplateConfigDao.findByWechatIdAndTemplateNameAndSceneAndStatus(wechatId, templateName, scene, 1);
            WxTemplateConfigDO newConfig = new WxTemplateConfigDO();
            BeanUtils.copyProperties(templateConfig,newConfig);
            if (newConfig == null) {
                logger.info("微信模板不存在!请确认wechatId:" + wechatId + ",templateName:" + templateName + ",scene:" + scene);
                return;
            }
            logger.info("微信模板推送前");
            if (StringUtils.isNoneBlank(first)){
                newConfig.setFirst(first);
            }
            if (StringUtils.isNoneBlank(url)){
               newConfig.setUrl(url);
            }
            if (StringUtils.isNoneBlank(remark)){
                newConfig.setRemark(remark);
            }
            newConfig = setTemPlateUrl(newConfig,type,openId,josn);
            int keyLength = keywords.length;
            if (keyLength >= 1) {
               if(StringUtils.isNoneBlank(keywords[0])){
                   newConfig.setKeyword1(keywords[0]);
                }
            }
            if (keyLength >= 2) {
                if(StringUtils.isNoneBlank(keywords[1])){
                    newConfig.setKeyword2(keywords[1]);
                }
            }
            if (keyLength >= 3) {
                if(StringUtils.isNoneBlank(keywords[2])){
                    newConfig.setKeyword3(keywords[2]);
                }
            }
            if (keyLength >= 4) {
                if(StringUtils.isNoneBlank(keywords[3])){
                    newConfig.setKeyword4(keywords[3]);
                }
            }
            if (keyLength >= 5) {
                if(StringUtils.isNoneBlank(keywords[4])){
                    newConfig.setKeyword5(keywords[4]);
                }
            }
            if (keyLength >= 6) {
                if(StringUtils.isNoneBlank(keywords[5])){
                    newConfig.setKeyword6(keywords[5]);
                }
            }
            if (keyLength >= 7) {
                if(StringUtils.isNoneBlank(keywords[6])){
                    newConfig.setKeyword7(keywords[6]);
                }
            }
            //发起微信消息模板推送
            weixinMessagePushUtils.putWxMsg(wxAccessTokenDO.getAccessToken(), openId, newConfig);
            logger.info("微信模板消息推送后");
        } catch (Exception e) {
            logger.info("微信模板推送异常");
            e.printStackTrace();
        }
    }
    public WxTemplateConfigDO setTemPlateUrl(WxTemplateConfigDO wxTemplateConfigDO,Integer type,String openid,JSONObject json){
        String url =  "taian-wx/html/";
        if (json==null){
            return wxTemplateConfigDO;
        }
        switch (type){
            case 19:
                String urlStr= wxTemplateConfigDO.getUrl();
                boolean status = urlStr.contains("openid=");
                if(!status){
                    urlStr=json.getString("url")+"?openid=" + openid;
                }
                wxTemplateConfigDO.setUrl(url + urlStr );
                break;
            case 30:
                //反馈通知 测试 TPbq9m0SAiVfRhXtXq17SDmYIfrJ8Whp2NpSrq9wlfI
                if(json.containsKey("consult")) {
                    wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid + "&consult=" + json.getString("consult"));
                }else if (json.containsKey("id")){
                    wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid + "&id=" + json.getString("id"));
                }else if(json.containsKey("relationCode")){
                    wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid );
                }else if(json.containsKey("resultCode")){
                    wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?resultCode=" + json.getString("resultCode"));
                }
                break;
            case 31:
                //上门服务医生评分
                wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl()+"?openid=" + openid + "&id=" + json.getString("id")+ "&finish=" + json.getString("finish"));
                break;
            case 32:
                String url1 = "wx/common/";
                wxTemplateConfigDO.setUrl(url1 + wxTemplateConfigDO.getUrl()+"?openid=" + openid + "&consult=" + json.getString("consult") + "&status=" + json.getInteger("status"));
                break;
            case 34:
                wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl() + "?openid=" + openid + "&orderId=" + json.getString("orderId")+ "&authorizeImage=" + json.getString("authorizeImage"));
                break;
            case 35:
                wxTemplateConfigDO.setUrl(url + wxTemplateConfigDO.getUrl()+json.getString("orderId")+"&isMask=1");
                break;
        }
        return wxTemplateConfigDO;
    }
    /**
     *
     */
    public SystemMessageDO saveSystemMessage(String messageId, String relationCode, String title, String type, String sender, String senderName, String receiver, String receiverName, String idCard, String msg, String over) {
        SystemMessageDO messageDO = new SystemMessageDO();
        if (StringUtils.isBlank(messageId)) {
            messageDO.setId(UUID.randomUUID().toString().replace("-", ""));
        }
        messageDO.setTitle(title);
        messageDO.setType(type);
        messageDO.setSender(sender);
        messageDO.setSenderName(senderName);
        messageDO.setRelationCode(relationCode);
        messageDO.setReceiver(receiver);
        messageDO.setReceiverName(receiverName);
        messageDO.setData(msg);
        messageDO.setOver(over);
        messageDO.setCreateTime(new Date());
        systemMessageDao.save(messageDO);
        return messageDO;
    }
    public void updateLifeCareMessage(LifeCareOrderDO orderDO, String[] type, String toType){
        String orderId=orderDO.getId();
        List<SystemMessageDO> messages = systemMessageDao.queryByRelationCodeAndTypeIn(orderId,type);
        if (toType.equals("patientCancel")){//居民取消 消息列表也应该不显示
            if(CollectionUtils.isEmpty(messages)){
                logger.error("当前工单没有系统消息!!orderId:" + orderId);
            } else {
                messages.forEach(
                        message -> {
                            message.setOver("0");
                            systemMessageDao.save(message);
                        }
                );
            }
        }
    }
}

+ 0 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotDeviceService.java

@ -40,7 +40,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.sun.tools.corba.se.idl.constExpr.Expression.one;
/**
 * @author yeshijie on 2017/12/8.