Explorar o código

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

wangjun %!s(int64=4) %!d(string=hai) anos
pai
achega
9855c3c42e
Modificáronse 47 ficheiros con 1967 adicións e 211 borrados
  1. 6 0
      business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java
  2. 43 1
      common/common-entity/sql记录
  3. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java
  4. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientFamilyMemberDO.java
  5. 40 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/BasePatientContactsOrgDO.java
  6. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/Device.java
  7. 12 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientDevice.java
  8. 114 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceSosLogDO.java
  9. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareItemDictDO.java
  10. 41 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/sign/CapacityDoctorDO.java
  11. 5 0
      common/common-entity/src/main/java/com/yihu/jw/entity/util/AesEncryptUtils.java
  12. 173 0
      common/common-util/src/main/java/com/yihu/jw/util/common/GpsUtil.java
  13. 4 0
      common/common-util/src/main/java/com/yihu/jw/util/common/LatitudeUtils.java
  14. 12 0
      common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java
  15. 1 0
      gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java
  16. 11 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java
  17. 21 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/contacts/BasePatientContactsOrgDao.java
  18. 5 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java
  19. 8 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/family/PatientFamilyMemberDao.java
  20. 5 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/sign/CapacityAssessmentRecordDao.java
  21. 17 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/sign/CapacityDoctorDao.java
  22. 157 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java
  23. 62 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  24. 20 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java
  25. 44 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorToDoWorkEndpoint.java
  26. 22 8
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java
  27. 130 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PadLifeCareEndpoint.java
  28. 125 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientContactsEndpoint.java
  29. 15 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  30. 33 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  31. 46 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/assistance/EmeAsEndpoint.java
  32. 175 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java
  33. 109 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  34. 52 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  35. 36 21
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java
  36. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java
  37. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  38. 84 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java
  39. 72 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  40. 20 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java
  41. 40 13
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java
  42. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  43. 51 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/CountDistance.java
  44. 11 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceSosLogDao.java
  45. 0 83
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java
  46. 94 69
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  47. 6 0
      svr/svr-cloud-device/src/main/resources/application.yml

+ 6 - 0
business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java

@ -61,4 +61,10 @@ public interface BaseOrgDao extends PagingAndSortingRepository<BaseOrgDO, String
    
    @Query(value="select b.* from base_org b where b.org_level= ?1 and b.del=?2 ORDER BY sort DESC",nativeQuery = true)
    List<BaseOrgDO> findByLevelAndDel(Integer level,String del);
    @Query(value="select Distinct org from BaseOrgDO org,BaseDoctorHospitalDO h where org.code = h.orgCode and h.del=1 and org.del=1 and h.doctorCode=?1 and org.type=?2 " )
    List<BaseOrgDO> findByDoctorAndType(String doctor,String type);
    @Query(value="select org from BaseOrgDO org where org.del=1  and org.type in ?1 " )
    List<BaseOrgDO> findByTypeIn(String[] type);
}

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

@ -445,4 +445,46 @@ alter table base_doctor add doctor_level tinyint(4) DEFAULT NULL COMMENT '类型
-- 2021-04-29 wj
alter table base_patient ADD disease varchar(50) ;
alter table patient_medicare_card ADD medicare_number varchar(50) ;
alter table patient_medicare_card ADD medicare_number varchar(50) ;
-- 2021-05-07 ysj
alter table base_patient_family_member add is_contacts tinyint(1) DEFAULT NULL COMMENT '是否是一键联系人';
CREATE TABLE `base_capacity_doctor` (
  `id` varchar(50) NOT NULL,
  `capacity_id` varchar(50) DEFAULT NULL COMMENT '能力评估记录id',
  `doctor_id` varchar(50) DEFAULT NULL COMMENT '医生id',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='能力评估医生关联表';
CREATE TABLE `base_patient_contacts_org` (
  `id` varchar(50) NOT NULL,
  `patient` varchar(50) DEFAULT NULL,
  `org_code` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='居民联系服务站';
-- 2021-05-07 skj
ALTER TABLE base.wlyy_patient_device add COLUMN  `sos_address` varchar(50) DEFAULT NULL COMMENT '设备类型为报警器时,需要填写投放地址 category_code = 7';
-- 2021-05-08 skj
ALTER TABLE base.base_life_care_item_dict add COLUMN  `life_care_img` varchar(255) DEFAULT NULL COMMENT '服务项目图片';
-- 2021-05-08 lb
CREATE TABLE `base_device_sos_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `patient` varchar(50) DEFAULT NULL COMMENT '居民code',
  `patient_name` varchar(50) DEFAULT NULL COMMENT '姓名',
  `idcard` varchar(32) DEFAULT NULL COMMENT '身份证',
  `category_code` varchar(50) DEFAULT NULL COMMENT '设备类型标识1血糖仪,2.血压计,3药盒,4智能手表',
  `device_sn` varchar(50) NOT NULL COMMENT '设备SN码',
  `sos_address` varchar(100) DEFAULT NULL COMMENT '报警地址',
  `sos_lat` varchar(100) DEFAULT NULL COMMENT '报警地址纬度',
  `sos_lon` varchar(100) DEFAULT NULL COMMENT '报警地址经度',
  `sos_send_status` varchar(255) DEFAULT NULL COMMENT '紧急救助发起状态 200成功, -1 失败',
  `sos_send_message` varchar(500) DEFAULT NULL COMMENT '紧急救助发起返回消息',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备紧急救助日志表';

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java

@ -84,7 +84,7 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
	private String spell;
    /**
	 * 机构类型: 1. 等级医院2. 社区医院3.  养老机构
	 * 机构类型: 1. 等级医院2. 社区医院3.  养老机构 4.  托育机构
	 */
	private String type;

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientFamilyMemberDO.java

@ -17,6 +17,7 @@ public class BasePatientFamilyMemberDO extends UuidIdentityEntityWithOperator {
    private String familyMember;//家庭成员code',
    private Integer familyRelation;//家庭关系关系 1配偶 2父亲 3母亲 4公公 5婆婆 6岳父 7岳母 8子女',
    private Integer isAuthorize;//是否授权0:未授权,1:已授权,默认为1',
    private Integer isContacts;//是否是一键联系人 1是
    private Integer del;//删除标志(1正常,0删除)
    @Column(name = "patient")
@ -63,4 +64,13 @@ public class BasePatientFamilyMemberDO extends UuidIdentityEntityWithOperator {
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "is_contacts")
    public Integer getIsContacts() {
        return isContacts;
    }
    public void setIsContacts(Integer isContacts) {
        this.isContacts = isContacts;
    }
}

+ 40 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/BasePatientContactsOrgDO.java

@ -0,0 +1,40 @@
package com.yihu.jw.entity.care.contacts;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/7
 * @Description:
 */
@Entity
@Table(name="base_patient_contacts_org")
public class BasePatientContactsOrgDO extends UuidIdentityEntity {
    private String patient;
    private String orgCode;
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/Device.java

@ -26,6 +26,7 @@ public class Device extends IdEntity {
	private String name;
	private Date czrq;
	private String del;
	private String serviceTopic;//设备所属专题 防走失 preventLost
	@Column(name="category_code")
	public String getCategoryCode() {
@ -108,4 +109,12 @@ public class Device extends IdEntity {
	public void setDel(String del) {
		this.del = del;
	}
	public String getServiceTopic() {
		return serviceTopic;
	}
	public void setServiceTopic(String serviceTopic) {
		this.serviceTopic = serviceTopic;
	}
}

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

@ -65,6 +65,9 @@ public class DevicePatientDevice extends IdEntity {
    private String applyReason;
    //医生拒绝原因
    private String refuseReason;
    //设备类型为报警器时,需要填写投放地址 category_code = 7
    private String sosAddress;
  //========================非表字段======================
    //患者居住地址
    private String address;
@ -251,6 +254,15 @@ public class DevicePatientDevice extends IdEntity {
        this.checkDoctorName = checkDoctorName;
    }
    @Column(name = "sos_address")
    public String getSosAddress() {
        return sosAddress;
    }
    public void setSosAddress(String sosAddress) {
        this.sosAddress = sosAddress;
    }
    @Transient
    public String getAddress() {
        return address;

+ 114 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceSosLogDO.java

@ -0,0 +1,114 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Bing on 2021/5/8.
 */
@Entity
@Table(name="base_device_sos_log")
public class DeviceSosLogDO extends IdEntity {
    private String patient; //居民code
    private String patientName; //姓名
    private String idcard;  //身份证
    private String categoryCode;    //设备类型标识1血糖仪,2.血压计,3药盒,4智能手表
    private String deviceSn;    //设备SN码
    private String sosAddress;  //报警地址
    private String sosLat;  //报警地址纬度
    private String sosLon;  //报警地址经度
    private String sosSendStatus;//紧急救助发起状态 200成功 -1失败
    private String sosSendMessage; //紧急救助返回消息
    private Date createTime;//
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    public String getIdcard() {
        return idcard;
    }
    public void setIdcard(String idcard) {
        this.idcard = idcard;
    }
    public String getCategoryCode() {
        return categoryCode;
    }
    public void setCategoryCode(String categoryCode) {
        this.categoryCode = categoryCode;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getSosAddress() {
        return sosAddress;
    }
    public void setSosAddress(String sosAddress) {
        this.sosAddress = sosAddress;
    }
    public String getSosLat() {
        return sosLat;
    }
    public void setSosLat(String sosLat) {
        this.sosLat = sosLat;
    }
    public String getSosLon() {
        return sosLon;
    }
    public void setSosLon(String sosLon) {
        this.sosLon = sosLon;
    }
    public String getSosSendStatus() {
        return sosSendStatus;
    }
    public void setSosSendStatus(String sosSendStatus) {
        this.sosSendStatus = sosSendStatus;
    }
    public String getSosSendMessage() {
        return sosSendMessage;
    }
    public void setSosSendMessage(String sosSendMessage) {
        this.sosSendMessage = sosSendMessage;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

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

@ -2,6 +2,7 @@ package com.yihu.jw.entity.care.lifeCare;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.math.BigDecimal;
@ -19,6 +20,7 @@ public class LifeCareItemDictDO extends UuidIdentityEntity{
    private BigDecimal price;//价格
    private Integer sort;//排序字段
    private Integer del;//删除标志 1正常,0删除
    private String lifeCareImg;//服务项目图片
    public String getCode() {
        return code;
@ -67,4 +69,13 @@ public class LifeCareItemDictDO extends UuidIdentityEntity{
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "life_care_img")
    public String getLifeCareImg() {
        return lifeCareImg;
    }
    public void setLifeCareImg(String lifeCareImg) {
        this.lifeCareImg = lifeCareImg;
    }
}

+ 41 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/sign/CapacityDoctorDO.java

@ -0,0 +1,41 @@
package com.yihu.jw.entity.care.sign;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/8
 * @Description: 能力评估医生关联表
 */
@Entity
@Table(name = "base_capacity_doctor")
public class CapacityDoctorDO extends UuidIdentityEntity {
    private String capacityId;
    private String doctorId;
    @Column(name = "capacity_id")
    public String getCapacityId() {
        return capacityId;
    }
    public void setCapacityId(String capacityId) {
        this.capacityId = capacityId;
    }
    @Column(name = "doctor_id")
    public String getDoctorId() {
        return doctorId;
    }
    public void setDoctorId(String doctorId) {
        this.doctorId = doctorId;
    }
}

+ 5 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/util/AesEncryptUtils.java

@ -145,6 +145,11 @@ public class AesEncryptUtils {
        }
        return decrypt(encryptStr, AGKEY);
    }
    public static String agEncrypt(String content) throws Exception {
        return encrypt(content, AGKEY);
    }
    private static final String AGKEY = "46A61629A19AE04C";
}

+ 173 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/GpsUtil.java

@ -0,0 +1,173 @@
package com.yihu.jw.util.common;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
/**
 * * 坐标转换工具类
 *  * WGS84: Google Earth采用,Google Map中国范围外使用
 *  * GCJ02: 火星坐标系,中国国家测绘局制定的坐标系统,由WGS84机密后的坐标。Google Map中国和搜搜地图使用,高德
 *  * BD09:百度坐标,GCJ02机密后的坐标系
 *
 * Created by Bing on 2021/5/8.
 */
@Component
public class GpsUtil {
    public static final String BAIDU_LBS_TYPE = "bd09ll";
    public static double pi = 3.1415926535897932384626;
    public static double a = 6378245.0;
    public static double ee = 0.00669342162296594323;
    /**
     * 84 to 火星坐标系 (GCJ-02) World Geodetic System ==> Mars Geodetic System
     * @param lat
     * @param lon
     */
    public  JSONObject gps84_To_Gcj02(double lat, double lon) {
        if (outOfChina(lat, lon)) {
            return null;
        }
        double dLat = transformLat(lon - 105.0, lat - 35.0);
        double dLon = transformLon(lon - 105.0, lat - 35.0);
        double radLat = lat / 180.0 * pi;
        double magic = Math.sin(radLat);
        magic = 1 - ee * magic * magic;
        double sqrtMagic = Math.sqrt(magic);
        dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
        dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
        double mgLat = lat + dLat;
        double mgLon = lon + dLon;
        return getPosition(mgLat, mgLon);
    }
    /**
     * * 火星坐标系 (GCJ-02) to 84 * * @param lon * @param lat * @return
     */
    public  JSONObject gcj_To_Gps84(double lat, double lon) {
        JSONObject gps = transform(lat, lon);
        double lontitude = lon * 2 - gps.getDouble("lon");
        double latitude = lat * 2 - gps.getDouble("lat");
        return getPosition(latitude, lontitude);
    }
    /**
     * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标
     *
     * @param gg_lat
     * @param gg_lon
     */
    public  JSONObject gcj02_To_Bd09(double gg_lat, double gg_lon) {
        double x = gg_lon, y = gg_lat;
        double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);
        double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);
        double bd_lon = z * Math.cos(theta) + 0.0065;
        double bd_lat = z * Math.sin(theta) + 0.006;
        return getPosition(bd_lat, bd_lon);
    }
    public  String gcj02_To_Bd09_Str(double gg_lat, double gg_lon) {
        double x = gg_lon, y = gg_lat;
        double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);
        double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);
        double bd_lon = z * Math.cos(theta) + 0.0065;
        double bd_lat = z * Math.sin(theta) + 0.006;
        return bd_lon+","+bd_lat;
    }
    /**
     * * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 * * 将 BD-09 坐标转换成GCJ-02 坐标 * * @param
     * bd_lat * @param bd_lon * @return
     */
    public  JSONObject bd09_To_Gcj02(double bd_lat, double bd_lon) {
        double x = bd_lon - 0.0065, y = bd_lat - 0.006;
        double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi);
        double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi);
        double gg_lon = z * Math.cos(theta);
        double gg_lat = z * Math.sin(theta);
        return getPosition(gg_lat, gg_lon);
    }
    public  String  bd09_To_Gcj02_str(double bd_lat, double bd_lon) {
        double x = bd_lon - 0.0065, y = bd_lat - 0.006;
        double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi);
        double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi);
        double gg_lon = z * Math.cos(theta);
        double gg_lat = z * Math.sin(theta);
        return bd_lon+","+bd_lat;
    }
    /**
     * (BD-09)-->84
     * @param bd_lat
     * @param bd_lon
     * @return
     */
    public  JSONObject bd09_To_Gps84(double bd_lat, double bd_lon) {
        JSONObject gcj02 = bd09_To_Gcj02(bd_lat, bd_lon);
        JSONObject map84 = gcj_To_Gps84(gcj02.getDouble("lat"),
                gcj02.getDouble("lon"));
        return map84;
    }
    /**
     * is or not outOfChina
     * @param lat
     * @param lon
     * @return
     */
    public  boolean outOfChina(double lat, double lon) {
        if (lon < 72.004 || lon > 137.8347)
            return true;
        if (lat < 0.8293 || lat > 55.8271)
            return true;
        return false;
    }
    public  JSONObject transform(double lat, double lon) {
        if (outOfChina(lat, lon)) {
            return getPosition(lat, lon);
        }
        double dLat = transformLat(lon - 105.0, lat - 35.0);
        double dLon = transformLon(lon - 105.0, lat - 35.0);
        double radLat = lat / 180.0 * pi;
        double magic = Math.sin(radLat);
        magic = 1 - ee * magic * magic;
        double sqrtMagic = Math.sqrt(magic);
        dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
        dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
        double mgLat = lat + dLat;
        double mgLon = lon + dLon;
        return getPosition(mgLat, mgLon);
    }
    public  double transformLat(double x, double y) {
        double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y
                + 0.2 * Math.sqrt(Math.abs(x));
        ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
        ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
        ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
        return ret;
    }
    public  double transformLon(double x, double y) {
        double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1
                * Math.sqrt(Math.abs(x));
        ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
        ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
        ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0
                * pi)) * 2.0 / 3.0;
        return ret;
    }
    public JSONObject getPosition(double lat, double lon){
        JSONObject result = new JSONObject();
        result.put("lat",lat);
        result.put("lon",lon);
        return result;
    }
}

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

@ -87,6 +87,10 @@ public class LatitudeUtils {
     * @return
     */
    public static String getDistance(String lat1Str, String lng1Str, String lat2Str, String lng2Str) {
        if(StringUtils.isEmpty(lat1Str)||StringUtils.isEmpty(lng1Str)
                ||StringUtils.isEmpty(lat2Str)||StringUtils.isEmpty(lng2Str)){
            return "";
        }
        double lat1 = Double.parseDouble(lat1Str);
        double lng1 = Double.parseDouble(lng1Str);
        double lat2 = Double.parseDouble(lat2Str);

+ 12 - 0
common/common-util/src/main/java/com/yihu/jw/util/http/HttpClientUtil.java

@ -488,6 +488,18 @@ public class HttpClientUtil {
        return null;
    }
    public String postBodyRawForm(String url, String params) throws IOException {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        List<NameValuePair> pairs = new ArrayList<>(0);
        pairs.add(new BasicNameValuePair("object",params));
        UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(pairs);
        HttpPost httpPost = new HttpPost(url);
        httpPost.setEntity(formEntity);
        CloseableHttpResponse response = httpclient.execute(httpPost);
        HttpEntity entity = response.getEntity();
        String ret = EntityUtils.toString(entity);
        return ret;
    }
    /**
     * 爱牵挂请求

+ 1 - 0
gateway/ag-basic/src/main/java/com/yihu/jw/gateway/filter/BasicZuulFilter.java

@ -131,6 +131,7 @@ public class BasicZuulFilter extends ZuulFilter {
                || url.contains("/sms_gateway/send")//发送短信
                || url.contains("/accountAppeal/create")
                || url.contains("/open/")//开放接口
                || url.contains("/cloudCare/noLogin/")//医疗云开放接口
                || url.contains("/image/")//获取默认图片
                ||url.contains("/weixin")||
                url.contains("/excelControl")) {

+ 11 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java

@ -27,6 +27,17 @@ public class AqgConfig {
     */
    public static final String sos_numbers = baseUrl +"/api/device/{0}/sos_numbers/{1}";
    /**
     * 获取设备最新位置数据
     */
    public static final String device_last_locationdata = baseUrl +"/api/device/{0}/data/locationdata/";
    /**
     * 设置智能手环安全区域
     */
    public static final String fence_area = baseUrl +"/api/device/{0}/fences/{1}";
    public static final String username = "13559485270";
    public static final String password = "zjxl@2021";
    public static final String redisKey = "aqgCooker";

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

@ -0,0 +1,21 @@
package com.yihu.jw.care.dao.contacts;
import com.yihu.jw.entity.care.contacts.BasePatientContactsOrgDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/7
 * @Description:
 */
public interface BasePatientContactsOrgDao extends PagingAndSortingRepository<BasePatientContactsOrgDO,String>,
        JpaSpecificationExecutor<BasePatientContactsOrgDO> {
    BasePatientContactsOrgDO findByPatient(String patient);
}

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

@ -43,6 +43,10 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatie
    @Query("update DevicePatientDevice t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5,t.hospital=?6,t.hospitalName=?7,t.checkDoctorName=?8 where t.user = ?1 and t.deviceSn = ?2 ")
    int updatePatientDevice(String user, String deviceSN, String newDeviceSN, String userType, String sim, String hospital, String hospitalName, String checkDoctorName);
    //管理员解绑居民设备
    @Modifying
    @Query("update DevicePatientDevice t set t.del = 1  where t.deviceSn = ?1 ")
    int updatePatientDevice(String deviceSN);
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();
@ -50,5 +54,5 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatie
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    List<DevicePatientDevice> findAllByUser(String user);
    List<DevicePatientDevice> findByUserAndCategoryCode(String user,String categoryCode);
}

+ 8 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/family/PatientFamilyMemberDao.java

@ -50,4 +50,12 @@ public interface PatientFamilyMemberDao extends PagingAndSortingRepository<BaseP
    BasePatientFamilyMemberDO findByPatientAndFamilyMember(String patient,String member);
    List<BasePatientFamilyMemberDO> findByFamilyMemberAndIsAuthorize(String familyMember,Integer isAuthorize);
    @Modifying
    @Query("update BasePatientFamilyMemberDO m set m.isContacts = 0 where m.patient=?1 ")
    int updateContactsByPatient(String patient);
    @Modifying
    @Query("update BasePatientFamilyMemberDO m set m.isContacts = 1 where m.id=?1 ")
    int updateContactsById(String id);
}

+ 5 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/sign/CapacityAssessmentRecordDao.java

@ -2,14 +2,18 @@ package com.yihu.jw.care.dao.sign;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
/**
 * Created by yeshijie on 2021/2/25.
 */
public interface CapacityAssessmentRecordDao extends PagingAndSortingRepository<CapacityAssessmentRecordDO, String>,
        JpaSpecificationExecutor<CapacityAssessmentRecordDO> {
    CapacityAssessmentRecordDO findByPatient(String patient);
    @Query("select c from CapacityAssessmentRecordDO c where c.patient=?1 and c.assessmentTime>=?2 ")
    CapacityAssessmentRecordDO findByPatient(String patient,Date assessmentTime);
}

+ 17 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/sign/CapacityDoctorDao.java

@ -0,0 +1,17 @@
package com.yihu.jw.care.dao.sign;
import com.yihu.jw.entity.care.sign.CapacityDoctorDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/8
 * @Description:
 */
public interface CapacityDoctorDao extends PagingAndSortingRepository<CapacityDoctorDO, String>, JpaSpecificationExecutor<CapacityDoctorDO> {
    CapacityDoctorDO findByCapacityIdAndDoctorId(String capacityId, String doctorId);
}

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

@ -0,0 +1,157 @@
package com.yihu.jw.care.endpoint.device;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
import java.util.Map;
/***
 * @ClassName: PadDeviceController
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/5/7 13:39
 */
@RestController
@RequestMapping(value = "pad/device")
@Api(value = "患者设备管理(平板端)", description = "患者设备管理")
public class PadDeviceController extends BaseController {
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private DeviceDetailService deviceDetailService;
    @Autowired
    private BasePatientDao patientDao;
    private ObjectMapper objectMapper = new ObjectMapper();
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    /**
     * 设备列表获取
     *
     * @return 操作结果
     */
    @ApiOperation("管理员获取设备列表")
    @RequestMapping(value = "PatientDeviceList", method = RequestMethod.GET)
    public String getDeviceByPatient(@ApiParam(name = "patientName", value = "居民姓名", defaultValue = "张")
                                     @RequestParam(value = "patientName", required = false) String patientName,
                                     @ApiParam(name = "idcard", value = "身份证号", defaultValue = "")
                                     @RequestParam(value = "idcard", required = false) String idcard,
                                     @ApiParam(name = "page", value = "分页起始id", defaultValue = "1")
                                     @RequestParam(value = "page", required = true) int page,
                                     @ApiParam(name = "pagesize", value = "每页条数", defaultValue = "10")
                                     @RequestParam(value = "pagesize", required = true) int pagesize) {
        try {
            List<Map<String , Object>> list = patientDeviceService.findDeviceFromAdmin(patientName, idcard, page, pagesize);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @ApiOperation("平板端,添加设备时获取设备类型(大类)")
    @RequestMapping(value = "getDeviceTypeBig", method = RequestMethod.GET)
    public String getDeviceTypeBig(@ApiParam(name = "pyCode", value = "获取设备类型(默认为null,获取大类)", defaultValue = "")
                                       @RequestParam(value = "pyCode", required = false) String pyCode) {
        try {
            List<Map<String , Object>> list = patientDeviceService.getDeviceType(1,pyCode);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @ApiOperation("平板端,添加设备时获取设备类型(小类)")
    @RequestMapping(value = "getDeviceTypeSmall", method = RequestMethod.GET)
    public String getDeviceTypeSmall(@ApiParam(name = "pyCode", value = "获取设备类型(默认为 watch,获取小类(智能手表多类型))", defaultValue = "watch")
                                         @RequestParam(value = "pyCode", required = false) String pyCode) {
        try {
            List<Map<String , Object>> list = patientDeviceService.getDeviceType(0,pyCode);
            return write(200, "查询成功", "data", list);
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @ApiOperation("设备保存接口(平板端绑定设备  设备为报警器时需要填写投放地址)")
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{     \"deviceId\":\"3\",     \"deviceName\":\"血压计-优瑞恩\",     \"deviceSn\":\"7052169111\",     \"categoryCode\":\"7\",     \"userType\":\"-1\", \"sosAddress\":\"福建省厦门市思明区望海路55号之1\" }")
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = false) String patientCode
                             ) {
        try {
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            // 设置患者标识
            device.setUser(patientCode);
            //患者和设备是否首绑
            Map<String,Object> checkMap = patientDeviceService.checkBindingFirstAndType(device);
            boolean flag = (Boolean)checkMap.get("flag");
            int code = (Integer)checkMap.get("code");
            if (code==-30000){
                return write(-1,"设备不存在或者数据存在错误!");
            }
            BaseDoctorDO doctor = baseDoctorDao.findById(getUID());
            device.setAgent(getUID());
            device.setAgentName(doctor.getName());
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
                Boolean flagDevice = patientDeviceService.saveDevice(device);
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                }
            }
            //修改设备表中{"1":"0", "2":"0"}的绑定次数 和其他绑定信息
            deviceDetailService.updateAfterBinding(device,new Date(),flag);
            return success("设备保存成功!");
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    @ApiOperation("设备解绑接口(平板端解绑设备 )")
    @RequestMapping(value = "delDeviceByDeviceSn", method = RequestMethod.POST)
    public String delDeviceByDeviceSn(
                             @ApiParam(name = "deviceSn", value = "设备sn码") @RequestParam(value = "deviceSn", required = false) String deviceSn
    ) {
        try {
                int flagDevice = patientDeviceService.delDeviceByDeviceSn(deviceSn);
                if (flagDevice == 1){
                    return success("设备解绑成功!");
                }else {
                    return write(-1,"解绑失败,请确认设备sn码");
                }
        } catch (Exception ex) {
            error(ex);
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
}

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

@ -9,6 +9,7 @@ import com.yihu.jw.care.service.device.PatientHealthIndexService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.ListEnvelop;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -94,7 +95,11 @@ public class PatientDeviceController extends BaseController {
            }
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
                patientDeviceService.saveDevice(device);
//                patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device);
                if (flagDevice == false){
                    return write(-1,"请填写投放地址");
                }
            }
            //修改设备表中{"1":"0", "2":"0"}的绑定次数 和其他绑定信息
            deviceDetailService.updateAfterBinding(device,new Date(),flag);
@ -163,7 +168,20 @@ public class PatientDeviceController extends BaseController {
            return invalidUserException(ex, -1, ex.getMessage());
        }
    }
    
    @ApiOperation("获取患者设备信息")
    @RequestMapping(value = "patientDeviceListByTopic", method = RequestMethod.GET)
    public ListEnvelop patientDeviceListByTopic(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                                @RequestParam(value = "patient", required = true) String patient,
                                                @ApiParam(name = "topic", value = "专题CODE;preventLost防走失", defaultValue = "topic")
                                                @RequestParam(value = "topic", required = true) String topic) {
        try {
            return ListEnvelop.getSuccess("查询成功",  patientDeviceService.patientDeviceListByTopic(patient,topic));
        } catch (Exception ex) {
            error(ex);
            return ListEnvelop.getError("查询失败");
        }
    }
    /**
     * 设备删除
@ -240,4 +258,46 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @ApiOperation("获取设备最新位置数据")
    @RequestMapping(value = "getDeviceLastLocation",method = RequestMethod.GET)
    public String getDeviceLastLocation(@ApiParam(name = "deviceSn",value = "设备sn码")
                                        @RequestParam(value = "deviceSn",required = true)String deviceSn,
                                        @ApiParam(name = "type",value = "type 0:Gps定位; 1:基站定位 (非必填)")
                                        @RequestParam(value = "type",required = false)String type){
        try {
            return write(200,"获取成功","data",patientDeviceService.getDeviceLastLocation(deviceSn,type));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
    @ApiOperation("更新智能手环设备安全区域")
    @RequestMapping(value = "updateDeviceFenceArea",method = RequestMethod.GET)
    public String updateDeviceFenceArea(@ApiParam(name = "deviceSn",value = "设备sn码")
                                        @RequestParam(value = "deviceSn",required = true)String deviceSn,
                                        @ApiParam(name = "fenceNO",value = "安全区编号")
                                        @RequestParam(value = "fenceNO",required = false)Integer fenceNO,
                                        @ApiParam(name = "enable",value = "0,1 是否启用")
                                        @RequestParam(value = "enable",required = false)String enable,
                                        @ApiParam(name = "name",value = "安全区名称")
                                        @RequestParam(value = "name",required = false)String name,
                                        @ApiParam(name = "freq",value = "0,触发一天;1,每日触发 ")
                                        @RequestParam(value = "freq",required = false)String freq,
                                        @ApiParam(name = "time_begin",value = "目标时间与当日0点之间相差的秒数 ")
                                        @RequestParam(value = "time_begin",required = false)String time_begin,
                                        @ApiParam(name = "time_end",value = "同上 ")
                                        @RequestParam(value = "time_end",required = false)String time_end,
                                        @ApiParam(name = "safe_area",value = "lon1,lat1;lon2,lat2; 5个坐标 形成一个封闭区域  A;B;C;D;A ")
                                        @RequestParam(value = "safe_area",required = false)String safe_area,
                                        @ApiParam(name = "clear",value = "删除标志,删除传1")
                                        @RequestParam(value = "clear",required = false)String clear
                                        ){
        try {
            return write(200,"获取成功","data",patientDeviceService.updateDeviceFenceArea(deviceSn, fenceNO, enable, name, freq, time_begin, time_end, safe_area, clear));
        }catch (Exception e){
            e.printStackTrace();
            return write(-1,"获取失败!");
        }
    }
}

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

@ -12,6 +12,7 @@ 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.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -93,4 +94,23 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
        }
        return success("保存成功");
    }
    @GetMapping(value = "getOrgDoctor")
    @ApiOperation(value = "医生通讯录机构详情查询")
    public ObjEnvelop getOrgDoctor(
            @ApiParam(name = "doctorId", value = "doctorId", required = false)
            @RequestParam(value = "doctorId",required = false) String doctorId,
            @ApiParam(name = "orgType", value = "1,2医疗机构 3养老机构,4托育机构")
            @RequestParam(value = "orgType") String orgType
    ){
        try {
            if (orgType.equals("3")&&StringUtils.isBlank(doctorId)){
                return ObjEnvelop.getError("参数错误");
            }
            return ObjEnvelop.getSuccess("查询成功", doctorService.getOrgDoctor(doctorId,orgType));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
}

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

@ -0,0 +1,44 @@
package com.yihu.jw.care.endpoint.doctor;
import com.yihu.jw.care.service.message.DoctorMessageService;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/***
 * @ClassName: DoctorToDoWorkEndpoint
 * @Description: 助老员 待办工作
 * @Auther: shi kejing
 * @Date: 2021/5/8 17:42
 */
@RestController
@RequestMapping(value = "doctor/todowork")
@Api(description = "助老员 - 待办工作")
public class DoctorToDoWorkEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private DoctorMessageService doctorMessageService;
    @GetMapping(value = "todowork")
    @ApiOperation("待办工作")
    public ObjEnvelop messages(@ApiParam(name = "serviceSype", value = "工作类型: 生活照料,安防监护=preventLost,紧急救助=emergencyAssistance,生活照料=fifeCare")
                               @RequestParam(value = "serviceSype", required = false) String serviceSype,
                               @ApiParam(name = "id", value = "查看详情需要传id")
                               @RequestParam(value = "id", required = false) String id,
                               @ApiParam(name = "doctor", value = "doctor")
                               @RequestParam(value = "doctor", required = true) String doctor){
        try {
            return ObjEnvelop.getSuccess("查询成功",doctorMessageService.getPreventLost(doctor,id,serviceSype));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
}

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

@ -163,6 +163,7 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
            }
            return success( "授权成功");
        }catch (Exception e){
            e.printStackTrace();
            return failed("授权失败",-1);
        }
    }
@ -171,21 +172,21 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
    /**
     * 家庭成员查询
     * @param patient
     * @param isAgree (任意值已同意(只查询家人关系表),null不同意)
     * @param isContacts (1是一键联系人)
     * @return
     */
    @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) {
                                              @RequestParam(required = false) Integer isContacts) {
        try {
            JSONObject data = new JSONObject();
            JSONArray result = new JSONArray();
            if (StringUtils.isNotEmpty(patient)) {
                result = familyMemberService.getPatientMembers(patient, "", isContain,isAgree);
                result = familyMemberService.getPatientMembers(patient, "", isContain,isContacts);
            } else  {
                result = familyMemberService.getPatientFamilyMembers(getUID(), "",null);
                result = familyMemberService.getPatientFamilyMembers(getUID(), "",isContacts);
            }
            data.put("normalmembers",result);//家人关系
@ -256,6 +257,7 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
            JSONObject result = familyMemberService.isRegister(idcard, getUID());
            return ObjEnvelop.getSuccess( "查询成功",  result);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "查询失败");
        }
    }
@ -272,6 +274,7 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
            JSONObject result = familyMemberService.checkFamilyMember(memberCode);
            return ObjEnvelop.getSuccess( "验证成功",  result);
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError( "验证失败");
        }
    }
@ -308,18 +311,28 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
                return success( "添加成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "添加失败",-1);
        }
    }
    @RequestMapping(value = "/addMemberByCaptcha", method = RequestMethod.POST)
    @ApiOperation(value = "通过手机验证码新增家庭成员")
    public Envelop addMemberByCaptcha(@RequestParam("member") String member,
    public Envelop addMemberByCaptcha(@RequestParam("idcard") String idcard,
                                      @RequestParam("name") String name,
                                      @RequestParam("mobile") String mobile,
                                      @RequestParam("archiveType") Integer archiveType,
                                     @RequestParam("captcha") String captcha,
                                     @RequestParam("relation") int relation){
        try {
            if (StringUtils.isEmpty(member)) {
                return failed( "添加成员不能为空",-1);
            if (StringUtils.isEmpty(idcard)) {
                return failed( "添加成员身份证不能为空",-1);
            }
            if (StringUtils.isEmpty(name)) {
                return failed( "添加成员姓名不能为空",-1);
            }
            if (StringUtils.isEmpty(mobile)) {
                return failed( "添加成员手机号不能为空",-1);
            }
            if (StringUtils.isEmpty(captcha)) {
                return failed( "验证码不能为空",-1);
@ -328,7 +341,7 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
                return failed( "家庭关系无效",-1);
            }
            int result = familyMemberService.addMemberByCaptcha(getUID(),member,captcha,relation);
            int result = familyMemberService.addMemberByCaptcha(getUID(),idcard,name,mobile,archiveType,captcha,relation);
            if(result==0){
                return failed( "不能添加自己",-1);
@ -348,6 +361,7 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
                return success( "添加成功");
            }
        } catch (Exception e) {
            e.printStackTrace();
            return failed( "添加失败",-1);
        }
    }

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

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

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

@ -0,0 +1,125 @@
package com.yihu.jw.care.endpoint.patient;
import com.alibaba.fastjson.JSONArray;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/7
 * @Description:
 */
@RestController
@RequestMapping("patientContacts" )
@Api(tags = "居民-联系人", description = "居民-联系人")
public class PatientContactsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ContactsService contactsService;
    /**
     * 联系人查询
     * @param patient
     * @param isContacts (1是一键联系人)
     * @return
     */
    @RequestMapping(value = "getPatientContacts", method = RequestMethod.GET)
    @ApiOperation(value = "联系人查询")
    public Envelop getPatientContacts(@RequestParam(required = true) String patient,
                                      @RequestParam(required = true) Integer isContacts) {
        try {
            JSONArray result = contactsService.getPatientContacts(patient,isContacts);
            return ObjEnvelop.getSuccess( "查询成功", result);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "查询失败");
        }
    }
    /**
     * 设置一键联系人
     * @param patient
     * @return
     */
    @RequestMapping(value = "setPatientContacts", method = RequestMethod.POST)
    @ApiOperation(value = "设置一键联系人")
    public Envelop setPatientContacts(@RequestParam(required = true) String patient,
                                      @RequestParam(required = true) String fid) {
        try {
            contactsService.setContacts(fid,patient);
            return ObjEnvelop.getSuccess("设置成功");
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("设置失败");
        }
    }
    /**
     * 查找居民联系服务站
     * @param patient
     * @return
     */
    @RequestMapping(value = "getContactsOrg", method = RequestMethod.GET)
    @ApiOperation(value = "联系人查询")
    public Envelop getContactsOrg(@RequestParam(required = true) String patient) {
        try {
            BaseOrgDO result = contactsService.getContactsOrg(patient);
            return ObjEnvelop.getSuccess( "查询成功", result);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "查询失败");
        }
    }
    /**
     * 设置居民联系服务站
     * @param patient
     * @return
     */
    @RequestMapping(value = "setContactsOrg", method = RequestMethod.POST)
    @ApiOperation(value = "设置居民联系服务站")
    public Envelop setContactsOrg(@RequestParam(required = true) String patient,
                                      @RequestParam(required = true) String orgCode) {
        try {
            contactsService.setContactsOrg(patient,orgCode);
            return ObjEnvelop.getSuccess("设置成功");
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("设置失败");
        }
    }
    /**
     * 查找居民联系服务站
     * @param patient
     * @return
     */
    @RequestMapping(value = "findSignOrg", method = RequestMethod.GET)
    @ApiOperation(value = "联系人查询")
    public Envelop findSignOrg(@RequestParam(required = true) String patient,
                               @RequestParam(required = true) String lng,
                               @RequestParam(required = true) String lat) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", contactsService.findSignOrg(patient,lng,lat));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "查询失败");
        }
    }
}

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

@ -3,6 +3,7 @@ package com.yihu.jw.care.endpoint.security;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringConclusionDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -269,4 +270,18 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
            return ListEnvelop.getError("查询失败");
        }
    }
    @ApiOperation("获取居民监护信息")
    @RequestMapping(value = "patientMonitoringInfo ", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public ObjEnvelop patientMonitoringInfo(@ApiParam(name = "patient", value = "patient")
                                @RequestParam(value = "patient") String patient) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", securityMonitoringOrderService.patientMonitoringInfo(patient));
        } catch (Exception ex) {
            ex.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
}

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

@ -7,9 +7,7 @@ import com.yihu.jw.care.dao.sign.CapacityAssessmentRecordDao;
import com.yihu.jw.care.service.sign.ArchiveService;
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
@ -21,12 +19,10 @@ 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.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -290,6 +286,23 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @PostMapping(value = "synCapacityRecord" )
    @ApiOperation(value = "同步能力评估报告")
    @ObserverRequired
    public Envelop synCapacityRecord(
            @ApiParam(name = "patient", value = "患者id", required = true)
            @RequestParam String patient,
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam String doctorId) {
        try{
            capacityAssessmentRecordService.synCapacityRecord(patient,doctorId);
            return success("同步成功");
        }catch (Exception e){
            e.printStackTrace();
            return failed("同步失败",-1);
        }
    }
    @PostMapping(value = "capacityAssessmentByPatient" )
    @ApiOperation(value = "通过患者id生成当年能力评估报告")
    @ObserverRequired
@ -434,6 +447,9 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        try{
            if (StringUtils.isBlank(doctorId)&&StringUtils.isBlank(name)){
                return PageEnvelop.getError("请求参数错误");
            }
            return archiveService.archiveList(doctorId,page,size,signStatus,name);
        }catch (Exception e){
            e.printStackTrace();
@ -489,6 +505,18 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value="getServerDoctorAll")
    @ApiOperation(value = "获取所有服务医生")
    public ListEnvelop getServerDoctorAll(            @ApiParam(name = "patient", value = "患者id", required = true)
                                                          @RequestParam(value = "patient") String patient){
        try {
            return ListEnvelop.getSuccess("查询成功",servicePackageService.getServerDoctorAll(patient));
        }catch (Exception e){
            e.printStackTrace();
            return ListEnvelop.getError("查询失败");
        }
    }
    @GetMapping(value="getPackageDetailById")
    @ApiOperation(value = "获取服务包详情")
    public ObjEnvelop getPackageDetailById(@ApiParam(name="packageId",value = "服务包id",required = true)

+ 46 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/assistance/EmeAsEndpoint.java

@ -0,0 +1,46 @@
package com.yihu.jw.care.endpoint.third.assistance;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ServicesAuth;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * Created by Bing on 2021/5/10.
 */
@RestController
@RequestMapping(value = "/cloudCare/noLogin/emergency_assistance")
@Api(description = "紧急救助相关")
public class EmeAsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private EmergencyAssistanceService assistanceService;
    @PostMapping(value = "newOrder")
    @ApiOperation(value = "居民发起新的紧急救助")
    @ServicesAuth(item = "emergencyAssistance")
    public ObjEnvelop newOrder(@ApiParam(name="patientId",value = "居民id")
                               @RequestParam(value = "patientId") String patientId,
                               @ApiParam(name="jsonData",value = "创建工单json")
                               @RequestParam(value = "jsonData") String jsonData
    ){
        try {
            JSONObject result = assistanceService.newOrder(patientId,jsonData,getUID());
            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());
        }
    }
}

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

@ -0,0 +1,175 @@
package com.yihu.jw.care.service.contacts;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.contacts.BasePatientContactsOrgDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.family.PatientFamilyMemberDao;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import com.yihu.jw.entity.care.contacts.BasePatientContactsOrgDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.LatitudeUtils;
import org.apache.commons.collections.map.HashedMap;
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 org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/7
 * @Description:
 */
@Service
public class ContactsService {
    @Autowired
    private PatientFamilyMemberDao memberDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    private PatientFamilyMemberService patientFamilyMemberService;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private BasePatientContactsOrgDao contactsOrgDao;
    @Autowired
    private BaseOrgDao baseOrgDao;
    @Autowired
    private ServicePackageService servicePackageService;
    /**
     * 查找居民联系服务站
     * @param patient
     */
    public BaseOrgDO getContactsOrg(String patient){
        BasePatientContactsOrgDO contactsOrgDO = contactsOrgDao.findByPatient(patient);
        if(contactsOrgDO == null){
            return null;
        }
        return baseOrgDao.findByCode(contactsOrgDO.getOrgCode());
    }
    /**
     * 设置居民联系服务站
     * @param patient
     */
    public void setContactsOrg(String patient,String orgCode){
        BasePatientContactsOrgDO contactsOrgDO = contactsOrgDao.findByPatient(patient);
        if(contactsOrgDO == null){
            contactsOrgDO = new BasePatientContactsOrgDO();
            contactsOrgDO.setPatient(patient);
        }
        contactsOrgDO.setOrgCode(orgCode);
        contactsOrgDao.save(contactsOrgDO);
    }
    /**
     * 获取居民的联系人
     * @param patient 居民
     * @return
     */
    public JSONArray getPatientContacts(String patient, Integer isContacts) {
        JSONArray resultArray = new JSONArray();
        String sql = "select *,t1.id fid " +
                " from " +
                "    base_patient_family_member t1, " +
                "    base_patient t2 " +
                " where " +
                "    t2.id in (select family_member from base_patient_family_member where patient = ? ) " +
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.id ";
        if(isContacts == 1){
            sql += " and t1.is_contacts = "+ isContacts;
        }
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient, patient});
        if (result != null && result.size() > 0) {
            for (Map<String, Object> map : result) {
                JSONObject obj = new JSONObject();
                obj.put("id", map.get("id"));
                obj.put("fid", map.get("fid"));
                obj.put("name", map.get("name"));
                obj.put("isContacts", map.get("is_contacts"));
                obj.put("sex", map.get("sex"));
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                obj.put("familyRelation", map.get("family_relation"));
                obj.put("familyRelationName", PatientFamilyMemberService.relations.get(map.get("family_relation")));
                resultArray.add(obj);
            }
        }
        return resultArray;
    }
    /**
     * 设置一键联系人
     * @param fid
     * @param patient
     */
    @Transactional(rollbackFor = Exception.class)
    public void setContacts(String fid,String patient){
        BasePatientFamilyMemberDO familyMemberDO = memberDao.findOne(fid);
        BasePatientDO patientDO = basePatientDao.findById(patient);
        //设置爱牵挂智能设备sos号码
        try {
            List<DevicePatientDevice> patientDeviceList = patientDeviceDao.findByPatient(patient);
            for(DevicePatientDevice patientDevice : patientDeviceList){
                if("4".equals(patientDevice.getCategoryCode())||"7".equals(patientDevice.getCategoryCode())){
                    patientDeviceService.updAqgDeviceSosInfo(patientDevice.getDeviceSn(),"1",
                            PatientFamilyMemberService.relations.get(familyMemberDO.getFamilyRelation()),patientDO.getMobile(),"1",null);
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        memberDao.updateContactsByPatient(patient);
        familyMemberDO.setIsContacts(1);
        memberDao.save(familyMemberDO);
    }
    /**
     * 获取居民签约机构
     */
    public List<Map<String,Object>> findSignOrg(String patient,String lng,String lat){
        List<Map<String,Object>> result = new ArrayList<>();
        List<BaseOrgDO> orgDOList = servicePackageService.findSignOrg(patient);
        for (BaseOrgDO orgDO : orgDOList){
            Map<String,Object> map = new HashedMap();
            map.put("distance", LatitudeUtils.getDistance(lat,lng,orgDO.getLatitude(),orgDO.getLongitude()));
            map.put("id",orgDO.getId());
            map.put("code",orgDO.getCode());
            map.put("name",orgDO.getName());
            map.put("photo",orgDO.getPhoto());
            map.put("mobile",orgDO.getMobile());
            map.put("address",orgDO.getAddress());
            result.add(map);
        }
        return result;
    }
}

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

@ -7,6 +7,7 @@ import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.service.wechat.WeiXinAccessTokenUtils;
import com.yihu.jw.care.util.ConcealUtil;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.care.util.MyJdbcTemplate;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -88,6 +89,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    Map<Integer, String> relations = new HashMap<>();
    @Value("${es.index.Statistics}")
    private String esIndex;
    @Autowired
    private GpsUtil gpsUtil;
    @PostConstruct
    public void init() {
@ -127,11 +130,18 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        String type = devicePatientDevice.getCategoryCode();
        Long deviceId = devicePatientDevice.getDeviceId();
        String userType = devicePatientDevice.getUserType();
        String sosAddress = null;
        if (userType == null) {
            userType = "-1";
            devicePatientDevice.setUserType("-1");
        }
        if (type.equals("7")){
            if (StringUtils.isBlank(devicePatientDevice.getSosAddress())){
                return false;
            }
        }
        boolean needVerify = true;
        //修改操作
        if (devicePatientDevice.getId() != null) {
@ -168,6 +178,15 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return true;
    }
    public int delDeviceByDeviceSn(String deviceSn){
        String sql = "select * from wlyy_patient_device where del = 0 and device_sn = '"+deviceSn+"'";
        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
        if (list.size() > 0){
            return patientDeviceDao.updatePatientDevice(deviceSn);
        }else {
            return 0;
        }
    }
    public void deleteDevices(String deviceSn, String type, String uuid) {
        List<DevicePatientDevice> devicePatientDevices = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
@ -230,6 +249,30 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return patientDeviceDao.findAll(spec, pageRequest);
    }
    public List<Map<String , Object>> findDeviceFromAdmin(String patientName, String Idcard, int page, int pageSize) {
        String sql = "select p.id,p.`name`,pd.device_id deviceId,pd.category_code categoryCode,pd.device_name deviceName,pd.device_sn deviceSn,pd.czrq,pd.doctor,\n" +
                "pd.doctor_name doctorName,pd.agent,pd.agent_name agentName from wlyy_patient_device pd,base_patient p where p.id = pd.`user`";
        if (StringUtils.isNotBlank(patientName)){
            sql += " AND p.`name` LIKE '%" + patientName +"%'";
        }
        if (StringUtils.isNotBlank(Idcard)){
            sql += " AND p.idcard LIKE '%" + Idcard + "%'";
        }
        sql += " ORDER BY pd.czrq DESC LIMIT "+ (page-1)*pageSize +" , " + pageSize + " ";
        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    public List<Map<String , Object>> getDeviceType(int type,String pyCode) {
        String sql = "SELECT * FROM base_system_dict WHERE saas_id = 'device_type' AND type = "+type+"";
        if (StringUtils.isNotBlank(pyCode)){
            sql += " and py_code = '"+pyCode+"' " ;
        }
        List<Map<String , Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    /**
     * 患者设备列表接口--医生端
     */
@ -371,6 +414,19 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return re;
    }
    public List<Map<String,Object>> patientDeviceListByTopic(String patient,String serviceTopic){
        String sql = "select dd.photo,dd.brands,dd.category_code,dd.model,pd.device_name,pd.czrq deviceTime from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code\n" +
                "where 1=1 and  pd.del=0 ";
        if (StringUtils.isNotBlank(patient)) {
        sql += " pd.`user`='" + patient + "' ";
        }
        if (StringUtils.isNotBlank(serviceTopic)) {
            sql+= " and dd.service_topic='preventLost' ";
        }
        sql+=" order by pd.czrq asc ";
        return jdbcTemplate.queryForList(sql);
    }
    public JSONArray getDeviceByDeviceSn(String deviceSn, String type) {
        List<DevicePatientDevice> list = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        JSONArray objects = new JSONArray();
@ -713,7 +769,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    若该设备以前已设置亲情号码2,则以前设置的亲情号码2也会被清空]
    |
     */
    public com.alibaba.fastjson.JSONObject updAqgDeviceSosInfo(String deviceSn,String seqid,String name,String num,String dial_flag,String clear) throws Exception{
    public com.alibaba.fastjson.JSONObject updAqgDeviceSosInfo(String deviceSn,String seqid,String name,String num,String dial_flag,String clear){
        String url = MessageFormat.format(AqgConfig.sos_numbers, deviceSn,seqid);
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if(StringUtils.isBlank(clear)){
@ -728,7 +784,59 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return response.getBody();
    }
    /**
     * 获取设备最新位置数据
     * @param deviceSn
     * @param type  0:Gps定位; 1:基站定位 (非必填)
     * @return
     * @throws Exception
     */
    public com.alibaba.fastjson.JSONObject getDeviceLastLocation(String deviceSn,String type) throws Exception{
        String url = MessageFormat.format(AqgConfig.device_last_locationdata, deviceSn);
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        param.add("type", type);
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.GET, getCookie());
        return response.getBody();
    }
    /**
     *
     *    | enable       |  否  | Int          |  0,1 是否启用                        |
     *    | name         |  否  | String       |   安全区名称                           |
     *    | freq         |  否  | Boolean      |  0,触发一天;1,每日触发        |
     *    | time_begin   |  否  | Int          |  目标时间与当日0点之间相差的秒数。如8 a.m 8*60*60=28800 |n
     *    | time_end     |  否  | Int          |  同上                        |
     *    | safe_area    |  否  | String       | x1,y1;x2,y2;xn,yn  一组由';'分隔的坐标,坐标用','分隔。且需要呈闭环,如A,B,C,D4个点,则应该上传的数据为 A;B;C;D;A  |
     *    | clear        |  否  | any          | 如果指定clear参数,则上述参数全部无意义,全部重设为缺省值    |
     * @return
     * @throws Exception
     */
    public com.alibaba.fastjson.JSONObject updateDeviceFenceArea(String deviceSn,Integer fenceNO,String enable,String name,String freq,
                                                                 String time_begin,String time_end,String safe_area ,String clear) throws Exception{
        String url = MessageFormat.format(AqgConfig.fence_area, deviceSn,fenceNO);
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if(StringUtils.isBlank(clear)){
            if (StringUtils.isNotBlank(safe_area)){
                String[] position = safe_area.split(";");
                safe_area = "";
                for (String tmp:position){
                    String[] point = tmp.split(",");
                    safe_area+= gpsUtil.bd09_To_Gcj02_str(Double.parseDouble(point[1]),Double.parseDouble(point[0]))+";";
                }
            }
            param.add("name", name);
            param.add("freq", freq);
            param.add("enable",enable);
            param.add("time_begin", time_begin);
            param.add("time_end", time_end);
            param.add("safe_area", safe_area);
        }else {
            param.add("clear",clear);
        }
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.POST, getCookie());
        return response.getBody();
    }
    /******************************************* 爱牵挂设备end *****************************************************/

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

@ -1,11 +1,16 @@
package com.yihu.jw.care.service.doctor;
import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import com.yihu.jw.care.endpoint.org.OrgEndpoint;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.DoctorSpecialDiseaseDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.StringUtil;
@ -14,10 +19,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
 * Created by yeshijie on 2021/3/3.
@ -38,6 +48,12 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private RoleService roleService;
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 获取医生详情
@ -118,4 +134,40 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return true;
    }
    public Map<String,Object> getOrgDoctor(String doctorId,String orgType){
        List<BaseOrgDO> orgList = new ArrayList<>();
        Map<String,Object> orgListMap = new HashMap<>();
        Map<String,Object> result = new HashMap<>();
        if (orgType.equals("3")){//养老机构
            orgList = orgDao.findByDoctorAndType(doctorId,"3");
        }
        if (orgType.equals("1,2")){//医疗机构
            orgList = orgDao.findByTypeIn(new String[]{"1","2"});
        }
        if (orgType.equals("4")){//托育机构
            orgList = orgDao.findByDoctorAndType(doctorId,"4");
        }
        List<Map<String,Object>> doctorList = new ArrayList<>();
        if (orgList.size()==0){
            return new HashMap<>();
        }
        for (BaseOrgDO org:orgList){
            String sql = "select dh.org_code,dh.org_name,doc.id,doc.name,doc.mobile,doc.photo,dict.code deptCode,dict.name deptName,dh.doctor_duty_code job,dh.doctor_duty_name jobName\n" +
                    "from base_doctor_hospital dh,dict_hospital_dept dict,base_doctor doc where  dh.doctor_code = doc.id  " +
                    "and dh.dept_code = dict.`code` and dh.org_code = dict.org_code and dh.del=1 and dh.org_code='"+org.getCode()+"' GROUP BY doc.id" ;
            List<Map<String,Object>> tmpList = jdbcTemplate.queryForList(sql);
            Map<String,List<Map<String,Object>>> docTmp = tmpList.stream().collect(Collectors.groupingBy(e->e.get("deptCode").toString()));
          Map<String,String> deptList = tmpList.stream().collect(Collectors.toMap(s->s.get("deptCode").toString(),s->s.get("deptName").toString(),(oldVal, currVal) -> currVal));
            Map<String,Object> tmpMap = new HashMap<>();
            tmpMap.put("orgCode",org.getCode());
            tmpMap.put("orgName",org.getName());
//            tmpMap.put("deptList",deptList);
            orgListMap.put(org.getCode(),tmpMap);
            doctorList.addAll(tmpList);
        }
        result.put("orgList",orgListMap);
        return result;
    }
}

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

@ -18,11 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -32,7 +28,7 @@ import java.util.regex.Pattern;
@Service
public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamilyMemberDO, PatientFamilyMemberDao> {
    Map<Integer, String> relations = new HashMap<>();
    public static Map<Integer, String> relations = new HashMap<>();
    @Autowired
    private PatientFamilyMemberDao memberDao;
    @Autowired
@ -43,8 +39,8 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @PostConstruct
    public void init() {
    static {
        relations.put(0, "其他");
        relations.put(1, "父亲");
        relations.put(2, "母亲");
@ -359,7 +355,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
     * @param patient 居民
     * @return
     */
    public JSONArray getPatientFamilyMembers(String patient, String doctorCode, Integer isAgree) {
    public JSONArray getPatientFamilyMembers(String patient, String doctorCode, Integer isContacts) {
        JSONArray resultArray = new JSONArray();
        String sql = "select * " +
                " from " +
@ -369,7 +365,9 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                "    t2.id in (select family_member from base_patient_family_member where patient = ? ) " +
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.id ";
/*        if(isContacts != null){
            sql += " and t1.is_contacts = "+ isContacts;
        }*/
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient, patient});
        if (result != null && result.size() > 0) {
@ -387,6 +385,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                obj.put("id", map.get("id"));
                obj.put("name", map.get("name"));
                obj.put("isContacts", map.get("is_contacts"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", isAuthorize);//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
@ -715,31 +714,47 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
    }
    @Transactional
    public int addMemberByCaptcha(String patient, String member, String captcha, int relation) throws Exception {
        if (patient.equals(member)) {
            return 0;
        }
    public int addMemberByCaptcha(String patient, String idcard, String name, String mobile, Integer archiveType, String captcha, int relation) throws Exception {
        BasePatientDO p = patientDao.findById(patient);
        BasePatientDO m = patientDao.findById(member);
        if (p == null) {
            return -1;
        }
        // 添加的成员是否注册判断
        if (m == null) {
            return -2;
        if(idcard.equals(p.getIdcard())){
            return 0;
        }
//        // 验证码验证
        //        // 验证码验证
//        if (StringUtils.isNotEmpty(captcha)) {
//            int checkStatus = smsService.check(m.getMobile(), 10, captcha);
//            int checkStatus = smsService.check(mobile, 10, captcha);
//            if (checkStatus == -2) {
//                return -6;  // 验证码过期
//            } else if (checkStatus == -1) {
//                return -3; // 验证码错误
//            }
//        }
        BasePatientDO m = patientDao.findByIdcard(idcard);
        String member = "";
        // 添加的成员是否注册判断
        if (m == null) {
            //新增账户
            m = new BasePatientDO();
            String salt = UUID.randomUUID().toString().substring(0,5);
            String pw = idcard.substring(idcard.length()-6,idcard.length());
            m.setPassword(com.yihu.utils.security.MD5.md5Hex(pw + "{" + salt + "}"));
            m.setSalt(salt);
            m.setMobile(mobile);
            m.setDel("1");
            m.setEnabled(1);
            m.setLocked(0);
            m.setCreateTime(new Date());
            m.setUpdateTime(new Date());
            m.setName(name);
            m.setIdcard(idcard);
            m.setArchiveType(archiveType);
            patientDao.save(m);
        }
        member = m.getId();
        return addMemberFamily(p, m, patient, member, relation);
    }

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

@ -40,7 +40,7 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
                "                and i.del = 1 and i.team_code = '"+teamCode+"' " +
                "                and sr.patient = p.id and p.id = l.patient and l.label_type = 1) " +
                "a on dict.dict_code = a.label_code  " +
                "where dict.dict_name = '"+ConstantUtil.DICT_SERVICE_TYPE+"'  " +
                "where dict.dict_name = '"+ConstantUtil.DICT_SERVICE_TYPE+"' and dict_code<>5  " +
                "GROUP BY labelCode,labelName ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){

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

@ -178,6 +178,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        String sql = "SELECT " +
                "  p.name AS patientName, " +
                "  p.photo AS photo, " +
                "  p.idcard," +
                "  case p.sex  " +
                "  when 1 then '男'  " +
                "  when 2 then '女' " +

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

@ -127,4 +127,88 @@ public class DoctorMessageService {
        return result;
    }
    public JSONObject getPreventLost(String doctor,String id,String type){
        JSONObject result = new JSONObject();
        boolean typeNull = StringUtils.isBlank(type);
        if (typeNull||type.equals("preventLost")){//安全监护
            String sql ="select id,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,'preventLost' as service_type from base_security_monitoring_order ord where 1=1 \n" +
                    "and status <>-1 and status<> 7  \n" +
                    "and  EXISTS ( \n" +
                    "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
                    "base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and \n" +
                    "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='preventLost' \n" +
                    "and m.doctor_code = '"+doctor+"' and m.del = '1') \n" +
                    "order by create_time DESC ";
            if (StringUtils.isNotBlank(id)){
                sql = "select * from base_security_monitoring_order ord where 1=1 \n" +
                        "AND id = '"+id+"'\n" +
                        "and status <>-1 and status<> 7  \n" +
                        "and  EXISTS ( \n" +
                        "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
                        "base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and \n" +
                        "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='preventLost' \n" +
                        "and m.doctor_code = '13' and m.del = '1') ";
            }
            List<Map<String,Object>> sqlResult  = jdbcTemplate.queryForList(sql);
            result.put("preventLost",sqlResult);
        }
        if (typeNull||type.equals("emergencyAssistance")){//紧急救助
            String sql ="select id,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,'emergencyAssistance' as service_type from base_emergency_assistance_order ord where 1=1\n" +
                    "and status =1 \n" +
                    "and EXISTS ( \n" +
                    "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
                    "base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and \n" +
                    "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='emergencyAssistance' \n" +
                    "and m.doctor_code = '"+doctor+"' and m.del = '1')\n" +
                    "order by create_time DESC ";
            if (StringUtils.isNotBlank(id)){
                sql = "select * from base_emergency_assistance_order ord where 1=1\n" +
                        "\n" +
                        "AND id = '"+id+"'\n" +
                        "\n" +
                        "and status =1 \n" +
                        "and EXISTS ( \n" +
                        "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ,\n" +
                        "base_team_member m where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and \n" +
                        "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='emergencyAssistance' \n" +
                        "and m.doctor_code = '13' and m.del = '1')";
            }
            List<Map<String,Object>> sqlResult  = jdbcTemplate.queryForList(sql);
            result.put("emergencyAssistance",sqlResult);
        }
        if (typeNull||type.equals("fifeCare")){//生活照料
            String sql ="select id,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,'fifeCare' as service_type from base_life_care_order lco where 1=1\n" +
                    "and status =1 \n" +
                    "and EXISTS ( \n" +
                    "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r,\n" +
                    "base_team_member m where lco.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and sr.`status`=1 \n" +
                    "and m.team_code\n" +
                    "and m.doctor_code = '"+doctor+"' and m.del = '1')\n" +
                    "order by create_time DESC ";
            if (StringUtils.isNotBlank(id)){
                sql = "select * from base_life_care_order lco where 1=1\n" +
                        "AND id = '"+id+"'\n" +
                        "and status =1 \n" +
                        "and EXISTS ( \n" +
                        "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r,\n" +
                        "base_team_member m where lco.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and sr.`status`=1 \n" +
                        "and m.doctor_code = '"+doctor+"' and m.del = '1')";
            }
            List<Map<String,Object>> sqlResult  = jdbcTemplate.queryForList(sql);
            result.put("fifeCare",sqlResult);
        }
        return result;
    }
}

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

@ -7,7 +7,10 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.*;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -65,6 +68,12 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    private SecurityMonitoringConclusionDao securityMonitoringConclusionDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private GpsUtil gpsUtil;
    @Autowired
    private CountDistance countDistance;
    private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
@ -906,6 +915,69 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    public JSONObject patientMonitoringInfo(String patient){
        JSONObject result = new JSONObject();
        result.put("location",null);
        result.put("fences",null);
        result.put("smoke",null);
        result.put("fire",null);
        result.put("deviceSn",null);
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
        if (devicePatientDeviceDos.size()==0){
            return result;
        }
        else {
            DevicePatientDevice device = devicePatientDeviceDos.get(0);
            result.put("deviceSn",device.getDeviceSn());
            try {
             JSONObject response= patientDeviceService.getAqgDeviceInfo(device.getDeviceSn());
             if (response!=null){
                 //定位信息
                if (response.containsKey("last_location")&&response.get("last_location")!=null){
                    JSONObject locationTmp = response.getJSONObject("last_location");
                    Double lon = locationTmp.getJSONArray("coordinates").getDouble(0);
                    Double lat = locationTmp.getJSONArray("coordinates").getDouble(1);
                    JSONObject tmp = gpsUtil.gcj02_To_Bd09(lat,lon);
                    tmp.put("city",locationTmp.getString("city"));
                    tmp.put("address",locationTmp.getString("address"));
                    result.put("location",tmp);
                }
                //围栏信息
                 if (response.containsKey("fences")&&response.get("fences")!=null){
                     JSONArray fencesArr = response.getJSONArray("fences");
                     JSONArray fencesEnables = new JSONArray();
                     for (int i=0;i<fencesArr.size();i++){
                         JSONObject tmp = fencesArr.getJSONObject(i);
                         if (tmp.getBooleanValue("enable")){//围栏生效
                            JSONObject fenceTmp = new JSONObject();
                            fenceTmp.put("fenceNO",tmp.getInteger("seqid").toString());
                            fenceTmp.put("name",tmp.getString("name"));
                            JSONArray fenceLocationTmp = tmp.getJSONObject("safe_area").getJSONArray("coordinates").getJSONArray(0);
                            JSONArray fenceLocation = new JSONArray();
                            for (int j=0;j<fenceLocationTmp.size();j++){
                                Double lon = fenceLocationTmp.getJSONArray(j).getDouble(0);
                                Double lat = fenceLocationTmp.getJSONArray(j).getDouble(1);
                                JSONObject positionTmp = gpsUtil.gcj02_To_Bd09(lat,lon);
                                fenceLocation.add(positionTmp);
                            }
                            fenceTmp.put("location",fenceLocation);
                            fenceTmp.put("inFenceStatus",countDistance.isInPolygon(result.getJSONObject("location").getDouble("lon"),result.getJSONObject("location").getDouble("lat"),fenceLocation));
                            fencesEnables.add(fenceTmp);
                         }
                     }
                     if (fencesEnables.size()>0){
                         result.put("fences",fencesEnables);
                     }
                 }
             }
            }catch (Exception e){
                e.printStackTrace();
                result.put("location",null);
            }
        }
        return result;
    }
    private String getRandomIntStr(){
        Random rand = new Random();
        int i = rand.nextInt(); //int范围类的随机数

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

@ -83,8 +83,8 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
    }
    public PageEnvelop<List<Map<String,Object>>> archiveList(String doctorId, int page, int size,Integer signStatus,String name){
        String sql = "SELECT a.create_time,p.idcard,p.mobile,p.name,p.sex,p.id,CAST(a.sign_status AS char) sign_status ";
        String countSql = "SELECT count(*) ";
        String sql = "SELECT a.create_time,p.idcard,p.mobile,p.name,p.sex,p.id,p.photo,CAST(a.sign_status AS char) sign_status ";
        String countSql = "SELECT count(*) from ( ";
        String filters = "from wlyy_archive a,base_patient p " +
                "WHERE  a.patient = p.id ";
@ -97,8 +97,24 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
        if(StringUtils.isNotBlank(name)){
            filters += " and p.name like '%"+name+"%'";
        }
        if (signStatus!=null&&signStatus==1){//已签约不按建档查询,是要该居民服务医生就在列表中
            filters+=" UNION " +
                    " SELECT a.create_time,p.idcard,p.mobile,p.name,p.sex,p.id,p.photo,CAST(a.sign_status AS char) sign_status \n" +
                    "from wlyy_archive a,base_patient p WHERE  a.patient = p.id and a.sign_status = 1 and EXISTS( " +
                    "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                    "base_service_package_item i,base_team_member m " +
                    "WHERE  sr.id = r.sign_id and sr.patient = a.patient and sr.status=1 and r.service_package_id = i.service_package_id " +
                    "and i.del = 1 and m.team_code = i.team_code " ;
            if(StringUtils.isNotBlank(doctorId)){
                filters += " and m.doctor_code = '"+doctorId+"' ";
            }
            if(StringUtils.isNotBlank(name)){
                filters += " and p.name like '%"+name+"%'";
            }
            filters+= " and m.del = '1' and sr.`status`=1 ) ";
        }
        String orderBy = " ORDER BY a.create_time DESC " +
        String orderBy = " ORDER BY create_time DESC " +
                "LIMIT "+ (page - 1) * size + "," + size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filters+orderBy);
@ -112,7 +128,7 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
                map.put("servicePackageList",servicePackageService.getServicePackageListByPatient(patientId,null));
            }
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);
        Long count = jdbcTemplate.queryForObject(countSql+sql+filters+" )tmp",Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
    }

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

@ -75,14 +75,17 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
    private PatientBedApplyDao patientBedApplyDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private CapacityDoctorDao capacityDoctorDao;
    /**
     * 按id查找评估明细
     * @param patient
     * @return
     */
    public CapacityAssessmentRecordDO findAssessmentByPatientId(String patient)  {
        CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordDao.findByPatient(patient);
    public CapacityAssessmentRecordDO findAssessmentByPatientId(String patient) throws Exception {
        Date assessmentTime =  DateUtil.dateTimeParse(DateUtil.getNowYear() + "-01-01 00:00:00");
        CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordDao.findByPatient(patient,assessmentTime);
        recordDO.setLevelConclusionName(dictService.fingByNameAndCode(ConstantUtil.DICT_LEVEL_CONCLUSION,String.valueOf(recordDO.getLevelConclusion())));
        return recordDO;
    }
@ -135,28 +138,28 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
            res.put(String.valueOf(map.get("level_conclusion")),c);
        }
        String sql2 = "SELECT COUNT(DISTINCT ar.id) from base_patient ar, " +
                "base_service_package_sign_record sr,base_service_package_record r,  " +
                "                base_service_package_item i,base_team_member m  " +
                "                WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
                "                and i.del = 1 and m.team_code = i.team_code and ar.id = sr.patient and ar.archive_type = 2 " +
                "                and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1";
        Integer count = jdbcTemplate.queryForObject(sql2,Integer.class);
        res.put("10",count);
//        String sql2 = "SELECT COUNT(DISTINCT ar.id) from base_patient ar, " +
//                "base_service_package_sign_record sr,base_service_package_record r,  " +
//                "                base_service_package_item i,base_team_member m  " +
//                "                WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
//                "                and i.del = 1 and m.team_code = i.team_code and ar.id = sr.patient and ar.archive_type = 2 " +
//                "                and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1";
//        Integer count = jdbcTemplate.queryForObject(sql2,Integer.class);
//        res.put("10",count);
        return res;
    }
    public PageEnvelop<List<Map<String,Object>>> assessmentPage(String doctorId,String name, int page, int size,
                    Integer status,Integer levelConclusion,Integer servicePackageStatus){
        String sql = "SELECT c.id,c.patient,c.assessment_time,c.service_package_status servicePackageStatus, " +
                "c.`status`,c.level_conclusion levelConclusion,c.org_code orgCode,c.org_name orgName,p.name,p.mobile,p.sex,p.idcard  ";
                "c.`status`,c.level_conclusion levelConclusion,c.org_code orgCode,c.org_name orgName,p.name,p.photo,p.mobile,p.sex,p.idcard  ";
        String countSql = "SELECT count(*) ";
        String filters = "from base_capacity_assessment_record c,base_patient p " +
        String filters = "from base_capacity_assessment_record c left join base_capacity_doctor d on c.id =d.capacity_id ,base_patient p " +
                "WHERE  c.patient = p.id  and c.assessment_time>='" + DateUtil.getNowYear() + "-01-01'";
        if(StringUtils.isNoneBlank(doctorId)){
            filters += " and c.doctor = '"+doctorId+"' ";
            filters += " and (c.doctor = '"+doctorId+"' or d.doctor_id = '"+doctorId+"')";
        }
        if(status!=null){
            filters += " and c.status = "+status;
@ -271,6 +274,30 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
        return result;
    }
    /**
     * 同步能力评估
     * @param patient
     * @param doctorId
     * @throws Exception
     */
    public void synCapacityRecord(String patient,String doctorId) throws Exception{
        Date assessmentTime =  DateUtil.dateTimeParse(DateUtil.getNowYear() + "-01-01 00:00:00");
        CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordDao.findByPatient(patient,assessmentTime);
        if(recordDO == null){
            throw new Exception("居民不存在有效的能力评估报告");
        }
        if(doctorId.equals(recordDO.getDoctor())){
           return;
        }
        CapacityDoctorDO capacityDoctorDO = capacityDoctorDao.findByCapacityIdAndDoctorId(recordDO.getId(),doctorId);
        if(capacityDoctorDO == null){
            capacityDoctorDO = new CapacityDoctorDO();
            capacityDoctorDO.setCapacityId(recordDO.getId());
            capacityDoctorDO.setDoctorId(doctorId);
            capacityDoctorDao.save(capacityDoctorDO);
        }
    }
    /**
     * 通过患者id 生成当年评估报告
     * @param patient

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

@ -480,6 +480,18 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return result;
    }
    public List<Map<String,Object>> getServerDoctorAll(String patient){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile\n" +
                "from base_service_package_item item ,base_service_package pack,base_team_member mem,base_doctor doc\n" +
                "where item.service_package_id in (\n" +
                "SELECT spc.service_package_id FROM base_service_package_record spc ,base_service_package_sign_record spsr\n" +
                "WHERE spc.patient = '"+patient+"' AND spsr.status = 1 AND spsr.patient = spc.patient\n" +
                ") and item.service_package_id = pack.id\n" +
                "and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 and pack.del=1 and item.del = 1";
        List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
        return result;
    }
    public Map<String,Object> getPackageDetailById(String packageId){
        String sql="select * from base_service_package where id='"+packageId+"' and del=1 ";
        Map<String,Object>result = jdbcTemplate.queryForMap(sql);

+ 51 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/CountDistance.java

@ -1,7 +1,13 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.List;
@Component
public class CountDistance {
    private static double EARTH_RADIUS = 6378.137;// 6378.137赤道半径6378137
@ -32,4 +38,49 @@ public class CountDistance {
        return s;
    }
    /**
     * 判断坐标是否在多边形区域内
     * @param pointLon
     * @param pointLat
     * @param rangePositions 多边形坐标 [{"lon":118.19302036660137,"lat":24.494515439791996},{"lon":118.19401849369201,"lat":24.49606682685256}]
     * @return
     */
    public boolean isInPolygon(double pointLon, double pointLat, JSONArray rangePositions) {
        // 将要判断的横纵坐标组成一个点
        double[] lon =  rangePositions.stream().mapToDouble(item->((JSONObject)item).getDouble("lon")).toArray();
        double[] lat =  rangePositions.stream().mapToDouble(item->((JSONObject)item).getDouble("lat")).toArray();;
        Point2D.Double point = new Point2D.Double(pointLon, pointLat);
        // 将区域各顶点的横纵坐标放到一个点集合里面
        List<Point2D.Double> pointList = new ArrayList<Point2D.Double>();
        double polygonPoint_x = 0.0, polygonPoint_y = 0.0;
        for (int i = 0; i < lon.length; i++) {
            polygonPoint_x = lon[i];
            polygonPoint_y = lat[i];
            Point2D.Double polygonPoint = new Point2D.Double(polygonPoint_x, polygonPoint_y);
            pointList.add(polygonPoint);
        }
        return check(point, pointList);
    }
    private static boolean check(Point2D.Double point, List<Point2D.Double> polygon) {
        java.awt.geom.GeneralPath peneralPath = new java.awt.geom.GeneralPath();
        Point2D.Double first = polygon.get(0);
        // 通过移动到指定坐标(以双精度指定),将一个点添加到路径中
        peneralPath.moveTo(first.x, first.y);
        polygon.remove(0);
        for (Point2D.Double d : polygon) {
            // 通过绘制一条从当前坐标到新指定坐标(以双精度指定)的直线,将一个点添加到路径中。
            peneralPath.lineTo(d.x, d.y);
        }
        // 将几何多边形封闭
        peneralPath.lineTo(first.x, first.y);
        peneralPath.closePath();
        // 测试指定的 Point2D 是否在 Shape 的边界内。
        return peneralPath.contains(point);
    }
}

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

@ -0,0 +1,11 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DeviceSosLogDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/5/8.
 */
public interface DeviceSosLogDao extends PagingAndSortingRepository<DeviceSosLogDO, Long>, JpaSpecificationExecutor<DeviceSosLogDO> {
}

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

@ -226,38 +226,6 @@ public class DeviceController {
        }
    }
    @ApiOperation("柏颐设备sos数据接收")
    @RequestMapping(value = "bySos", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String bySos(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = true) String imei,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="heartrate",required = false,value="心率")
            @RequestParam(value = "heartrate",required = false) int heartrate,
            @ApiParam(name="city",required = false,value="城市")
            @RequestParam(value = "city",required = false) String city,
            @ApiParam(name="address",required = false,value="地址")
            @RequestParam(value = "address",required = false) String address,
            @ApiParam(name="lon",required = false,value="经度")
            @RequestParam(value = "lon",required = false) double lon,
            @ApiParam(name="lat",required = false,value="纬度")
            @RequestParam(value = "lat",required = false) double lat,
            @ApiParam(name="type",required = false,value="类型  0:Gps定位; 1:基站定位")
            @RequestParam(value = "type",required = false) String type,
            HttpServletRequest request) {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("请求参数:"+paraString);
            deviceService.bySos(imei,time_begin,heartrate,city,address,lon,lat,type);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐设备步数接收")
    @RequestMapping(value = "bySteps", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String bySteps(
@ -310,57 +278,6 @@ public class DeviceController {
        }
    }
    @ApiOperation("柏颐设备开关机数据接收")
    @RequestMapping(value = "bySwitch", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String bySwitch(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = true) String imei,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="type",required = false,value="开/关机类型  0:开机; 1:关机; 2:电量上报; 3:低电通知")
            @RequestParam(value = "type",required = false) String type,
            @ApiParam(name="remaining_power",required = false,value="剩余电量(%)")
            @RequestParam(value = "remaining_power",required = false) int remaining_power,
            HttpServletRequest request) {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("请求参数:"+paraString);
            deviceService.bySwitch(imei,time_begin,type,remaining_power);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐设备消息通知数据接收")
    @RequestMapping(value = "byPushData", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String byPushData(
            @ApiParam(name="type",required = false,value="type=1 SOS,type=2 fall,type=3 new 新成员加入 ,type=4 电子围栏触发, type=5 设备低电,type=6 环境音 ",defaultValue = "")
            @RequestParam(value = "type",required = false) int type,
            @ApiParam(name="deviceid",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "deviceid",required = true) String deviceid,
            @ApiParam(name="communityid",required = false,value="机构ID")
            @RequestParam(value = "communityid",required = false) String communityid,
            @ApiParam(name="url",required = false,value="环境音下载地址 只有环境音(type=6)为必填,其他type都为非必填")
            @RequestParam(value = "url",required = false) String url,
            @ApiParam(name="name",required = false,value="设备名称")
            @RequestParam(value = "name",required = false) String name,
            HttpServletRequest request) {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("请求参数:"+paraString);
            deviceService.byPushData(type,deviceid,communityid,url,name);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /**
     * 返回接口处理结果

+ 94 - 69
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -1,28 +1,37 @@
package com.yihu.jw.care.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.DevicePatientHealthIndexDao;
import com.yihu.jw.care.dao.device.DeviceSosLogDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DeviceSosLogDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
@ -36,6 +45,8 @@ import java.util.concurrent.TimeUnit;
public class DeviceService {
    private static Logger logger = LoggerFactory.getLogger(DeviceService.class);
    @Value("${cloudCare.url}")
    private String cloudCareUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
@ -45,6 +56,14 @@ public class DeviceService {
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DevicePatientHealthIndexDao healthIndexDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private DeviceSosLogDao sosLogDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private GpsUtil gpsUtil;
    /**
     * 获取爱牵挂管理员cookie
@ -96,12 +115,67 @@ public class DeviceService {
    @Async
    public void aqgsos(String imei,String label_mac,String time_begin, HttpServletRequest request) {
        try {
        } catch (Exception e) {
            e.printStackTrace();
        }
            String address= request.getParameter("address");
            Double lat= Double.parseDouble(request.getParameter("lat"));
            Double lon= Double.parseDouble(request.getParameter("lon"));
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
            DevicePatientDevice deviceDO = devicePatientDeviceDos.get(0);
            BasePatientDO patientDO = patientDao.findById(deviceDO.getUser());
            DeviceSosLogDO logDO = new DeviceSosLogDO();
            logDO.setPatient(patientDO.getIdcard());
            logDO.setPatientName(patientDO.getName());
            logDO.setIdcard(patientDO.getIdcard());
            logDO.setCategoryCode(deviceDO.getCategoryCode());
            logDO.setDeviceSn(deviceDO.getDeviceSn());
            logDO.setCreateTime(new Date());
            if (deviceDO.getCategoryCode().equals("4")) {
                JSONObject position = gpsUtil.gcj02_To_Bd09(lat,lon);
                logDO.setSosAddress(address);
                logDO.setSosLat(position.getDouble("lat")+"");
                logDO.setSosLon(position.getDouble("lon")+"");
            }
            if (deviceDO.getCategoryCode().equals("7")) {
                logDO.setSosAddress(deviceDO.getSosAddress());
                Map<String, String> json = null;
                if (StringUtils.isNotBlank(deviceDO.getSosAddress())) {
                    json = LatitudeUtils.getGeocoderLatitude(deviceDO.getSosAddress().replace("G.", "").replace("(糖友网)", "").replace("(高友网)", ""));
                }
                if (json != null) {
                    logDO.setSosLat(json.get("lat").toString());
                    logDO.setSosLon(json.get("lat").toString());
                }
            }
            //发送紧急救助
            String sql =" select Distinct item.org_code,item.org_name\n" +
                    "from base_service_package_sign_record sr INNER JOIN base_service_package_record pr\n" +
                    "on sr.id = pr.sign_id and sr.status=1 INNER JOIN base_service_package_item item on pr.service_package_id = item.service_package_id and item.del=1 \n" +
                    "where item.code='emergencyAssistance' and sr.patient='"+patientDO.getId()+"'";
            List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
            if (sqlResult.size()>0){
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("serveAddress",logDO.getSosAddress());
                jsonObject.put("serveLon",logDO.getSosLon());
                jsonObject.put("serveLat",logDO.getSosLat());
                jsonObject.put("orgCode",sqlResult.get(0).get("org_code").toString());
                jsonObject.put("orgName",sqlResult.get(0).get("org_name").toString());
                jsonObject.put("patient",logDO.getPatient());
                jsonObject.put("patientName",logDO.getPatientName());
                String url = cloudCareUrl+"cloudCare/noLogin/emergency_assistance/newOrder";
                Map map = new HashMap<String, String>();
                map.put("patientId", logDO.getPatient());
                map.put("jsonData", jsonObject.toJSONString());
                String content = com.alibaba.fastjson.JSONObject.toJSONString(map);
                String postParams = AesEncryptUtils.agEncrypt(content);
                String response = httpClientUtil.postBodyRawForm(url,postParams);
                JSONObject result = com.alibaba.fastjson.JSONObject.parseObject(response);
                JSONObject jsonObjectData =JSONObject.parseObject(AesEncryptUtils.agDecrypt(result.getString("data")));
                logDO.setSosSendStatus(jsonObjectData.getInteger("status").toString());
                logDO.setSosSendMessage(jsonObjectData.getString("message"));
            }
            sosLogDao.save(logDO);
        }catch(Exception e){
                e.printStackTrace();
            }
    }
    /**
@ -195,7 +269,9 @@ public class DeviceService {
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
                    DevicePatientHealthIndex patientHealthIndex = new DevicePatientHealthIndex();
                    patientHealthIndex.setName(patientDO.getName());
                    patientHealthIndex.setDeviceSn(imei);
                    patientHealthIndex.setUser(devicePatientDevice.getUser());
                    patientHealthIndex.setIdcard(devicePatientDevice.getUserIdcard());
@ -208,6 +284,10 @@ public class DeviceService {
                    if (heartrate>=theshold_heartrate_h||heartrate<=theshold_heartrate_l){
                        patientHealthIndex.setStatus(1);
                    }
                    else {
                        patientHealthIndex.setStatus(0);
                    }
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                }
            }
@ -233,7 +313,9 @@ public class DeviceService {
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
                    DevicePatientHealthIndex patientHealthIndex = new DevicePatientHealthIndex();
                    patientHealthIndex.setName(patientDO.getName());
                    patientHealthIndex.setDeviceSn(imei);
                    patientHealthIndex.setUser(devicePatientDevice.getUser());
                    patientHealthIndex.setIdcard(devicePatientDevice.getUserIdcard());
@ -247,6 +329,10 @@ public class DeviceService {
                    if (sbp>=sbp_h||dbp<=dbp_l){
                        patientHealthIndex.setStatus(1);
                    }
                    else {
                        patientHealthIndex.setStatus(0);
                    }
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                }
            }
@ -278,29 +364,6 @@ public class DeviceService {
        }
    }
    /**
     * 柏颐sos 接收
     * @param imei  15位设备唯一序号
     * @param time_begin  发生时间YYYY-MM-DD HH:mm:SS
     * @param heartrate   心率
     * @param city  城市
     * @param address  地址
     * @param lon  经度
     * @param lat  纬度
     * @param type  类型   0:Gps定位; 1:基站定位
     */
    @Async
    public void bySos(String imei,String time_begin,int heartrate,String city,String address,double lon,double lat,String type) {
        try {
            if(StringUtils.isNotBlank(imei)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐步数数据接收
     * @param imei 15位设备唯一序号
@ -340,42 +403,4 @@ public class DeviceService {
        }
    }
    /**
     * 柏颐开关机数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param type 开/关机类型  0:开机; 1:关机; 2:电量上报; 3:低电通知
     * @param remaining_power 剩余电量(%)
     */
    @Async
    public void bySwitch(String imei,String time_begin,String type,int remaining_power) {
        try {
            if(StringUtils.isNotBlank(imei)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐数据消息通知
     * @param type  type=1 SOS,type=2 fall,type=3 new 新成员加入 ,type=4 电子围栏触发, type=5 设备低电,type=6 环境音
     * @param deviceid 15位设备唯一序号
     * @param communityid 机构ID
     * @param url 环境音下载地址 只有环境音(type=6)为必填,其他type都为非必填
     * @param name 设备名称
     */
    @Async
    public void byPushData(int type,String deviceid,String communityid,String url,String name) {
        try {
            if(StringUtils.isNotBlank(deviceid)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

+ 6 - 0
svr/svr-cloud-device/src/main/resources/application.yml

@ -168,6 +168,9 @@ express:
baiduApi:
  AK: 0vjnCSReegE7A47a941ohjv9a07ONiMC
  url: http://api.map.baidu.com/
cloudCare:
  url: http://ehr.yihu.com/hlwyy/cloudCare/
---
spring:
  profiles: jwtest
@ -264,6 +267,9 @@ express:
baiduApi:
  AK: 0vjnCSReegE7A47a941ohjv9a07ONiMC
  url: http://api.map.baidu.com/
cloudCare:
  url: http://ehr.yihu.com/hlwyy/cloudCare/
---
spring:
  profiles: jwprod