Browse Source

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

# Conflicts:
#	common/common-entity/sql记录
wangjun 4 years ago
parent
commit
97b89b31de
45 changed files with 2023 additions and 175 deletions
  1. 5 0
      common/common-entity/sql记录
  2. 38 0
      common/common-entity/src/main/java/com/yihu/jw/entity/IdEntity.java
  3. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java
  4. 20 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java
  5. 0 1
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyDO.java
  6. 76 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiDeviceDO.java
  7. 87 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiHealthScoreDO.java
  8. 86 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiHeartDO.java
  9. 76 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiPaiDO.java
  10. 66 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiRealtimeDateDO.java
  11. 126 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiRundateDO.java
  12. 116 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiSleepDO.java
  13. 296 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdXeekLungDO.java
  14. 145 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdXeekLungDetailDO.java
  15. 90 0
      common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyXeekPatientDeviceDO.java
  16. 9 9
      common/common-util/src/main/java/com/yihu/jw/util/common/LatitudeUtils.java
  17. 4 2
      svr/svr-base/src/main/resources/application.yml
  18. 26 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/assistance/EmergencyAssistanceEndpoint.java
  19. 2 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java
  20. 4 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java
  21. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  22. 28 14
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  23. 98 12
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  24. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java
  25. 13 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  26. 0 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  27. 3 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java
  28. 17 14
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  29. 56 0
      svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/CopdXeekDeviceController.java
  30. 188 5
      svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java
  31. 19 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiDeviceDao.java
  32. 11 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiHealthScoreDao.java
  33. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiHeartDao.java
  34. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiPaiDao.java
  35. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiRealtimeDateDao.java
  36. 11 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiRundateDao.java
  37. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiSleepDao.java
  38. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdXeekLungDao.java
  39. 12 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdXeekLungDetailDao.java
  40. 20 0
      svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyXeekPatientDeviceDao.java
  41. 29 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/WlyyIotTzDict.java
  42. 2 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/WlyyIotTzDictDao.java
  43. 10 4
      svr/svr-iot/src/main/java/com/yihu/iot/service/equipment/IotEqtDetailService.java
  44. 92 0
      svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/CopdXeekDeviceService.java
  45. 69 97
      svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

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

@ -427,5 +427,10 @@ ALTER table base_doctor ADD COLUMN `doctor_lat` varchar(100) DEFAULT NULL COMMEN
ALTER table base_doctor ADD COLUMN `doctor_lon` varchar(100) DEFAULT NULL COMMENT '医生当前定位地址经度';
alter TABLE base_emergency_assistance_order add COLUMN complete_time timestamp NULL DEFAULT NULL COMMENT '医生确认完成时间';
-- 2021-04-19 lb
ALTER table base.base_doctor add COLUMN `doctor_locate_address` varchar(100) DEFAULT NULL COMMENT '医生当前定位地址';
ALTER table base.base_emergency_assistance_order add COLUMN `team_code` varchar(100) DEFAULT NULL COMMENT '服务团队';
-- 2021-04-20 wj
alter table base_doctor add doctor_level tinyint(4) DEFAULT NULL COMMENT '类型 1社区医生,2助老员';

+ 38 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/IdEntity.java

@ -0,0 +1,38 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import java.io.Serializable;
/**
 * 统一定义id的entity基类.
 * 
 * 基类统一定义id的属性名称、数据类型、列名映射及生成策略.
 * Oracle需要每个Entity独立定义id的SEQUCENCE时,不继承于本类而改为实现一个Idable的接口。
 * 
 * @author calvin
 */
// JPA 基类的标识
@MappedSuperclass
public abstract class IdEntity implements Serializable {
	private static final long serialVersionUID = 3673803562328635206L;
	protected Long id;  // 非业务主键
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/doctor/BaseDoctorDO.java

@ -289,6 +289,7 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
    private Integer level;
    private String doctorLat;//医生当前定位地址纬度
    private String doctorLon;//医生当前定位地址经度
    private String doctorLocateAddress;//医生定位地址
    @Column(name = "visit_time")
@ -781,4 +782,12 @@ public class BaseDoctorDO extends UuidIdentityEntityWithOperator {
    public void setDoctorLon(String doctorLon) {
        this.doctorLon = doctorLon;
    }
    public String getDoctorLocateAddress() {
        return doctorLocateAddress;
    }
    public void setDoctorLocateAddress(String doctorLocateAddress) {
        this.doctorLocateAddress = doctorLocateAddress;
    }
}

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

@ -1,6 +1,7 @@
package com.yihu.jw.entity.care.assistance;
import com.yihu.jw.entity.UuidIdentityEntityWithOperator;
import netscape.javascript.JSObject;
import javax.persistence.Entity;
import javax.persistence.Table;
@ -32,12 +33,14 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    private String conclusionImg; //服务相关附件
    private Integer status; //工单状态 -1已取消 0已完成 1申请中
    private Date completeTime;//完成时间
    private String teamCode;
    private String sendMessage;//
    private Integer patientAge;
    private String patientPhoto;
    private Integer patientSex;
    private double distance;//医生与患者距离 单位km
    private String otherDoctorDistance;
    public String getPatient() {
        return patient;
@ -190,6 +193,14 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
        this.completeTime = completeTime;
    }
    public String getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(String teamCode) {
        this.teamCode = teamCode;
    }
    @Transient
    public String getSendMessage() {
        return sendMessage;
@ -234,4 +245,13 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    public void setDistance(double distance) {
        this.distance = distance;
    }
    @Transient
    public String getOtherDoctorDistance() {
        return otherDoctorDistance;
    }
    public void setOtherDoctorDistance(String otherDoctorDistance) {
        this.otherDoctorDistance = otherDoctorDistance;
    }
}

+ 0 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/iot/company/IotCompanyDO.java

@ -90,7 +90,6 @@ public class IotCompanyDO extends UuidIdentityEntityWithOperator implements Seri
        this.status = status;
    }
    @Convert(converter = StringFStringEncryptConverter.class)
    public String getName() {
        return name;
    }

+ 76 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiDeviceDO.java

@ -0,0 +1,76 @@
package com.yihu.jw.entity.iot.copdDevice;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/4/14.
 * 华米医疗设备信息
 */
@Entity
@Table(name="wlyy_copd_huami_device")
public class WlyyCopdHuamiDeviceDO extends UuidIdentityEntity {
    private String  patient;    //患者code
    private String  deviceSn;  //设备ID 即sn码
    private String  macAddress;    //设备MAC地址
    private String  lastDataSyncTime;    //上次同步数据的时间戳
    private String  deviceType;    //设备类型:BAND、SCALE、SHOE、WATCH
    private String  deviceName;    //设备名称
    @Column(name="patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name="device_sn")
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    @Column(name="mac_address")
    public String getMacAddress() {
        return macAddress;
    }
    public void setMacAddress(String macAddress) {
        this.macAddress = macAddress;
    }
    @Column(name="last_data_sync_time")
    public String getLastDataSyncTime() {
        return lastDataSyncTime;
    }
    public void setLastDataSyncTime(String lastDataSyncTime) {
        this.lastDataSyncTime = lastDataSyncTime;
    }
    @Column(name="device_type")
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    @Column(name="device_name")
    public String getDeviceName() {
        return deviceName;
    }
    public void setDeviceName(String deviceName) {
        this.deviceName = deviceName;
    }
}

+ 87 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiHealthScoreDO.java

@ -0,0 +1,87 @@
package com.yihu.jw.entity.iot.copdDevice;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/4/14.
 * 华米医疗设备健康分
 */
@Entity
@Table(name="wlyy_copd_huami_health_score")
public class WlyyCopdHuamiHealthScoreDO extends UuidIdentityEntity {
    private String  deviceSn;  //设备ID 即sn码
    private String  exportKey; //本次查询的类型  HealthScore_Week,HealthScore_Month分表表示周健康分和月健康分
    private String  exportTime;    //时间戳,和查询的exportTime对应
    private String  name;   //健康分名称,为”h5”
    private String  score;  //健康分值
    private String  total;  //健康分总分,默认100
    private String  date;//创建时间
    @Column(name="device_sn")
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    @Column(name="export_key")
    public String getExportKey() {
        return exportKey;
    }
    public void setExportKey(String exportKey) {
        this.exportKey = exportKey;
    }
    @Column(name="export_time")
    public String getExportTime() {
        return exportTime;
    }
    public void setExportTime(String exportTime) {
        this.exportTime = exportTime;
    }
    @Column(name="name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name="score")
    public String getScore() {
        return score;
    }
    public void setScore(String score) {
        this.score = score;
    }
    @Column(name="total")
    public String getTotal() {
        return total;
    }
    public void setTotal(String total) {
        this.total = total;
    }
    @Column(name="date")
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
}

+ 86 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiHeartDO.java

@ -0,0 +1,86 @@
package com.yihu.jw.entity.iot.copdDevice;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/4/14.
 * 华米医疗设备心率
 */
@Entity
@Table(name="wlyy_copd_huami_heart")
public class WlyyCopdHuamiHeartDO extends UuidIdentityEntity {
    private String  deviceSn;  //设备sn码
    private String  date;   //数据的本地生成日期,格式为yyyy-MM-dd
    private String  minute; //在当日中的分钟序号(0-1439)
    private String  lastSyncTime; //数据上传到华米后端的时间戳,仅在类型为AUTO时提供
    private String  timestamp;  //心率数据的生成时间戳
    private String  heartRateData;    //测量类型为MANUAL时为心率,测量类型为AUTO时则为该分钟时的平均心率。如果该分钟内未佩戴设备或者未测量心率,则心率为0
    private String  measureType;   //测量类型:AUTO、MANUAL
    @Column(name="device_sn")
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    @Column(name="date")
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    @Column(name="minute")
    public String getMinute() {
        return minute;
    }
    public void setMinute(String minute) {
        this.minute = minute;
    }
    @Column(name="last_sync_time")
    public String getLastSyncTime() {
        return lastSyncTime;
    }
    public void setLastSyncTime(String lastSyncTime) {
        this.lastSyncTime = lastSyncTime;
    }
    @Column(name="timestamp")
    public String getTimestamp() {
        return timestamp;
    }
    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }
    @Column(name="heart_rate_data")
    public String getHeartRateData() {
        return heartRateData;
    }
    public void setHeartRateData(String heartRateData) {
        this.heartRateData = heartRateData;
    }
    @Column(name="measure_type")
    public String getMeasureType() {
        return measureType;
    }
    public void setMeasureType(String measureType) {
        this.measureType = measureType;
    }
}

+ 76 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiPaiDO.java

@ -0,0 +1,76 @@
package com.yihu.jw.entity.iot.copdDevice;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/4/14.
 * 华米医疗设备pai
 */
@Entity
@Table(name="wlyy_copd_huami_pai")
public class WlyyCopdHuamiPaiDO extends UuidIdentityEntity {
    private String  deviceSn;  //设备ID 即sn码
    private String  calendarDay;   //PAI概况的生成日期,例如“2019-10-18”
    private String  timestamp;  //数据上传到华米后端的时间戳
    private String  totalPai;  //用户本周运动前获得的所有PAI
    private String  dailyPai;  //用户在当天获得的PAI
    private String  date;//创建时间
    @Column(name="device_sn")
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    @Column(name="calendar_day")
    public String getCalendarDay() {
        return calendarDay;
    }
    public void setCalendarDay(String calendarDay) {
        this.calendarDay = calendarDay;
    }
    @Column(name="timestamp")
    public String getTimestamp() {
        return timestamp;
    }
    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }
    @Column(name="total_pai")
    public String getTotalPai() {
        return totalPai;
    }
    public void setTotalPai(String totalPai) {
        this.totalPai = totalPai;
    }
    @Column(name="daily_pai")
    public String getDailyPai() {
        return dailyPai;
    }
    public void setDailyPai(String dailyPai) {
        this.dailyPai = dailyPai;
    }
    @Column(name="date")
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
}

+ 66 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiRealtimeDateDO.java

@ -0,0 +1,66 @@
package com.yihu.jw.entity.iot.copdDevice;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/4/14.
 * 华米医疗设备实时数据
 */
@Entity
@Table(name="wlyy_copd_huami_realtime_date")
public class WlyyCopdHuamiRealtimeDateDO extends UuidIdentityEntity {
    private String  deviceSn;  //设备sn码
    private String  hr; //实时心率
    private String  st; //实时步数,采集开始后的累积步数
    private String  cal;    //实时卡路里,累积卡路里
    private String  date;// 创建时间
    @Column(name="device_sn")
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    @Column(name="hr")
    public String getHr() {
        return hr;
    }
    public void setHr(String hr) {
        this.hr = hr;
    }
    @Column(name="st")
    public String getSt() {
        return st;
    }
    public void setSt(String st) {
        this.st = st;
    }
    @Column(name="cal")
    public String getCal() {
        return cal;
    }
    public void setCal(String cal) {
        this.cal = cal;
    }
    @Column(name="date")
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
}

+ 126 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiRundateDO.java

@ -0,0 +1,126 @@
package com.yihu.jw.entity.iot.copdDevice;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/4/14.
 * 华米医疗设备运动数据
 */
@Entity
@Table(name="wlyy_copd_huami_rundate")
public class WlyyCopdHuamiRundateDO extends UuidIdentityEntity {
    private String  deviceSn;  //设备sn码
    private String  date;   //数据的本地生成日期,格式为yyyy-MM-dd
    private String  lastSyncTime; //数据上传到华米后端的时间戳
    private String  steps;  //总步数
    private String  distance;   //包含行走距离和跑步距离在内的总距离,单位为米
    private String  runDistance;   //跑步距离,单位为米,仅在时间间隔为每日的情况下使用
    private String  runTime;   //跑步时间,单位为分钟,仅在时间间隔为每日的情况下使用
    private String  walkTime;  //行走时间,单位为分钟,仅在时间间隔为每日的情况下使用
    private String  calories;   //热量总消耗,单位为千卡
    private String  runCalories;   //跑步消耗热量,单位为千卡,仅在时间间隔为每日的情况下使用
    private String  hour;   //步数分段信息(起止时间不是按照小时来的),用于记录快走慢走跑步等步数类型的数据
    @Column(name="device_sn")
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    @Column(name="date")
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    @Column(name="last_sync_time")
    public String getLastSyncTime() {
        return lastSyncTime;
    }
    public void setLastSyncTime(String lastSyncTime) {
        this.lastSyncTime = lastSyncTime;
    }
    @Column(name="steps")
    public String getSteps() {
        return steps;
    }
    public void setSteps(String steps) {
        this.steps = steps;
    }
    @Column(name="distance")
    public String getDistance() {
        return distance;
    }
    public void setDistance(String distance) {
        this.distance = distance;
    }
    @Column(name="run_distance")
    public String getRunDistance() {
        return runDistance;
    }
    public void setRunDistance(String runDistance) {
        this.runDistance = runDistance;
    }
    @Column(name="run_time")
    public String getRunTime() {
        return runTime;
    }
    public void setRunTime(String runTime) {
        this.runTime = runTime;
    }
    @Column(name="walk_time")
    public String getWalkTime() {
        return walkTime;
    }
    public void setWalkTime(String walkTime) {
        this.walkTime = walkTime;
    }
    @Column(name="calories")
    public String getCalories() {
        return calories;
    }
    public void setCalories(String calories) {
        this.calories = calories;
    }
    @Column(name="run_calories")
    public String getRunCalories() {
        return runCalories;
    }
    public void setRunCalories(String runCalories) {
        this.runCalories = runCalories;
    }
    @Column(name="hour")
    public String getHour() {
        return hour;
    }
    public void setHour(String hour) {
        this.hour = hour;
    }
}

+ 116 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdHuamiSleepDO.java

@ -0,0 +1,116 @@
package com.yihu.jw.entity.iot.copdDevice;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/4/14.
 * 华米医疗设备睡眠
 */
@Entity
@Table(name="wlyy_copd_huami_sleep")
public class WlyyCopdHuamiSleepDO extends UuidIdentityEntity {
    private String  deviceSn;  //设备sn码
    private String  date;   //数据的本地生成日期,格式为yyyy-MM-dd
    private String  lastSyncTime; //数据上传到华米后端的时间戳
    private String  deepSleepTime;    //深度睡眠时长,单位为分钟
    private String  shallowSleepTime; //浅度睡眠时长,单位为分钟
    private String  wakeTime;  //睡眠期间清醒时长,单位为分钟
    private String  sleepScore;    //睡眠评分,范围为 0-100
    private String  start;  //睡眠开始时间。Amazfit设备为分钟序号(0-1439),mifit设备为时间戳
    private String  stop;   //睡眠结束时间。Amazfit设备为分钟序号(0-1439),mifit设备为时间戳
    private String  mode;   //睡眠状态。4为浅度睡眠状态;5为深度睡眠状态;7为清醒状态;8为REM(快速眼动睡眠)
    @Column(name="device_sn")
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    @Column(name="date")
    public String getDate() {
        return date;
    }
    public void setDate(String date) {
        this.date = date;
    }
    @Column(name="last_sync_time")
    public String getLastSyncTime() {
        return lastSyncTime;
    }
    public void setLastSyncTime(String lastSyncTime) {
        this.lastSyncTime = lastSyncTime;
    }
    @Column(name="deep_sleep_time")
    public String getDeepSleepTime() {
        return deepSleepTime;
    }
    public void setDeepSleepTime(String deepSleepTime) {
        this.deepSleepTime = deepSleepTime;
    }
    @Column(name="shallow_sleep_time")
    public String getShallowSleepTime() {
        return shallowSleepTime;
    }
    public void setShallowSleepTime(String shallowSleepTime) {
        this.shallowSleepTime = shallowSleepTime;
    }
    @Column(name="wake_time")
    public String getWakeTime() {
        return wakeTime;
    }
    public void setWakeTime(String wakeTime) {
        this.wakeTime = wakeTime;
    }
    @Column(name="sleep_score")
    public String getSleepScore() {
        return sleepScore;
    }
    public void setSleepScore(String sleepScore) {
        this.sleepScore = sleepScore;
    }
    @Column(name="start")
    public String getStart() {
        return start;
    }
    public void setStart(String start) {
        this.start = start;
    }
    @Column(name="stop")
    public String getStop() {
        return stop;
    }
    public void setStop(String stop) {
        this.stop = stop;
    }
    @Column(name="mode")
    public String getMode() {
        return mode;
    }
    public void setMode(String mode) {
        this.mode = mode;
    }
}

+ 296 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdXeekLungDO.java

@ -0,0 +1,296 @@
package com.yihu.jw.entity.iot.copdDevice;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/4/14.
 */
@Entity
@Table(name="wlyy_copd_xeek_lung")
public class WlyyCopdXeekLungDO extends UuidIdentityEntity {
    private String deviceType;// String Y 设备类型 设备品牌
    private String deviceSN;// String Y 设备 SN 号 设备唯一
    /**
     *  String Y 报告类型:
     *  1=吸气测试;
     * 2=呼气测试;
     * * 3=吸气训练
     *  4=呼气训练
     * 6=MVV 测试;
     * 7=慢通气测试;
     *
     类型不同时,details
     的参数也不同,参
     考 details 参数备注
     */
    private String reportType;
    /**
     * Int Y 用药标志:
     0=无;1=药前;2=药后;
     药前/后是舒张试验
     的吸气和呼气测试
     类型
     */
    private Integer drugFlag;
    private String patientName;// String Y 患者姓名
    private Integer patientGender;// Int Y 患者性别:            1 – 男;2 – 女;
    private String patientBirthday;// String Y 患者出生日期 格式:    YYYYMMDD
    private String patientNation;// String N 民族
    private String patientMobile;// String N 患者手机号
    private String idCardNo;// String N 身份证号
    private String contactAddress;// String N 联系地址
    private String occupation;// String N 职业
    private String residenceNo;// String N 门诊/住院号
    private String smoking;// String N 吸烟史
    private String disease;// String N 病史
    private String weight;// String Y 体重 单位:KG
    private String height;// String Y 身高 单位:CM
    private String inspectTime;// String Y 检查时间 格式:    YYYY-MM-DD    HH:mm:ss
    private String doctorName;// String Y 检查医生姓名
    private String itemName;// String N 检查项目
    private String finalQuality;// String Y 综合质控等级
    private String fvcQuality;// String Y FVC 质控等级
    private String fev1Quality;// String Y FEV1 质控等级
    private String doctorDiag;// String Y 医生诊断结果
    private Integer refEquations;// Int Y 采用的预计值公式 0=默认;            1=中国人 4-80 岁;            2=Standard'
    private String pdfReport;// String N 报告 Url
    @Column(name="device_type")
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    @Column(name="device_sn")
    public String getDeviceSN() {
        return deviceSN;
    }
    public void setDeviceSN(String deviceSN) {
        this.deviceSN = deviceSN;
    }
    @Column(name="report_type")
    public String getReportType() {
        return reportType;
    }
    public void setReportType(String reportType) {
        this.reportType = reportType;
    }
    @Column(name="drug_flag")
    public Integer getDrugFlag() {
        return drugFlag;
    }
    public void setDrugFlag(Integer drugFlag) {
        this.drugFlag = drugFlag;
    }
    @Column(name="patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name="patient_gender")
    public Integer getPatientGender() {
        return patientGender;
    }
    public void setPatientGender(Integer patientGender) {
        this.patientGender = patientGender;
    }
    @Column(name="patient_birthday")
    public String getPatientBirthday() {
        return patientBirthday;
    }
    public void setPatientBirthday(String patientBirthday) {
        this.patientBirthday = patientBirthday;
    }
    @Column(name="patient_nation")
    public String getPatientNation() {
        return patientNation;
    }
    public void setPatientNation(String patientNation) {
        this.patientNation = patientNation;
    }
    @Column(name="patient_mobile")
    public String getPatientMobile() {
        return patientMobile;
    }
    public void setPatientMobile(String patientMobile) {
        this.patientMobile = patientMobile;
    }
    @Column(name="idcard_no")
    public String getIdCardNo() {
        return idCardNo;
    }
    public void setIdCardNo(String idCardNo) {
        this.idCardNo = idCardNo;
    }
    @Column(name="contact_address")
    public String getContactAddress() {
        return contactAddress;
    }
    public void setContactAddress(String contactAddress) {
        this.contactAddress = contactAddress;
    }
    @Column(name="occupation")
    public String getOccupation() {
        return occupation;
    }
    public void setOccupation(String occupation) {
        this.occupation = occupation;
    }
    @Column(name="residence_no")
    public String getResidenceNo() {
        return residenceNo;
    }
    public void setResidenceNo(String residenceNo) {
        this.residenceNo = residenceNo;
    }
    @Column(name="smoking")
    public String getSmoking() {
        return smoking;
    }
    public void setSmoking(String smoking) {
        this.smoking = smoking;
    }
    @Column(name="disease")
    public String getDisease() {
        return disease;
    }
    public void setDisease(String disease) {
        this.disease = disease;
    }
    @Column(name="weight")
    public String getWeight() {
        return weight;
    }
    public void setWeight(String weight) {
        this.weight = weight;
    }
    @Column(name="height")
    public String getHeight() {
        return height;
    }
    public void setHeight(String height) {
        this.height = height;
    }
    @Column(name="inspect_time")
    public String getInspectTime() {
        return inspectTime;
    }
    public void setInspectTime(String inspectTime) {
        this.inspectTime = inspectTime;
    }
    @Column(name="doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name="item_name")
    public String getItemName() {
        return itemName;
    }
    public void setItemName(String itemName) {
        this.itemName = itemName;
    }
    @Column(name="final_quality")
    public String getFinalQuality() {
        return finalQuality;
    }
    public void setFinalQuality(String finalQuality) {
        this.finalQuality = finalQuality;
    }
    @Column(name="fvc_quality")
    public String getFvcQuality() {
        return fvcQuality;
    }
    public void setFvcQuality(String fvcQuality) {
        this.fvcQuality = fvcQuality;
    }
    @Column(name="fev1_quality")
    public String getFev1Quality() {
        return fev1Quality;
    }
    public void setFev1Quality(String fev1Quality) {
        this.fev1Quality = fev1Quality;
    }
    @Column(name="doctor_diag")
    public String getDoctorDiag() {
        return doctorDiag;
    }
    public void setDoctorDiag(String doctorDiag) {
        this.doctorDiag = doctorDiag;
    }
    @Column(name="ref_equations")
    public Integer getRefEquations() {
        return refEquations;
    }
    public void setRefEquations(Integer refEquations) {
        this.refEquations = refEquations;
    }
    @Column(name="pdf_report")
    public String getPdfReport() {
        return pdfReport;
    }
    public void setPdfReport(String pdfReport) {
        this.pdfReport = pdfReport;
    }
}

+ 145 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyCopdXeekLungDetailDO.java

@ -0,0 +1,145 @@
package com.yihu.jw.entity.iot.copdDevice;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2021/4/14.
 */
@Entity
@Table(name="wlyy_copd_xeek_lung_detail")
public class WlyyCopdXeekLungDetailDO extends UuidIdentityEntity {
    private String code;// 关联wlyy_copd_xeek_lung 的id
    private String deviceType;// String Y 设备类型 设备品牌
    private String deviceSN;// String Y 设备 SN 号 设备唯一
    private String parameter;//  Y 指标参数
    private String unit;// String Y 指标单位
    private String preValue;// String Y 预计值
    private String bestValue;// String Y 最佳值
    private String bestPre;// String Y 最佳值/预计值*100%
    private String lln;// String Y 预计值下限 LLN
    private String zScore;// String Y 得分
    private String test1Value;// String Y 实测 1
    private String test2Value;// String Y 实测 2
    private String test3Value;// String Y 实测 3
    public String getCode() {
        return code;
    }
    public void setCode(String code) {
        this.code = code;
    }
    @Column(name="device_type")
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    @Column(name="device_sn")
    public String getDeviceSN() {
        return deviceSN;
    }
    public void setDeviceSN(String deviceSN) {
        this.deviceSN = deviceSN;
    }
    @Column(name="parameter")
    public String getParameter() {
        return parameter;
    }
    public void setParameter(String parameter) {
        this.parameter = parameter;
    }
    @Column(name="unit")
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    @Column(name="pre_value")
    public String getPreValue() {
        return preValue;
    }
    public void setPreValue(String preValue) {
        this.preValue = preValue;
    }
    @Column(name="best_value")
    public String getBestValue() {
        return bestValue;
    }
    public void setBestValue(String bestValue) {
        this.bestValue = bestValue;
    }
    @Column(name="best_pre")
    public String getBestPre() {
        return bestPre;
    }
    public void setBestPre(String bestPre) {
        this.bestPre = bestPre;
    }
    @Column(name="lln")
    public String getLln() {
        return lln;
    }
    public void setLln(String lln) {
        this.lln = lln;
    }
    @Column(name="z_score")
    public String getzScore() {
        return zScore;
    }
    public void setzScore(String zScore) {
        this.zScore = zScore;
    }
    @Column(name="test1_value")
    public String getTest1Value() {
        return test1Value;
    }
    public void setTest1Value(String test1Value) {
        this.test1Value = test1Value;
    }
    @Column(name="test2_value")
    public String getTest2Value() {
        return test2Value;
    }
    public void setTest2Value(String test2Value) {
        this.test2Value = test2Value;
    }
    @Column(name="test3_value")
    public String getTest3Value() {
        return test3Value;
    }
    public void setTest3Value(String test3Value) {
        this.test3Value = test3Value;
    }
}

+ 90 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/iot/copdDevice/WlyyXeekPatientDeviceDO.java

@ -0,0 +1,90 @@
package com.yihu.jw.entity.iot.copdDevice;
import com.yihu.jw.entity.IdEntity;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by yeshijie on 2021/4/15.
 */
@Entity
@Table(name="wlyy_xeek_patient_device")
public class WlyyXeekPatientDeviceDO extends IdEntity {
    private String deviceSn;//设备sn码
    private String name;//姓名
    private Integer sex;//性别
    private String birthday;//生日
    private String mobile;//手机
    private String idcard;//身份证
    private String address;//地区
    private String patient;//居民code
    @Column(name = "device_sn")
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    @Column(name = "name")
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "sex")
    public Integer getSex() {
        return sex;
    }
    public void setSex(Integer sex) {
        this.sex = sex;
    }
    @Column(name = "birthday")
    public String getBirthday() {
        return birthday;
    }
    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }
    @Column(name = "mobile")
    public String getMobile() {
        return mobile;
    }
    public void setMobile(String mobile) {
        this.mobile = mobile;
    }
    @Column(name = "idcard")
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    @Column(name = "address")
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
}

+ 9 - 9
common/common-util/src/main/java/com/yihu/jw/util/common/LatitudeUtils.java

@ -104,15 +104,15 @@ public class LatitudeUtils {
        return distanceStr;
    }
//    public static void main(String args[]){
//        try {
//            Map<String, String> json = LatitudeUtils.getGeocoderLatitude("浦东区张杨路1725号");
//            System.out.println("经度 : " + json.get("lng"));
//            System.out.println("纬度 : " + json.get("lat"));
//        }catch (Exception e ){
//            e.printStackTrace();
//        }
//    }
    public static void main(String args[]){
        try {
            Map<String, String> json = LatitudeUtils.getGeocoderLatitude("厦门海沧区新阳海新阳光公寓15梯304");
            System.out.println("经度 : " + json.get("lng"));
            System.out.println("纬度 : " + json.get("lat"));
        }catch (Exception e ){
            e.printStackTrace();
        }
    }
}

+ 4 - 2
svr/svr-base/src/main/resources/application.yml

@ -436,8 +436,10 @@ spring:
    host: 10.90.32.3 # Redis server host.
    port: 20008  # Redis server port.
    password: jkzlehr
fast-dfs:
  tracker-server: 10.90.32.3:20003 #服务器地址
fastDFS:
  fastdfs_file_url: http://172.19.103.54:80/
  fastdfs_file_url: http://www.xmtyw.cn/
demo:
  flag: true
hospital:
@ -447,7 +449,7 @@ hospital:
  SourceSysCode: S60
  TargetSysCode: S01
wlyy:
  url: http://ehr.yihu.com/wlyy/
  url: http://www.xmtyw.cn/wlyy/
wechat:
  id: d24d1367-7f4f-43af-910e-a0a43799e040
  flag: false

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

@ -46,13 +46,34 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getOrderDetail")
    @ApiOperation(value = "查看救助详情")
    public ObjEnvelop getOrderDetail(@ApiParam(name="orderId",value = "工单id")
                               @RequestParam(value = "orderId") String orderId
    @GetMapping(value = "doctorGetOrderDetail")
    @ApiOperation(value = "医生查看救助详情")//不可查看已取消
    public ObjEnvelop doctorGetOrderDetail(@ApiParam(name="orderId",value = "工单id")
                                     @RequestParam(value = "orderId") String orderId,
                                     @ApiParam(name="doctor",value = "doctor")
                                     @RequestParam(value = "doctor") String doctor
    ){
        try {
            JSONObject result = assistanceService.getOrderDetail(orderId);
            JSONObject result = assistanceService.doctorGetOrderDetail(orderId,doctor);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }
            return ObjEnvelop.getSuccess("查询成功",result.getJSONObject("resultMsg"));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
    @GetMapping(value = "patientGetOrderDetail")
    @ApiOperation(value = "患者查看救助详情")//仅只能查看已完成
    public ObjEnvelop patientGetOrderDetail(@ApiParam(name="orderId",value = "工单id")
                               @RequestParam(value = "orderId") String orderId,
                               @ApiParam(name="patient",value = "patient")
                               @RequestParam(value = "patient") String patient
    ){
        try {
            JSONObject result = assistanceService.patientGetOrderDetail(orderId,patient);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString(ResponseContant.resultMsg));
            }

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

@ -177,12 +177,13 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
    @RequestMapping(value = "/members", method = RequestMethod.GET)
    @ApiOperation(value = "家庭成员查询")
    public ObjEnvelop getPatientFamilyMembers(@RequestParam(required = false) String patient,
                                              @RequestParam(required = false) String isContain,
                                              @RequestParam(required = false) Integer isAgree) {
        try {
            JSONObject data = new JSONObject();
            JSONArray result = new JSONArray();
            if (StringUtils.isNotEmpty(patient)) {
                result = familyMemberService.getPatientMembers(patient, "", true, getUID(),isAgree);
                result = familyMemberService.getPatientMembers(patient, "", isContain,isAgree);
            } else  {
                result = familyMemberService.getPatientFamilyMembers(getUID(), "",null);
            }

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

@ -84,9 +84,11 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "获取居民信息")
    public Envelop getPatientById(
            @ApiParam(name = "id", value = "居民id")
            @RequestParam(value = "id", required = true) String id) {
            @RequestParam(value = "id", required = true) String id,
            @ApiParam(name = "isCapacity", value = "是否返回能力评估,1返回其他值不返回,默认不返回", required = false)
            @RequestParam(value = "isCapacity", required = false) String isCapacity) {
        try{
            return success("获取成功",patientService.findPatientById(id));
            return success("获取成功",patientService.findPatientById(id,isCapacity));
        }catch (Exception e){
            e.printStackTrace();
            return failed("获取失败",-1);

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

@ -46,8 +46,8 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getSecurityOrderList")
    @ApiOperation(value = "获取安防工单列表")
    public ListEnvelop getSecurityOrderList(@ApiParam(name="doctor",value = "医生ID,当前查看列表医生",required = true)
                                            @RequestParam(value = "doctor")String doctor,
    public ListEnvelop getSecurityOrderList(@ApiParam(name="doctor",value = "医生ID,当前查看列表医生",required = false)
                                            @RequestParam(value = "doctor",required = false)String doctor,
                                            @ApiParam(name="serverDoctor",value = "处置医生di 即为患者提供服务的医生")
                                            @RequestParam(value = "serverDoctor",required = false)String serverDoctor,
                                            @ApiParam(name="patientName",value = "患者姓名或身份证")

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

@ -141,6 +141,34 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "serviceItemByPackageId")
    @ApiOperation(value = "根据服务包获取服务项目")
    public ObjEnvelop serviceItemByPackageI (
            @ApiParam(name = "packageId", value = "packageId", required = true)
            @RequestParam(value = "packageId") String packageId) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.serviceItemByPackageId(packageId));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "servicePackageByServerItem")
    @ApiOperation(value = "根据服务项目获取患者服务包列表")
    public ObjEnvelop servicePackageByServerItem (
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient,
            @ApiParam(name = "serverItem", value = "serverItem", required = true)
            @RequestParam(value = "serverItem") String serverItem) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.servicePackageByServerItem(patient,serverItem));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @PostMapping(value = "servicePackageSign")
    @ApiOperation(value = "分配服务包-签约")
    @ObserverRequired
@ -176,20 +204,6 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "servicePackageByPatient")
    @ApiOperation(value = "获取患者服务包")
    public ObjEnvelop servicePackageByPatient (
            @ApiParam(name = "patient", value = "患者id", required = true)
            @RequestParam(value = "patient") String patient,
            @ApiParam(name = "packageType", value = "服务包类型1养老服务、2医疗服务、3安防监护、4慢病管理", required = false)
            @RequestParam(value = "packageType",required = false) String packageType) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.servicePackageByPatient(patient, packageType));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value = "isCapacityAssessment" )
    @ApiOperation(value = "查询今年是否进行过能力评估")

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

@ -1,6 +1,7 @@
package com.yihu.jw.care.service.assistance;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.dao.assistance.EmergencyAssistanceDao;
@ -95,6 +96,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        }
        Map<String,Object> mapTmp = items.get(0);
        List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembers(mapTmp.get("team_code").toString());
        assistanceDO.setTeamCode(mapTmp.get("team_code").toString());
        if (doctorDOS.size()==0){
            String failMsg = "紧急救助服务项服务医生为空,不可发起救助";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
@ -112,7 +114,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
                distance = distanceTmp;
                assistanceDO.setDoctor(doctorDO.getId());
                assistanceDO.setDoctorName(doctorDO.getName());
                assistanceDO.setDoctorAddress("");
                assistanceDO.setDoctorAddress(doctorDO.getDoctorLocateAddress());
                assistanceDO.setDoctorLon(doctorDO.getDoctorLon());
                assistanceDO.setDoctorLat(doctorDO.getDoctorLat());
            }
@ -126,18 +128,13 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        ConsultTeamDo consultTeam = consultTeamDao.queryByRelationCode(assistanceDO.getId());
        if (consultTeam!=null){
            if (StringUtils.isNotBlank(assistanceDO.getSendMessage())){
                imUtill.sendTopicIM(patient,patientDO.getName(),consultTeam.getId(),"1",assistanceDO.getSendMessage(),null);
                imUtill.sendTopicIM(patient,patientDO.getName(),consultTeam.getConsult(),"1",assistanceDO.getSendMessage(),null);
            }
        }
        emergencyAssistanceDao.save(assistanceDO);
        return getOrderDetail(assistanceDO.getId());
    }
    /**
     * 救助工单详情
     * @param orderID
     * @return
     */
    public JSONObject getOrderDetail(String orderID){
        JSONObject result = new JSONObject();
        EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderID);
@ -147,17 +144,98 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembers(assistanceDO.getTeamCode());
        double distance = 0.0;
        JSONArray otherDoctorDistance = new JSONArray();
        JSONObject otherDoctorDistanceObj = new JSONObject();
        for (BaseDoctorDO doctorDO:doctorDOS){
            if (StringUtils.isBlank(doctorDO.getDoctorLat())||StringUtils.isBlank(doctorDO.getDoctorLon())){
                continue;
            }
            double distanceTmp = countDistance.getDistance(Double.parseDouble(assistanceDO.getServeLat()),Double.parseDouble(assistanceDO.getServeLon()),Double.parseDouble(doctorDO.getDoctorLat()),Double.parseDouble(doctorDO.getDoctorLon()));
            if (doctorDO.getId().equals(assistanceDO.getDoctor())){//服务医生
                assistanceDO.setDistance(distance);
            }
            else {
                otherDoctorDistanceObj.put("doctor",doctorDO.getId());
                otherDoctorDistanceObj.put("doctorName",doctorDO.getName());
                otherDoctorDistanceObj.put("doctorAddress",doctorDO.getDoctorLocateAddress());
                otherDoctorDistanceObj.put("doctorLon",doctorDO.getDoctorLon());
                otherDoctorDistanceObj.put("doctorLat",doctorDO.getDoctorLat());
                otherDoctorDistanceObj.put("distance",distanceTmp);
                otherDoctorDistance.add(otherDoctorDistanceObj);
            }
        }
        assistanceDO.setOtherDoctorDistance(otherDoctorDistance.toJSONString());
        BasePatientDO patientDO = patientDao.findById(assistanceDO.getPatient());
        assistanceDO.setPatientPhoto(patientDO.getPhoto());
        assistanceDO.setPatientSex(patientDO.getSex());
        assistanceDO.setPatientAge(IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
        double distance=countDistance.getDistance(Double.parseDouble(assistanceDO.getServeLat()),Double.parseDouble(assistanceDO.getServeLon()),Double.parseDouble(assistanceDO.getDoctorLat()),Double.parseDouble(assistanceDO.getDoctorLon()));
        assistanceDO.setDistance(distance);
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,JSONObject.parseObject(JSON.toJSONStringWithDateFormat(assistanceDO,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue)));
        return result;
    }
    /**
     * 救助工单详情
     * @param orderID
     * @return
     */ //医生无法查看已取消
    public JSONObject doctorGetOrderDetail(String orderID,String doctor){
        JSONObject result = new JSONObject();
        BaseDoctorDO doctorDO = doctorDao.findById(doctor);
        if (doctorDO==null) {
            String failMsg = "医生信息不存在,无法查看";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
            return result;
        }
        EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderID);
        if (assistanceDO==null){
            String failMsg = "当前救助工单不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        if (assistanceDO.getStatus()==-1){
            String failMsg = "当前工单已取消 无法查看";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        return getOrderDetail(orderID);
    }
    /**
     * 救助工单详情
     * @param orderID
     * @return
     *///患者只能查看已完成
    public JSONObject patientGetOrderDetail(String orderID,String patient){
        JSONObject result = new JSONObject();
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO==null) {
            String failMsg = "患者信息不存在,无法查看";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg, failMsg);
            return result;
        }
        EmergencyAssistanceDO assistanceDO = emergencyAssistanceDao.findOne(orderID);
        if (assistanceDO==null){
            String failMsg = "当前救助工单不存在";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        if (assistanceDO.getStatus()!=0){
            String failMsg = "当前工单未完成 无法查看";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        return getOrderDetail(orderID);
    }
    /**
     * 居民救助历史tab数量
     * @param patient
@ -323,6 +401,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            return result;
        }
        else {
            doctorDO.setDoctorLocateAddress(doctorAddress);
            doctorDO.setDoctorLat(doctorLat);
            doctorDO.setDoctorLon(doctorLon);
            doctorDao.save(doctorDO);
@ -356,9 +435,16 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            return result;
        }
        if (consultTeam!=null){
            imUtill.sendTopicIM(patient,patientDO.getName(),consultTeam.getId(),"1",content,null);
            result.put(ResponseContant.resultFlag, ResponseContant.success);
            result.put(ResponseContant.resultMsg,"发送成功");
            String response = imUtill.sendTopicIM(patient,patientDO.getName(),consultTeam.getConsult(),"1",content,null);
            JSONObject jsonObject = JSONObject.parseObject(response);
            if (jsonObject.getInteger("status")==200){
                result.put(ResponseContant.resultFlag, ResponseContant.success);
                result.put(ResponseContant.resultMsg,"发送成功");
            }
            else {
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg,jsonObject.getString("message"));
            }
        }
        return result;
    }

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

@ -311,14 +311,14 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
     * @param patient 居民
     * @return
     */
    public JSONArray getPatientMembers(String patient, String doctorCode, boolean isContain, String current, Integer isAgree) {
    public JSONArray getPatientMembers(String patient, String doctorCode, String isContain, Integer isAgree) {
        JSONArray resultArray = getPatientFamilyMembers(patient, doctorCode, isAgree);
        if (resultArray == null) {
            resultArray = new JSONArray();
        }
        if (isContain && !patient.equals(current)) {
        if ("1".equals(isContain)) {
            BasePatientDO p = patientDao.findById(patient);
            JSONObject obj = new JSONObject();

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

@ -5,11 +5,13 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
import com.yihu.jw.restmodel.web.PageEnvelop;
@ -17,7 +19,6 @@ import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.StringUtil;
import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
@ -54,6 +55,8 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    private WlyyPatientLabelDao patientLabelDao;
    @Autowired
    private DictService dictService;
    @Autowired
    private CapacityAssessmentRecordService capacityAssessmentRecordService;
    /**
     * 签约记录
@ -97,7 +100,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @param patientId
     * @return
     */
    public JSONObject findPatientById(String patientId) throws Exception{
    public JSONObject findPatientById(String patientId,String isCapacity) throws Exception{
        JSONObject res = new JSONObject();
        BasePatientDO patientDO = patientDao.findById(patientId);
        patientDO.setArchiveStatusName(dictService.fingByNameAndCode(ConstantUtil.DICT_ARCHIVESTATUS,String.valueOf(patientDO.getArchiveStatus())));
@ -120,7 +123,15 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            signRecordDO.setHelperList(helperList);
            signRecordDO.setPackageList(packageList);
            res.put("signRecordDO",signRecordDO);
            if("1".equals(isCapacity)){
                //能力评估
                CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
                res.put("capAssRecordDO",recordDO);
            }
        }
        return res;
    }

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

@ -221,8 +221,6 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " +
                    " r.service_package_id = i.service_package_id and  m.team_code = i.team_code  and i.del = 1 and sr.`status`=1  and i.code='8' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
        } else  {
            return new JSONArray();
        }
        if (StringUtils.isNotBlank(serverDoctor)){
            sql +=" and ord.doctor = '"+serverDoctor+"' ";

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

@ -82,7 +82,9 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
     * @return
     */
    public CapacityAssessmentRecordDO findAssessmentByPatientId(String patient)  {
        return capacityAssessmentRecordDao.findByPatient(patient);
        CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordDao.findByPatient(patient);
        recordDO.setLevelConclusionName(dictService.fingByNameAndCode(ConstantUtil.DICT_LEVEL_CONCLUSION,String.valueOf(recordDO.getLevelConclusion())));
        return recordDO;
    }
    /**

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

@ -403,21 +403,24 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return new ArrayList<>();
    }
    public List<ServicePackageRecordDO> servicePackageByPatient(String patient,String packageType){
        //签约记录
        List<ServicePackageSignRecordDO> signs = servicePackageSignRecordDao.findByStatusAndPatient(1,patient);
        if (signs.size()>0){
            ServicePackageSignRecordDO tmp = signs.get(0);
            String sql = " select r.* from base_service_package_record r inner join base_service_package p on r.service_package_id = p.id " +
                    " and p.del=1  where r.sign_id='"+tmp.getId()+"' ";
            if (StringUtils.isNotBlank(packageType)){
                sql += " and p.type='"+packageType+"' ";
            }
            List<ServicePackageRecordDO> result = jdbcTemplate.query(sql,new BeanPropertyRowMapper(ServicePackageRecordDO.class));
            return result;
        }
        else return new ArrayList<>();
    public List<Map<String,Object>> serviceItemByPackageId(String packageId){
        String sql ="select it.code,it.name,count(it.code)count,pack.introduce,pack.type,pack.`name` from base_service_package_item it " +
                "INNER JOIN base_service_package pack on it.service_package_id = pack.id  where it.service_package_id='"+packageId+"' group by it.code ";
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        return result;
    }
    public Map<String, List<Map<String, Object>>> servicePackageByServerItem(String patient, String serverItem)
    {
        String sql="select  DISTINCT pack.*,CASE WHEN pack.type=1 THEN '养老服务' WHEN pack.type=2 THEN '医疗服务'\n" +
                "WHEN pack.type=3 THEN '安防监护' WHEN pack.type=4 THEN '慢病管理' ELSE pack.type\n" +
                "END as 'typeName' from base_service_package_record re, base_service_package_item item,base_service_package pack  \n" +
                "where re.service_package_id = item.service_package_id and item.service_package_id = pack.id and item.code='"+serverItem+"' and re.sign_id in (\n" +
                "select rd.id from base_service_package_sign_record rd  where rd.patient='"+patient+"' and rd.status=1) ";
        List<Map<String,Object>> resultSql = jdbcTemplate.queryForList(sql);
        Map<String,List<Map<String,Object>>> result = resultSql.stream().collect(Collectors.groupingBy(e -> e.get("typeName").toString()));
        return result;
    }
}

+ 56 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/CopdXeekDeviceController.java

@ -0,0 +1,56 @@
package com.yihu.iot.controller.monitorPlatform;
import com.yihu.iot.service.monitorPlatform.CopdXeekDeviceService;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created by Bing on 2021/4/14.
 * 赛客医疗设备
 */
@RestController
@RequestMapping(value = "doctor/xeekDevice", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "赛客医疗设备")
public class CopdXeekDeviceController extends EnvelopRestEndpoint {
    @Autowired
    private CopdXeekDeviceService copdXeekDeviceService;
    @RequestMapping(value = "getXeekDeviceData",method = RequestMethod.GET)
    @ApiOperation(value = "塞克设备数据获取")
    public ObjEnvelop getXeekDeviceData(@ApiParam(name="deviceSN",value = "设备sn码")
                                @RequestParam(value = "deviceSN",required = false)String deviceSN,
                                    @ApiParam(name="reportType",value = "测试项目 1=吸气测试;2=呼气测试;6=MVV 测试;7=慢通气测试")
                                @RequestParam(value = "reportType")String reportType,
                                    @ApiParam(name="patient",value = "patient")
                                @RequestParam(value = "patient",required = false)String patient,
                                    @ApiParam(name="parameter",value = "数据指标 inCount,outCount")
                                @RequestParam(value = "parameter",required = false)String parameter,
                                    @ApiParam(name="time",value = "7 30 90")
                                @RequestParam(value = "time",required = false)String time,
                                    @ApiParam(name="begin",value = "开始时间 YYYY-MM-DD HH:MM:SS" ,defaultValue = "2021-04-14 00:00:00")
                                @RequestParam(value = "begin")String begin,
                                    @ApiParam(name="end",value = "结束时间 YYYY-MM-DD HH:MM:SS" ,defaultValue = "2021-04-14 23:59:59" )
                                @RequestParam(value = "end")String end)
    {
        if (StringUtils.isBlank(patient)&&StringUtils.isBlank(deviceSN)){
            return ObjEnvelop.getError("参数错误");
        }
        try {
            return ObjEnvelop.getSuccess("查询成功",copdXeekDeviceService.getDeviceData(patient,deviceSN,reportType,parameter,time,begin,end));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
}

+ 188 - 5
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -6,6 +6,7 @@ import com.yihu.iot.service.company.IotCompanyService;
import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.equipment.IotEqtDetailService;
import com.yihu.iot.service.monitorPlatform.CopdXeekDeviceService;
import com.yihu.iot.service.monitorPlatform.MonitorPlatformService;
import com.yihu.iot.service.product.IotProductBaseInfoService;
import com.yihu.jw.entity.iot.device.IotPatientDeviceDO;
@ -13,6 +14,7 @@ import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.restmodel.iot.device.IotPatientDeviceVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
@ -21,12 +23,13 @@ import io.swagger.annotations.ApiParam;
import iot.device.LocationDataVO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * Created by yeshijie on 2020/5/11.
@ -48,6 +51,10 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
    private IotEqtDetailService iotEqtDetailService;
    @Autowired
    private IotCompanyService iotCompanyService;
    @Autowired
    private CopdXeekDeviceService copdXeekDeviceService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @PostMapping(value = IotRequestMapping.PatientDevice.addPatientDevice)
@ -627,6 +634,34 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
        }
    }
    @RequestMapping(value = "getXeekDeviceData",method = RequestMethod.GET)
    @ApiOperation(value = "塞克设备数据获取")
    public ObjEnvelop getXeekDeviceData(@ApiParam(name="deviceSN",value = "设备sn码")
                                    @RequestParam(value = "deviceSN",required = false)String deviceSN,
                                    @ApiParam(name="reportType",value = "测试项目 1=吸气测试;2=呼气测试;6=MVV 测试;7=慢通气测试")
                                    @RequestParam(value = "reportType")String reportType,
                                    @ApiParam(name="patient",value = "patient")
                                    @RequestParam(value = "patient",required = false)String patient,
                                    @ApiParam(name="parameter",value = "数据指标 inCount,outCount")
                                    @RequestParam(value = "parameter",required = false)String parameter,
                                    @ApiParam(name="time",value = "7 30 90")
                                    @RequestParam(value = "time",required = false)String time,
                                    @ApiParam(name="begin",value = "开始时间 YYYY-MM-DD HH:MM:SS" ,defaultValue = "2021-04-14 00:00:00")
                                    @RequestParam(value = "begin")String begin,
                                    @ApiParam(name="end",value = "结束时间 YYYY-MM-DD HH:MM:SS" ,defaultValue = "2021-04-14 23:59:59" )
                                    @RequestParam(value = "end")String end)
    {
        if (StringUtils.isBlank(patient)&&StringUtils.isBlank(deviceSN)){
            return ObjEnvelop.getError("参数错误");
        }
        try {
            return ObjEnvelop.getSuccess("查询成功",copdXeekDeviceService.getDeviceData(patient,deviceSN,reportType,parameter,time,begin,end));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
    @ApiOperation("获取门诊记录/住院记录(基卫+APP)")
    @RequestMapping(value = "/event", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getAllEvent(@ApiParam(name = "patient", value = "患者代码", defaultValue = "")
@ -873,13 +908,161 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
    }
    @RequestMapping(value = "savePatientDeviceLocation",method = RequestMethod.POST)
    public Envelop savePatientDeviceLocation(){
    public Envelop savePatientDeviceLocation(String categoryCode){
        try {
            return success(monitorPlatformService.savePatientDeviceLocation());
            return success(monitorPlatformService.savePatientDeviceLocation(categoryCode));
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("操作失败");
        }
    }
    @ApiOperation("获取运动记录")
    @RequestMapping(value = "getSportRecord",method = {RequestMethod.POST,RequestMethod.GET})
    public Envelop getSportRecord(
            @ApiParam(name="patient",value="i健康居民code",defaultValue = "0fab4dd67e074e16ac86db6b6c15233e") @RequestParam(value = "patient", required = false)String patient,
            @ApiParam(name="date",value="开始日期,如2020-05-09",defaultValue = "2020-05-09") @RequestParam(value = "date", required = false)String date,
            @ApiParam(name="type",value="大屏选择项",defaultValue = "hear") @RequestParam(value = "type", required = false)String type,
            @ApiParam(name="day",value="周期",defaultValue = "7") @RequestParam(value = "day", required = false)Integer day
    ){
        try {
            JSONObject json = new JSONObject();
            String endDate = getNewDate(date,day);
            if (type.equals("hear") || type.equals("all")){
                //心率
                List<Map<String,Object>> hearDo = monitorPlatformService.getHeartByPatient(patient,date,endDate);
                if (hearDo.size() > 0){
                    json.put("hear",hearDo);//心率
                }else {
                    json.put("hear",0);//心率
                }
            }
            if (type.equals("score") || type.equals("all")){
                //健康分  retWeekTime("week");  周的健康分
                List<Map<String, Object>> scoreDO = monitorPlatformService.getHealthScoreByPatient(patient,date,endDate);
                if (scoreDO.size() > 0){
                    json.put("score",scoreDO); //健康分值
                }else {
                    json.put("score",0); //健康分值
                }
            }
            if (type.equals("realtime") || type.equals("all")){
                // 实时数据
                List<Map<String, Object>> realtimeDateDo = monitorPlatformService.getRealtimeDateByPatient(patient,date);
                if (realtimeDateDo.size() > 0){
                    json.put("realtime",realtimeDateDo.get(0)); //实时心率
//                    Map<String,Object> map = realtimeDateDo.get(0);
//                    json.put("realtimehr",map.get("hr")); //实时心率
//                    json.put("realtimest",map.get("st")); //实时步数,采集开始后的累积步数
//                    json.put("realtimecal",map.get("cal")); //实时卡路里,累积卡路里
                }else {
                    json.put("realtime",0);
//                    json.put("realtimehr",0); //实时心率
//                    json.put("realtimest",0); //实时步数,采集开始后的累积步数
//                    json.put("realtimecal",0); //实时卡路里,累积卡路里
                }
            }
            if (type.equals("runData") || type.equals("all")){
                //运动数据  runDate
                List<Map<String , Object>> rundateDo = monitorPlatformService.getRundatePatient(patient,date);
                if (rundateDo.size() > 0){
                    json.put("runData",rundateDo.get(0));
//                    Map<String,Object> map = rundateDo.get(0);
//                    json.put("steps",map.get("steps")); //总步数
//                    json.put("distance",map.get("distance")); //总距离
//                    json.put("walkTime",map.get("walk_time")); //步行时长
//                    json.put("runDistance",map.get("run_distance")); //跑步距离
//                    json.put("runTime",map.get("run_time")); //跑步时长
//                    json.put("calories",map.get("calories")); //总燃烧卡路里
//                    json.put("runCalories",map.get("run_calories")); //跑步消耗卡路里
                }else {
                    json.put("runData",0);
//                    json.put("steps",0); //总步数
//                    json.put("distance",0); //总距离
//                    json.put("walkTime",0); //步行时长
//                    json.put("runDistance",0); //跑步距离
//                    json.put("runTime",0); //跑步时长
//                    json.put("calories",0); //总燃烧卡路里
//                    json.put("runCalories",0); //跑步消耗卡路里
                }
            }
            if (type.equals("pai") || type.equals("all")){
                //PAI数据
                List<Map<String,Object>> paiDo = monitorPlatformService.getPaiPatient(patient,date);
                if (paiDo.size() > 0){
                    json.put("pai",paiDo.get(0));
//                    Map<String,Object> map = paiDo.get(0);
//                    json.put("totalPai",map.get("total_pai")); //用户本周运动前获得的所有PAI
//                    json.put("dailyPai",map.get("daily_pai")); //用户在当天获得的PAI
                }else {
                    json.put("pai",0);
//                    json.put("totalPai",0); //总
//                    json.put("dailyPai",0); //总距离
                }
            }
            if (type.equals("sleepData") || type.equals("all")){
                //睡眠数据
                List<Map<String , Object>> sleepDo = monitorPlatformService.getSleepByPatient(patient,date);
                if (sleepDo.size() > 0){
                    json.put("sleepData",sleepDo.get(0));
//                    Map<String,Object> map = sleepDo.get(0);
//                    json.put("deepSleepTime",map.get("deep_sleep_time")); //深度睡眠时长,单位为分钟
//                    json.put("shallowSleepTime",map.get("shallow_sleep_time")); //浅度睡眠时长,单位为分钟
//                    json.put("wakeTime",map.get("wake_time")); //睡眠期间清醒时长,单位为分钟
//                    json.put("sleepScore",map.get("sleep_score")); //睡眠评分
//                    json.put("start",map.get("start")); //睡眠开始时间。Amazfit设备为分钟序号(0-1439),mifit设备为时间戳
//                    json.put("stop",map.get("stop")); //睡眠结束时间。Amazfit设备为分钟序号(0-1439),mifit设备为时间戳
                }else {
                    json.put("sleepData",sleepDo.get(0));
//                    json.put("deepSleepTime",0); //深度睡眠时长,单位为分钟
//                    json.put("shallowSleepTime",0); //浅度睡眠时长,单位为分钟
//                    json.put("wakeTime",0); //睡眠期间清醒时长,单位为分钟
//                    json.put("sleepScore",0); //睡眠评分
//                    json.put("start",0); //睡眠开始时间。Amazfit设备为分钟序号(0-1439),mifit设备为时间戳
//                    json.put("stop",0); //睡眠结束时间。Amazfit设备为分钟序号(0-1439),mifit设备为时间戳
                }
            }
            return success("查询成功",json);
        }catch (Exception e){
            e.printStackTrace();
            return MixEnvelop.getError("查询失败");
        }
    }
    private String getNewDate(String date,Integer day) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date newDate = sdf.parse(date);
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(newDate);
        calendar.add(Calendar.DAY_OF_MONTH, -day);
        System.out.println(sdf.format(calendar.getTime()));
        return sdf.format(calendar.getTime());
    }
    @ApiOperation("获取赛客查询指标")
    @RequestMapping(value = "getXeekParameters",method = {RequestMethod.POST,RequestMethod.GET})
    public ObjEnvelop getSportRecord(){
        try {
            String sql = "select value as code,name1 name from xmiot.wlyy_iot_tz_dict where code='COPD_PARAMETER' and del=1";
            List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
            return  ObjEnvelop.getSuccess("查询成功",result);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
    @ApiOperation("获取华米手环查询指标")
    @RequestMapping(value = "getHuaMiParameters",method = {RequestMethod.POST,RequestMethod.GET})
    public ObjEnvelop getHuaMiParameters(){
        try {
            String sql = "select value as code,name from xmiot.wlyy_iot_tz_dict where code='HuaMiIot' and del=1";
            List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
            return  ObjEnvelop.getSuccess("查询成功",result);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
}

+ 19 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiDeviceDao.java

@ -0,0 +1,19 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyCopdHuamiDeviceDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/14.
 */
public interface WlyyCopdHuamiDeviceDao extends PagingAndSortingRepository<WlyyCopdHuamiDeviceDO, String>, JpaSpecificationExecutor<WlyyCopdHuamiDeviceDO> {
    @Query("select t from WlyyCopdHuamiDeviceDO t where t.patient = ?1")
    WlyyCopdHuamiDeviceDO selectDevice(String patient);
    WlyyCopdHuamiDeviceDO findByPatient(String patient);
}

+ 11 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiHealthScoreDao.java

@ -0,0 +1,11 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyCopdHuamiHealthScoreDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/14.
 */
public interface WlyyCopdHuamiHealthScoreDao extends PagingAndSortingRepository<WlyyCopdHuamiHealthScoreDO, String>, JpaSpecificationExecutor<WlyyCopdHuamiHealthScoreDO> {
}

+ 12 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiHeartDao.java

@ -0,0 +1,12 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyCopdHuamiHeartDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/14.
 */
public interface WlyyCopdHuamiHeartDao extends PagingAndSortingRepository<WlyyCopdHuamiHeartDO, String>, JpaSpecificationExecutor<WlyyCopdHuamiHeartDO> {
}

+ 12 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiPaiDao.java

@ -0,0 +1,12 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyCopdHuamiPaiDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/14.
 */
public interface WlyyCopdHuamiPaiDao extends PagingAndSortingRepository<WlyyCopdHuamiPaiDO, String>, JpaSpecificationExecutor<WlyyCopdHuamiPaiDao> {
}

+ 12 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiRealtimeDateDao.java

@ -0,0 +1,12 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyCopdHuamiRealtimeDateDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/14.
 */
public interface WlyyCopdHuamiRealtimeDateDao extends PagingAndSortingRepository<WlyyCopdHuamiRealtimeDateDO, String>, JpaSpecificationExecutor<WlyyCopdHuamiRealtimeDateDO> {
}

+ 11 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiRundateDao.java

@ -0,0 +1,11 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyCopdHuamiRundateDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/14.
 */
public interface WlyyCopdHuamiRundateDao extends PagingAndSortingRepository<WlyyCopdHuamiRundateDO, String>, JpaSpecificationExecutor<WlyyCopdHuamiRundateDO> {
}

+ 12 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdHuamiSleepDao.java

@ -0,0 +1,12 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyCopdHuamiSleepDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/14.
 */
public interface WlyyCopdHuamiSleepDao extends PagingAndSortingRepository<WlyyCopdHuamiSleepDO, String>, JpaSpecificationExecutor<WlyyCopdHuamiSleepDO> {
}

+ 12 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdXeekLungDao.java

@ -0,0 +1,12 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyCopdXeekLungDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/14.
 */
public interface WlyyCopdXeekLungDao extends PagingAndSortingRepository<WlyyCopdXeekLungDO, String>, JpaSpecificationExecutor<WlyyCopdXeekLungDO> {
}

+ 12 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyCopdXeekLungDetailDao.java

@ -0,0 +1,12 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyCopdXeekLungDetailDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/4/14.
 */
public interface WlyyCopdXeekLungDetailDao extends PagingAndSortingRepository<WlyyCopdXeekLungDetailDO, String>, JpaSpecificationExecutor<WlyyCopdXeekLungDetailDO> {
}

+ 20 - 0
svr/svr-iot/src/main/java/com/yihu/iot/dao/platform/WlyyXeekPatientDeviceDao.java

@ -0,0 +1,20 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyXeekPatientDeviceDO;
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/4/15.
 */
public interface WlyyXeekPatientDeviceDao extends PagingAndSortingRepository<WlyyXeekPatientDeviceDO, Long>, JpaSpecificationExecutor<WlyyXeekPatientDeviceDO> {
    WlyyXeekPatientDeviceDO findByDeviceSnAndNameAndSexAndBirthday(String deviceSn,String name,Integer sex,String birthday);
    @Query("from WlyyXeekPatientDeviceDO c where c.patient is null)")
    List<WlyyXeekPatientDeviceDO> findNoPatient();
}

+ 29 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/WlyyIotTzDict.java

@ -17,6 +17,12 @@ public class WlyyIotTzDict extends UuidIdentityEntity implements Serializable {
    @Column(name = "name")
    private String name;
    @Column(name = "name1")
    private String name1;
    private Integer del;
    private String value;
    public String getCode() {
        return code;
@ -34,4 +40,27 @@ public class WlyyIotTzDict extends UuidIdentityEntity implements Serializable {
        this.name = name;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getName1() {
        return name1;
    }
    public void setName1(String name1) {
        this.name1 = name1;
    }
}

+ 2 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/analyzer/WlyyIotTzDictDao.java

@ -7,4 +7,6 @@ import java.util.List;
public interface WlyyIotTzDictDao extends PagingAndSortingRepository<WlyyIotTzDict, String>, JpaSpecificationExecutor<WlyyIotTzDict>  {
    WlyyIotTzDict findByCodeAndDel(String code,Integer del);
}

+ 10 - 4
svr/svr-iot/src/main/java/com/yihu/iot/service/equipment/IotEqtDetailService.java

@ -171,7 +171,7 @@ public class IotEqtDetailService  extends BaseJpaService<IotEquipmentDetailDO, I
       return list;
    }
    public List<LocationDataVO> getEquipmentLocation(Integer page, Integer size){
    public List<LocationDataVO> getEquipmentLocation(Integer page, Integer size,String manufacturerCode){
        List<Map<String, Object>> jsonArray = new ArrayList<>();
@ -185,8 +185,11 @@ public class IotEqtDetailService  extends BaseJpaService<IotEquipmentDetailDO, I
                "longitude AS lon, " +
                "create_time AS createTime " +
                "FROM " +
                "iot_equipmet_detail LIMIT "+(page-1)*size+","+size;
                "iot_equipmet_detail ";
        if(StringUtils.isNoneBlank(manufacturerCode)){
            sql += " where manufacturer_code in ('"+manufacturerCode+"')";
        }
        sql += " LIMIT "+(page-1)*size+","+size;
        jsonArray = jdbcTemplate.queryForList(sql);
        for (Map<String, Object> jsobj:jsonArray){
            LocationDataVO locationDataVO = new LocationDataVO();
@ -208,8 +211,11 @@ public class IotEqtDetailService  extends BaseJpaService<IotEquipmentDetailDO, I
        return result;
    }
    public Integer getEquipmentCount(){
    public Integer getEquipmentCount(String manufacturerCode){
        String sql = "SELECT count(1) totalCount FROM iot_equipmet_detail ";
        if(StringUtils.isNoneBlank(manufacturerCode)){
            sql += " where manufacturer_code in ('"+manufacturerCode+"')";
        }
        Integer totalCount = jdbcTemplate.queryForObject(sql,Integer.class);
        return totalCount;
    }

+ 92 - 0
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/CopdXeekDeviceService.java

@ -0,0 +1,92 @@
package com.yihu.iot.service.monitorPlatform;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.iot.dao.platform.WlyyCopdXeekLungDao;
import com.yihu.iot.dao.platform.WlyyCopdXeekLungDetailDao;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * Created by Bing on 2021/4/14.
 *
 */
@Service
public class CopdXeekDeviceService  {
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WlyyCopdXeekLungDetailDao lungDetailDao;
    @Autowired
    private WlyyCopdXeekLungDao lungDao;
    public JSONObject getDeviceData(String patient,String deviceSN, String reportType, String parameter, String time, String begin, String end){
        List<Map<String,Object>> detailList = new ArrayList<>();
        StringBuilder sql = new StringBuilder(" select inspect_time dayTime,de.*,dict.name,lu.inspect_time from xmiot.wlyy_copd_xeek_lung_detail de," +
                "xmiot.wlyy_copd_xeek_lung lu, xmiot.wlyy_iot_tz_dict dict  where  de.code = lu.id and dict.del=1 " +
                "and  dict.code='COPD_PARAMETER' and dict.value = de.parameter ");
        if (StringUtils.isNotBlank(patient)){
            sql.append(" and lu.patient='"+patient+"' ");
        }
        if (StringUtils.isNotBlank(deviceSN)){
            sql.append(" and lu.device_sn='"+deviceSN+"' ");
        }
        if (StringUtils.isNotBlank(reportType)){
            sql.append(" and lu.report_type='"+reportType+"' ");
        }
        if (StringUtils.isNotBlank(parameter)){
            sql.append(" and de.parameter='"+parameter+"' ");
        }
        if (StringUtils.isNotBlank(begin)){
            sql.append(" and lu.inspect_time>='"+begin+"' ");
        }
        if (StringUtils.isNotBlank(end)){
            sql.append(" and lu.inspect_time<='"+end+"' ");
        }
        sql.append(" GROUP BY inspect_time,de.id order by de.parameter, lu.inspect_time asc ");
        detailList = jdbcTemplate.queryForList(sql.toString());
        //lu.report_type1=吸气测试;2=呼气测试; 3=吸气训练4=呼气训练6=MVV 测试;7=慢通气测试;
        StringBuilder sqlIn= new StringBuilder("select de.times test1_value ,inspect_time dayTime,'次' unit,'吸气训练数据' name,'inCount' parameter " +
                "from xmiot.wlyy_copd_xeek_lung_training de,xmiot.wlyy_copd_xeek_lung lu  where  de.code = lu.id and lu.report_type=3 ");
        StringBuilder sqlOut= new StringBuilder("select de.times test1_value ,inspect_time dayTime,'次' unit,'呼气训练数据' name,'outCount' parameter " +
                "from xmiot.wlyy_copd_xeek_lung_training de,xmiot.wlyy_copd_xeek_lung lu  where  de.code = lu.id and lu.report_type=4 ");
        sql = new StringBuilder("");
        if (StringUtils.isNotBlank(patient)){
            sql.append(" and lu.patient='"+patient+"' ");
        }
        if (StringUtils.isNotBlank(deviceSN)){
            sql.append(" and lu.device_sn='"+deviceSN+"' ");
        }
        if (StringUtils.isNotBlank(begin)){
            sql.append(" and lu.inspect_time>='"+begin+"' ");
        }
        if (StringUtils.isNotBlank(end)){
            sql.append(" and lu.inspect_time<='"+end+"' ");
        }
        sql.append(" order by  lu.inspect_time asc ");
        if ((StringUtils.isNotBlank(parameter)&&parameter.equals("inCount"))||StringUtils.isBlank(parameter)){//吸气训练次数 MIP
            List<Map<String,Object>> tmp = jdbcTemplate.queryForList(sqlIn.append(sql).toString());
            detailList.addAll(tmp);
        }
        if ((StringUtils.isNotBlank(parameter)&&parameter.equals("outCount"))||StringUtils.isBlank(parameter)){//呼气训练次数 FVC
            List<Map<String,Object>> tmp = jdbcTemplate.queryForList(sqlOut.append(sql).toString());
            detailList.addAll(tmp);
        }
        Map<String,List<Map<String,Object>>> filterMap  = detailList.stream().collect(Collectors.groupingBy(e -> e.get("parameter").toString()));
        String jsonStr = JSON.toJSONString(filterMap, SerializerFeature.WriteMapNullValue);
        return JSONObject.parseObject(jsonStr);
    }
}

+ 69 - 97
svr/svr-iot/src/main/java/com/yihu/iot/service/monitorPlatform/MonitorPlatformService.java

@ -3,9 +3,10 @@ package com.yihu.iot.service.monitorPlatform;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.google.gson.JsonObject;
import com.yihu.iot.dao.dict.IotSystemDictDao;
import com.yihu.iot.dao.equipment.IotEquipmentDetailDao;
import com.yihu.iot.service.analyzer.WlyyIotTzDict;
import com.yihu.iot.service.analyzer.WlyyIotTzDictDao;
import com.yihu.iot.service.common.MyJdbcTemplate;
import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.iot.service.equipment.IotEqtDetailService;
@ -24,23 +25,18 @@ import iot.device.LocationDataVO;
import org.apache.http.Consts;
import org.apache.http.client.utils.URLEncodedUtils;
import org.apache.http.message.BasicNameValuePair;
import org.apache.jasper.tagplugins.jstl.core.ForEach;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.elasticsearch.core.geo.GeoPoint;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SqlInOutParameter;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.print.DocFlavor;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.text.DecimalFormat;
import java.time.temporal.Temporal;
import java.util.*;
/**
@ -81,6 +77,8 @@ public class MonitorPlatformService  {
    private IotInterfaceLogService iotInterfaceLogService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private WlyyIotTzDictDao wlyyIotTzDictDao;
    /**
     * 获取位置信息
@ -118,19 +116,6 @@ public class MonitorPlatformService  {
                    locationDataVO = iotPatientDeviceService.addNameAndCodeToLocationVO(locationDataVO);
                    locationDataVOList.add(locationDataVO);
                });
//                JSONArray jsonArrayTemp = new JSONArray();
//                JSONObject deviceSn = new JSONObject();
//                deviceSn.put("andOr","or");
//                deviceSn.put("field","deviceSn");
//                deviceSn.put("condition","=");
//                deviceSn.put("value",list.getString(i));
//                jsonArrayTemp.add(deviceSn);
//                JSONObject jsonObject = new JSONObject();
//                jsonObject.put("filter",jsonArrayTemp);
//                jsonObject.put("page",page);
//                jsonObject.put("size",size);
//                List<LocationDataVO> locationDataVOList = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonObject.toString());
                //figureLabelSerachService.getFigureLabelByList(locationDataVOList);
                envelop.getDetailModelList().addAll(locationDataVOList);
            }
            envelop.setTotalCount(total);
@ -140,24 +125,20 @@ public class MonitorPlatformService  {
            int totalEqCount=0;
            int totalCount=0;
            //小屋总数
            if(deviceType.contains("5")){
                if (org.apache.commons.lang3.StringUtils.isBlank(deviceName)||(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) &&deviceName.contains("健康小屋"))){
                    totalEqCount = iotEqtDetailService.getEquipmentCount();
                }
            String manufacturerCode = deviceType;
            manufacturerCode = manufacturerCode.replace(",","','").replace("5","yituo").replace("10","xeek").replace("11","xiaomi");
            if(deviceType.contains("5")||deviceType.contains("10")||deviceType.contains("11")){
                totalEqCount = iotEqtDetailService.getEquipmentCount(manufacturerCode);
            }
            String[] categoryCodes= deviceType.split(",");
            if(categoryCodes.length==1&&"5".equals(deviceType)){
                if (org.apache.commons.lang3.StringUtils.isBlank(deviceName)||(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) &&deviceName.contains("健康小屋"))){
                    euipmentList = iotEqtDetailService.getEquipmentLocation(page,size);
                    envelop.getDetailModelList().addAll(euipmentList);
                }
            if(categoryCodes.length==1&&(deviceType.contains("5")||deviceType.contains("10")||deviceType.contains("11"))){
                euipmentList = iotEqtDetailService.getEquipmentLocation(page,size,manufacturerCode);
                envelop.getDetailModelList().addAll(euipmentList);
            }
            else{
                if(deviceType.contains("5")){
                    if (org.apache.commons.lang3.StringUtils.isBlank(deviceName)||(org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName) &&deviceName.contains("健康小屋"))){
                        euipmentList = iotEqtDetailService.getEquipmentLocation(page,size);
                        envelop.getDetailModelList().addAll(euipmentList);
                    }
                if(deviceType.contains("5")||deviceType.contains("10")||deviceType.contains("11")){
                    euipmentList = iotEqtDetailService.getEquipmentLocation(page,size,manufacturerCode);
                    envelop.getDetailModelList().addAll(euipmentList);
                }
                StringBuffer sql = new StringBuffer("select id,idcard idCard,category_code categoryCode,device_sn deviceSn,location,device_time deviceTime,disease_condition diseaseCondition,\n" +
                        "create_time createTime,device_name equimentName\n" +
@ -198,60 +179,6 @@ public class MonitorPlatformService  {
                    locationDataVOList.add(locationDataVO);
                });
                envelop.getDetailModelList().addAll(locationDataVOList);
//                for (String categoryCode:categoryCodes){
//                    JSONObject json = new JSONObject();
//                    JSONArray jsonArray = new JSONArray();
//                    if(diseaseCondition!=null){
//                        json.put("andOr","and");
//                        json.put("field","diseaseCondition");
//                        json.put("condition","=");
//                        json.put("value",diseaseCondition);
//                        jsonArray.add(json);
//                    }
//                     if(!"5".equals(categoryCode)){
//                         json = new JSONObject();
//                         List<String> listTmp = new ArrayList<>();
//                         if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
//                             String[] deviceNames = deviceName.split(",");
//                             for (String tmp :deviceNames){
//                                 String sql="select DISTINCT device_code  from device.wlyy_devices wd   where wd.device_name like '%"+tmp+"%'  ";
//                                 List<String> tmpList = jdbcTemplate.queryForList(sql,String.class);
//                                 listTmp.addAll(tmpList);
//                             }
//                             if (listTmp.size()!=0){
//                                 json.put("andOr","and");
//                                 json.put("field","deviceSn");
//                                 json.put("condition","in");
//                                 json.put("value",listTmp);
//                                 jsonArray.add(json);
//                             }
//                         }
//                         else{
//                            if(!"5".equals(categoryCode)) {
//                                json.put("andOr", "and");
//                                json.put("field", "categoryCode");
//                                json.put("condition", "=");
//                                json.put("value", Integer.parseInt(categoryCode));
//                                jsonArray.add(json);
//                            }
//                         }
//                         JSONObject jsonObject = new JSONObject();
//                         jsonObject.put("filter",jsonArray);
//                         jsonObject.put("page",page);
//                         jsonObject.put("size",size);
//                         if (jsonArray.size()!=0){
//                             List<LocationDataVO> locationDataVOList = iotPatientDeviceService.findDeviceLocationsByIdCard(jsonObject.toString());
//                             List<LocationDataVO> list2 = iotPatientDeviceService.addNameAndCodeToList(locationDataVOList);
//                             //figureLabelSerachService.getFigureLabelByList(locationDataVOList);
//                             envelop.getDetailModelList().addAll(list2);
//                           totalCount += iotPatientDeviceService.getESCount(jsonObject.toString());
//                         }
//                     }
//                     if (org.apache.commons.lang3.StringUtils.isNoneBlank(deviceName)){
//                         break;
//                     }
//                }
            }
            envelop.setTotalCount(totalCount>totalEqCount?totalCount:totalEqCount);
            return envelop;
@ -1206,7 +1133,7 @@ public class MonitorPlatformService  {
            params.put("appid", appid);
            params.put("appSecret", appSecret);
            String url = "/gc/accesstoken";
            String response = httpClientUtil.httpPost(wlyyUrl + url, params);
            String response = HttpClientUtil.httpPost(wlyyUrl + url, params);
            JSONObject jsonObject = JSON.parseObject(response);
            if(jsonObject.getInteger("status")==10000){
                String accesstoken = jsonObject.getJSONObject("result").getString("accesstoken");
@ -1248,7 +1175,7 @@ public class MonitorPlatformService  {
                    "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机'  \n" +
                    "GROUP BY wd.manufacturer_code,pd.device_name\n" +
                    "UNION\n" +
                    "select '健康小屋' device_name,manufacturer from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
                    "select case device_name when '自助体检一体机' then '健康小屋'  else device_name  end AS device_name,manufacturer from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
                    ")A\n" +
                    "GROUP BY A.manufacturer\n" +
                    "ORDER BY total desc";
@ -1262,7 +1189,7 @@ public class MonitorPlatformService  {
                    "and wd.manufacturer_code is not null and wd.manufacturer_code <>'' and pd.device_name<>'血压计-null' and pd.device_name<>'血糖仪-自助体检一体机' \n" +
                    "GROUP BY wd.manufacturer_code,pd.device_name\n" +
                    "UNION\n" +
                    "select '健康小屋' device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
                    "select case device_name when '自助体检一体机' then '健康小屋'  else device_name  end AS device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name\n" +
                    ")A";
            Integer BrandsCount = jdbcTemplate.queryForObject(sql,Integer.class);
@ -1285,6 +1212,8 @@ public class MonitorPlatformService  {
     */
    public JSONObject getEquipmentStatistics(String deviceType,String deviceName,String showLevel){
        try {
            WlyyIotTzDict dictObj =wlyyIotTzDictDao.findByCodeAndDel("IOT_LOST_DAY",1);
            String lost_day = dictObj.getValue();
            JSONObject result = new JSONObject();
            JSONArray arrTmp = new JSONArray();
            result.put("deviceInfo",arrTmp);
@ -1378,7 +1307,7 @@ public class MonitorPlatformService  {
                //失联设备(一周未上传当作失联)
                sql.append("and d.device_sn not in (select device_sn from ( select device_sn,MAX(record_date) record_date from device.wlyy_patient_health_index where device_sn<>'' GROUP BY device_sn)a ");
                sql.append("where TIMESTAMPDIFF(DAY,record_date,NOW()) <= 30)");
                sql.append("where TIMESTAMPDIFF(DAY,record_date,NOW()) <= "+lost_day+")");
                Integer lostContact = jdbcTemplate.queryForObject(sql.toString(),Integer.class);
                result.put("lostContact",lostContact);
            }
@ -1448,6 +1377,8 @@ public class MonitorPlatformService  {
     */
    public JSONObject iotAndLostRange(String startTime,String endTime,
                                      String deviceType,String area,String hospital,String quotaCode){
        WlyyIotTzDict dictObj =wlyyIotTzDictDao.findByCodeAndDel("IOT_LOST_DAY",1);
        String lost_day = dictObj.getValue();
        JSONObject result = new JSONObject();
        StringBuffer sql = new StringBuffer("select count(*) from wlyy.wlyy_patient_device d ,wlyy.wlyy_sign_family f WHERE f.`status`>0 and d.del=0 and f.patient = d.`user`  ");
        StringBuffer sqlCondition = new StringBuffer(" ");
@ -1501,7 +1432,7 @@ public class MonitorPlatformService  {
                sqlCondition.append("and record_date >='"+startTime+" 00:00:00' and record_date<='"+endTime+" 23:59:59'  ");
            }
            else{
                sqlCondition.append("and  TIMESTAMPDIFF(DAY,record_date,NOW()) <= 30  ");
                sqlCondition.append("and  TIMESTAMPDIFF(DAY,record_date,NOW()) <= "+lost_day+"  ");
            }
            sqlCondition.append(")");
            sql.append(sqlCondition);
@ -1564,7 +1495,7 @@ public class MonitorPlatformService  {
            }
            sql.append("GROUP BY wd.manufacturer_code,pd.device_name ");
            if ((org.apache.commons.lang3.StringUtils.isNoneBlank(deviceType)&&deviceType.contains("5"))||org.apache.commons.lang3.StringUtils.isBlank(deviceType)){
                sql.append("UNION select '健康小屋' device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name");
                sql.append("UNION select case device_name when '自助体检一体机' then '健康小屋'  else device_name  end AS device_name from xmiot.iot_equipmet_detail group BY manufacturer_code,device_name");
            }
            sql.append(")A");
            List<String> list = jdbcTemplate.queryForList(sql.toString(),String.class);
@ -1634,7 +1565,7 @@ public class MonitorPlatformService  {
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        JSONArray result = new JSONArray();
        for (Map<String,Object> map :list){
            sql="select `code`,`value` from xmiot.iot_system_dict where dict_name='DEVICE_TYPE' and del=1 and parent_code='"+map.get("id").toString()+"'";
            sql="select `code`,`value` from xmiot.iot_system_dict where dict_name='DEVICE_TYPE' and del=1 and code!=10 and code!=11  and parent_code='"+map.get("id").toString()+"'";
            StringBuffer buffer = new StringBuffer();
            List<Map<String,Object>> reList = jdbcTemplate.queryForList(sql);
            for (Map<String,Object> reMap:reList){
@ -1726,13 +1657,13 @@ public class MonitorPlatformService  {
        return deviceName;
    }
    public JSONObject savePatientDeviceLocation(){
    public JSONObject savePatientDeviceLocation(String categoryCode){
        String sql = "select DISTINCT pd.category_code ,pd.czrq create_time,pd.device_sn ,pd.device_name, p.disease_condition ,p.`code`,p.idcard ,p.address,sf.hospital_name\n" +
                "from  wlyy.wlyy_patient_device pd \n" +
                "INNER JOIN wlyy.wlyy_sign_family sf on pd.`user` = sf.patient and sf.type=2 \n" +
                "INNER JOIN wlyy.wlyy_patient p on p.idcard = sf.idcard and p.`status`=1\n" +
                "where  pd.del=0 and pd.category_code in (1,2)";
//        sql="select * from device.wlyy_patient_device_location_tmp";
                "where  pd.del=0 and pd.category_code in ("+categoryCode+")";
//                "where  pd.del=0 and pd.category_code in (1,2)";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        list.forEach(map->{
            try {
@ -1771,4 +1702,45 @@ public class MonitorPlatformService  {
        return null;
    }
    public List<Map<String, Object>> getHealthScoreByPatient(String patient,String date,String endDate){
        String sql = "SELECT chhs.device_sn deviceSn,chhs.export_key exportKey,chhs.export_time exportTime,chhs.name name,chhs.score score,chhs.total total,chhs.date date FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_health_score chhs,wlyy.hm_token t\n" +
                "WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chhs.device_sn and chhs.date > '"+endDate+"' and chhs.date < '"+date+"' ORDER BY export_time DESC ";
        List<Map<String, Object>> scoreDO = jdbcTemplate.queryForList(sql);
        return scoreDO;
    }
    public List<Map<String,Object>> getRealtimeDateByPatient(String patient,String date){
        String sql = "SELECT chrd.device_sn deviceSn,chrd.hr hr,chrd.st st,chrd.cal cal,chrd.date date FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_realtime_date chrd,wlyy.hm_token t\n" +
                "WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chrd.device_sn and chrd.date = '"+date+"' ORDER BY chrd.`date` DESC";
        List<Map<String, Object>> realtimeDateDo = jdbcTemplate.queryForList(sql);
        return realtimeDateDo;
    }
    public List<Map<String,Object>> getRundatePatient(String patient,String date){
        String sql = "SELECT chr.device_sn deviceSn,chr.date date,chr.last_sync_time lastSyncTime,chr.steps steps,chr.distance distance,chr.run_distance runDistance,chr.run_time runTime,chr.walk_time walkTime,chr.calories calories,chr.run_calories runCalories,chr.hour hour FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_rundate chr,wlyy.hm_token t\n" +
                "WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chr.device_sn and chr.date = '"+date+"' ORDER BY chr.`date` DESC";
        List<Map<String, Object>> rundataDo = jdbcTemplate.queryForList(sql);
        return rundataDo;
    }
    public List<Map<String,Object>> getPaiPatient(String patient,String date){
        String sql = "SELECT chp.device_sn deviceSn,chp.calendar_day calendarDay,chp.timestamp timestamp,chp.total_pai totalPai,chp.daily_pai dailyPai,chp.date date FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_pai chp,wlyy.hm_token t\n" +
                "WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chp.device_sn and chp.date = '"+date+"' ORDER BY chp.`timestamp` DESC";
        List<Map<String, Object>> paiDo = jdbcTemplate.queryForList(sql);
        return paiDo;
    }
    public List<Map<String,Object>> getSleepByPatient(String patient,String date){
        String sql = "SELECT chs.device_sn deviceSn,chs.date date,chs.last_sync_time lastSyncTime,chs.deep_sleep_time deepSleepTime,chs.shallow_sleep_time shallowSleepTime,chs.wake_time wakeTime,chs.sleep_score sleepScore,chs.start start,chs.stop stop,chs.mode mode FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_sleep chs,wlyy.hm_token t\n" +
                "WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chs.device_sn and chs.date = '"+date+"' ORDER BY chs.`last_sync_time` DESC";
        List<Map<String, Object>> paiDo = jdbcTemplate.queryForList(sql);
        return paiDo;
    }
    public List<Map<String , Object>> getHeartByPatient(String patient,String date,String endDate){
        String sql = "SELECT chh.device_sn deviceSn,chh.date date,chh.minute minute,chh.last_sync_time lastSyncTime,chh.timestamp timestamp,chh.heart_rate_data heartRateData,chh.measure_type measureType FROM xmiot.wlyy_copd_huami_device chd,xmiot.wlyy_copd_huami_heart chh,wlyy.hm_token t\n" +
                "WHERE t.patient = '"+patient+"' AND t.patient = chd.patient AND chd.device_sn = chh.device_sn and chh.`date` > '"+endDate+"' and chh.`date` < '"+date+"' ORDER BY chh.`date` DESC";
        List<Map<String, Object>> heartDo = jdbcTemplate.queryForList(sql);
        return heartDo;
    }
}