فهرست منبع

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

wangjun 3 سال پیش
والد
کامیت
b4e8fa6aa1
100فایلهای تغییر یافته به همراه4005 افزوده شده و 336 حذف شده
  1. 6 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDao.java
  2. 115 0
      business/es-service/src/main/java/com/yihu/jw/es/service/yqfk/YqfkService.java
  3. 144 0
      common/common-entity/sql记录
  4. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  5. 0 20
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageItemDO.java
  6. 55 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BasePatientOutBed.java
  7. 199 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepDeviceReport.java
  8. 81 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepNightRecord.java
  9. 77 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepPlan.java
  10. 191 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepPlanDetail.java
  11. 46 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseYxDeviceIndex.java
  12. 30 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceDetail.java
  13. 65 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceHealthIndex.java
  14. 47 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientDevice.java
  15. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientHealthIndex.java
  16. 37 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/HvDeviceRecord.java
  17. 130 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/HvDeviceSosLog.java
  18. 12 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareOrderDO.java
  19. 10 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java
  20. 6 0
      common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java
  21. 1 1
      common/common-util/src/main/java/com/yihu/jw/util/common/LatitudeUtils.java
  22. 20 1
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  23. 11 0
      gateway/ag-basic/src/main/resources/application.yml
  24. 17 0
      gateway/ag-basic/src/main/resources/bootstrap.yml
  25. 9 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/model/WlyyUserSimple.java
  26. 3 0
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  27. 67 1
      server/svr-authentication/src/main/resources/application.yml
  28. 18 2
      server/svr-authentication/src/main/resources/bootstrap.yml
  29. 30 0
      server/svr-configuration/src/main/resources/bootstrap.yml
  30. 0 2
      svr/svr-base/src/main/java/com/yihu/jw/base/dao/servicePackage/ServicePackageItemDao.java
  31. 4 4
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageEndpoint.java
  32. 6 11
      svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java
  33. 48 1
      svr/svr-base/src/main/resources/application.yml
  34. 9 1
      svr/svr-base/src/main/resources/bootstrap.yml
  35. 9 0
      svr/svr-cloud-care/pom.xml
  36. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/SvrCloudCareApplication.java
  37. 15 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java
  38. 14 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BasePatientOutBedDao.java
  39. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BaseSleepDeviceReportDao.java
  40. 25 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BaseSleepNightRecordDao.java
  41. 21 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BaseSleepPlanDao.java
  42. 24 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BaseSleepPlanDetailDao.java
  43. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DeviceDetailDao.java
  44. 4 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/DevicePatientHealthIndexDao.java
  45. 10 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java
  46. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/label/WlyyPatientLabelDao.java
  47. 0 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/sign/ServicePackageItemDao.java
  48. 4 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/team/BaseTeamMemberDao.java
  49. 18 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/BaseController.java
  50. 1 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/assistance/EmergencyAssistanceEndpoint.java
  51. 31 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorHealthController.java
  52. 150 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java
  53. 111 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  54. 12 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/YsDeviceController.java
  55. 9 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorBirthdayWishesEndpoint.java
  56. 6 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java
  57. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java
  58. 23 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java
  59. 59 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  60. 16 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  61. 92 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java
  62. 11 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  63. 5 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/team/TeamEndpoint.java
  64. 23 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  65. 18 21
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/birthday/BirthdayWishesService.java
  66. 6 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java
  67. 10 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java
  68. 226 28
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  69. 26 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientHealthIndexService.java
  70. 5 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  71. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java
  72. 6 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java
  73. 8 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  74. 22 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/BaseServiceNewsService.java
  75. 18 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/DoctorMessageService.java
  76. 53 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  77. 9 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/OnlineContactService.java
  78. 397 94
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  79. 2 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java
  80. 12 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java
  81. 124 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  82. 273 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java
  83. 68 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  84. 4 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/team/BaseTeamService.java
  85. 3 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/patient/PatientNoLoginService.java
  86. 250 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/ArtemisPostTest.java
  87. 60 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/Tools.java
  88. 9 16
      svr/svr-cloud-device/pom.xml
  89. 21 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/config/WebSocketConfig.java
  90. 15 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/BasePatientOutBedDao.java
  91. 12 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/BaseSleepDeviceReportDao.java
  92. 23 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/BaseSleepNightRecordDao.java
  93. 19 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/BaseSleepPlanDao.java
  94. 16 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/BaseSleepPlanDetailDao.java
  95. 16 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/BaseYxDeviceIndexDao.java
  96. 3 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceDetailDao.java
  97. 16 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/DeviceHealthIndexDao.java
  98. 22 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/HvDeviceRecordDao.java
  99. 16 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/HvDeviceSosLogDao.java
  100. 0 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java

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

@ -34,6 +34,12 @@ public interface BasePatientDao extends PagingAndSortingRepository<BasePatientDO
    @Query("from BasePatientDO where mobile = ?1")
    List<BasePatientDO> findByMobile(String mobile);
    @Query("from BasePatientDO where del = 1")
    List<BasePatientDO> findAllByDel();
    @Query("from BasePatientDO where del = 1 and id = ?1")
    List<BasePatientDO> findAllByDelAndId(String user);
    @Query("from BasePatientDO p where p.mobile = ?1 and p.del=?2")
    List<BasePatientDO> findByMobileAndDel(String mobile,String del);
    

+ 115 - 0
business/es-service/src/main/java/com/yihu/jw/es/service/yqfk/YqfkService.java

@ -0,0 +1,115 @@
package com.yihu.jw.es.service.yqfk;
import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 *
 * 卫建局疫情防控
 *
 * Created by wangzhinan on 2020/08/21
 */
@Service
public class YqfkService {
    private Logger logger = LoggerFactory.getLogger(YqfkService.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 疫情防控头部总数统计
     * @param startTime
     * @param endTime
     * @return
     */
    public JSONObject yqfkStatisticsHead(String startTime,String endTime){
        JSONObject object = new JSONObject();
        String sql = "select COUNT(1) as confirmedTotal from MID_CDC_CASE_INFO where ";
        object.put("confirmed","");//现有确诊
        object.put("newHome","");//新增本土
        object.put("newAsymptomatic","");//新增无症状;
        object.put("confirmedTotal","");//累计确诊
        object.put("cureTotal","");//累计治愈
        object.put("deathTotal","");//累计死亡
        return object;
    }
    public JSONObject yqfkStatisticsTail(String startTime,String endTime){
        JSONObject object = new JSONObject();
        JSONObject MjObject = new JSONObject();//在厦密接
        MjObject.put("zyTotal","");//正转运
        MjObject.put("jdTotal","");//在酒店/已采核酸
        MjObject.put("dlsTotal","");//待落实
        MjObject.put("total","");//总计
        JSONObject CmObject = new JSONObject();//在厦次密
        CmObject.put("zyTotal","");//正转运
        CmObject.put("jdTotal","");//在酒店/已采核酸
        CmObject.put("dlsTotal","");//待落实
        CmObject.put("total","");//总计
        JSONObject ybObject = new JSONObject();//在厦一般接触者
        ybObject.put("zyTotal","");//正转运
        ybObject.put("jdTotal","");//在酒店/已采核酸
        ybObject.put("dlsTotal","");//待落实
        ybObject.put("total","");//总计
        object.put("MjObject",MjObject);
        object.put("CmObject", CmObject);
        object.put("ybObject",ybObject);
        return object;
    }
    public  List<Map<String, Object>> confirmedList(){
        String confirmedListSql = "select PATIENT_ID as \"patientId\",PATIENT_NAME as \"patientName\",PATIENT_SEX as \"patientSex\",PATIENT_AGE as \"patientAge\",DIAG_TIME as \"diagTime\" from MID_CDC_CASE_INFO ";
        List<Map<String, Object>> confirmedList = jdbcTemplate.queryForList(confirmedListSql);
        if (confirmedList!=null&&confirmedList.size()!=0){
            for (Map<String,Object> map:confirmedList){
                String patientId = map.get("patientId").toString();
                //密接人数计算
                String mjTotalSql = "select count(1) as total from MID_CDC_CCC_INFO where PATIENT_ID='"+patientId+"'";
                List<Map<String, Object>> mjList = jdbcTemplate.queryForList(mjTotalSql);
                Integer mjTotal = 0;//密接人数
                if (mjList!=null&&mjList.size()!=0){
                    mjTotal = Integer.parseInt(mjList.get(0).get("total").toString());
                }
                map.put("mjTotal",mjTotal);
                //次密接人数计算
                String cmjTotalSql = "select count(1) as total from MID_CDC_CCC_SED_INFO where PATIENT_ID='"+patientId+"'";
                List<Map<String, Object>> cmjList = jdbcTemplate.queryForList(cmjTotalSql);
                Integer cmjTotal = 0;//密接人数
                if (cmjList!=null&&cmjList.size()!=0){
                    cmjTotal = Integer.parseInt(cmjList.get(0).get("total").toString());
                }
                map.put("cmjTotal",cmjTotal);
                //一般接触人数计算
                String ybmjTotalSql = "select count(1) as total from MID_KEYNOTE_CROWD_INFO where PATIENT_ID='"+patientId+"'";
                List<Map<String, Object>> ybmjList = jdbcTemplate.queryForList(ybmjTotalSql);
                Integer ybmjTotal = 0;//密接人数
                if (ybmjList!=null&&ybmjList.size()!=0){
                    ybmjTotal = Integer.parseInt(ybmjList.get(0).get("total").toString());
                }
                map.put("ybmjTotal",ybmjTotal);
            }
        }
        return confirmedList;
    }
}

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

@ -1244,3 +1244,147 @@ ALTER table base.base_patient_sos_contacts add column phone_seqid int(2) default
ALTER table base_emergency_assistance_order add column device_sn varchar(50) DEFAULT NULL COMMENT '设备触发工单时有该字段';
ALTER table base_security_monitoring_order add column device_sn varchar(50) DEFAULT NULL COMMENT '设备触发工单时有该字段';
ALTER table base_service_package_record add column team_code varchar(50) DEFAULT NULL COMMENT '团队id';
--2021-08-12
ALTER table wlyy_patient_device add column online_status TINYINT(4) default '0' COMMENT '设备在线状态';
CREATE TABLE base.`base_sleep_device` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `patient` varchar(50) DEFAULT NULL COMMENT '居民id',
  `device_sn` varchar(50) DEFAULT NULL COMMENT '睡眠带sn',
  `falla_sleep` varchar(50) DEFAULT NULL COMMENT '入睡时长 分钟',
  `sleep_time` varchar(50) DEFAULT NULL COMMENT '睡眠时长 分钟',
  `rest_time` varchar(50) DEFAULT NULL COMMENT '休息时长 分钟',
  `awake_time` varchar(50) DEFAULT NULL COMMENT '清醒时长 分钟',
  `light_time` varchar(50) DEFAULT NULL COMMENT '浅睡时长 分钟',
  `rem_time` varchar(50) DEFAULT NULL COMMENT 'rem时长 分钟',
  `deep_time` varchar(50) DEFAULT NULL COMMENT '深睡时长 分钟',
  `bucket` varchar(50) DEFAULT NULL COMMENT '睡眠时段',
  `avghr` varchar(50) DEFAULT NULL COMMENT '平均心率',
  `avgbr` varchar(50) DEFAULT NULL COMMENT '平均呼吸率',
  `awake_per` varchar(50) DEFAULT NULL COMMENT '清醒百分比',
  `rem_per` varchar(50) DEFAULT NULL COMMENT 'rem百分比',
  `light_per` varchar(50) DEFAULT NULL COMMENT '浅睡百分比',
  `deep_per` varchar(50) DEFAULT NULL COMMENT '深睡百分比',
  `efficiency` varchar(50) DEFAULT NULL COMMENT '睡眠效率',
  `score` varchar(50) DEFAULT NULL COMMENT '睡眠评分 <=0无睡眠数据,<60待改善,<70一般,<85良好 其他,非常好',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '产生日期',
  `del` int(1) DEFAULT NULL COMMENT '是否有效 1有效 0无效',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='爱牵挂睡眠带数据';
-- 2021-08-13
alter table base_service_package_item drop  COLUMN team_code;
alter table base_service_package_item drop  COLUMN team_name;
-- 20210817 lb
CREATE TABLE `base_sleep_night_record` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `patient` varchar(50) DEFAULT NULL COMMENT '居民id',
  `device_sn` varchar(50) DEFAULT NULL COMMENT '睡眠带sn',
  `status` varchar(50) DEFAULT NULL COMMENT '是否回床,(0/-1)否 1是,-1触发警报',
	 out_time varchar(50) DEFAULT null comment '离床时长',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建日期 即起床时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新日期',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='睡眠带起夜记录数据';
-- 20210818 lb
CREATE TABLE base_sleep_patient_out_bed (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `patient` varchar(50) DEFAULT NULL COMMENT '居民id',
  `device_sn` varchar(50) DEFAULT NULL COMMENT '睡眠带sn',
  `status` varchar(50) DEFAULT NULL COMMENT '在床状态0离床1在床',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建日期 即起床时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='患者离床时间';
-- 20210819 skj 导入居民签约数据 (未执行)
CREATE TABLE `base_patient_add` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键id',
  `idcard` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL COMMENT '身份证号',
  `mobile` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  `doc_mobile` varchar(50) NOT NULL COMMENT '医生手机号',
  `start` varchar(255) DEFAULT NULL COMMENT '签约开始时间',
  `end` varchar(255) DEFAULT NULL COMMENT '签约结束时间',
  `service_package` varchar(255) DEFAULT NULL COMMENT '服务包',
  `team_code` varchar(255) DEFAULT NULL COMMENT '签约团队code',
  `del` int(1) DEFAULT '1' COMMENT '1有效  0失效',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- 2021-08-23 气感烟感设备
CREATE TABLE `base_device_health_index` (
  `id` varchar(50) NOT NULL,
  `device_sn` varchar(50) DEFAULT NULL COMMENT '设备sn',
  `device_type` varchar(4) DEFAULT NULL COMMENT '设备类型 1气感 2烟感',
  `value` varchar(20) DEFAULT NULL COMMENT '测量值',
  `unit` varchar(20) DEFAULT NULL COMMENT '单位',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `record_time` varchar(50) DEFAULT NULL COMMENT '记录时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='烟感气感实时数据';
CREATE TABLE `base_hvdevice_record` (
  `id` varchar(50) NOT NULL,
  `device_id` varchar(50) DEFAULT NULL COMMENT '海康平台设备id',
  `device_sn` varchar(50) DEFAULT NULL COMMENT '设备sn',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='海康烟感气感设备记录表';
CREATE TABLE `base_hvdevice_sos_log` (
  `id` varchar(50) NOT NULL,
  `resource_id` varchar(50) DEFAULT NULL,
  `resource_serial` varchar(50) DEFAULT NULL,
  `resource_name` varchar(50) DEFAULT NULL,
  `alarm_num` int(10) DEFAULT NULL,
  `alarm_time` varchar(50) DEFAULT NULL,
  `monitor_value` varchar(50) DEFAULT NULL,
  `alarm_type` varchar(20) DEFAULT NULL,
  `system_type` varchar(20) DEFAULT NULL,
  `alarm_id` varchar(50) DEFAULT NULL,
  `resource_type` varchar(50) DEFAULT NULL,
  `location` varchar(500) DEFAULT NULL,
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='烟感气感设备报警日志记录表';
-- 20210819
alter table wlyy_devices add COLUMN device_type TINYINT(2) default null COMMENT '设备种类 0健康设备 1安防设备';
alter table wlyy_patient_device add COLUMN device_type TINYINT(2) default null COMMENT '设备种类 0健康设备 1安防设备';
-- 20210823
alter table base_sleep_night_record add COLUMN day varchar(50) DEFAULT NULL COMMENT '睡眠监控日期';
CREATE TABLE `base_sleep_plan_detail` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `patient` varchar(50) DEFAULT NULL COMMENT '居民id',
  `device_sn` varchar(50) DEFAULT NULL COMMENT '睡眠带sn',
  `day` varchar(50) DEFAULT NULL COMMENT '睡眠监控日期',
  `up_status` tinyint(2) DEFAULT NULL COMMENT '起床状态 0未起床 1起床',
  `up_time` timestamp NULL DEFAULT NULL COMMENT '起床时间',
  `siesta_status` tinyint(2) DEFAULT NULL COMMENT '午睡状态 0未入床 1已入床 2无午睡计划',
  `siesta_time_begin` timestamp NULL DEFAULT NULL COMMENT '午睡开始时间',
  `siesta_time_end` timestamp NULL DEFAULT NULL COMMENT '午睡结束时间',
  `siesta_long` varchar(10) DEFAULT NULL COMMENT '午睡时长 单位秒',
  `in_status` varchar(10) DEFAULT NULL COMMENT '睡觉状态 0未入床 1已入床',
  `in_time_begin` timestamp null DEFAULT NULL COMMENT '夜眠开始时间',
  `in_time_end` timestamp null DEFAULT NULL COMMENT '夜眠结束时间 ',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建日期',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新日期',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COMMENT='睡眠带监测计划详情';
-- 20210824
alter table base_security_monitoring_order add COLUMN warn_info varchar(3000) DEFAULT NULL COMMENT '触发工单时信息如 烟雾心率等';
-- 20210825
alter table wlyy_devices add COLUMN contact_status_time datetime DEFAULT NULL COMMENT '失联状态更新时间';
alter table wlyy_devices add COLUMN contact_status tinyint(2) DEFAULT NULL COMMENT '失联状态 1未失联 0失联';
-- 20210826
CREATE TABLE `base_yxdevice_index` (
  `id` varchar(50) NOT NULL,
  `sn` varchar(50) DEFAULT NULL COMMENT '设备sn码',
  `lat` varchar(50) DEFAULT NULL COMMENT '纬度',
  `lon` varchar(50) DEFAULT NULL COMMENT '经度',
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='云芯拐杖设备上传记录';

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -272,7 +272,7 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String medicareNumber;//医疗保险号
    private Integer archiveStatus;//档案状态【1.未管理 2.死亡 3.正常 4.高危】【必填】
    private Integer archiveType;// 档案类型 1老人 2新生儿
    private Integer archiveType;// 档案类型 1老人 2新生儿 3老人家属
    private String archiveStatusName;
    private String archiveTypeName;

+ 0 - 20
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageItemDO.java

@ -25,8 +25,6 @@ public class ServicePackageItemDO extends UuidIdentityEntity implements java.io.
    private String introduce;//'服务简介'
    private String del;//是否生效(1 生效,0 失效)
    private String delName;
    private String teamCode;//'服务团队code'
    private String teamName;//'服务团队名称'
    private String createTime;//
    private String dictId;//
    private String topicItem;//所属专题 security 安防专题
@ -120,24 +118,6 @@ public class ServicePackageItemDO extends UuidIdentityEntity implements java.io.
        this.del = del;
    }
    @Column(name = "team_code")
    public String getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(String teamCode) {
        this.teamCode = teamCode;
    }
    @Column(name = "team_name")
    public String getTeamName() {
        return teamName;
    }
    public void setTeamName(String teamName) {
        this.teamName = teamName;
    }
    @Column(name = "create_time")
    public String getCreateTime() {
        return createTime;

+ 55 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BasePatientOutBed.java

@ -0,0 +1,55 @@
package com.yihu.jw.entity.care.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Bing on 2021/8/18.
 */
@Entity
@Table(name="base_sleep_patient_out_bed")
public class BasePatientOutBed extends IdEntity {
    private String patient ;
    private String deviceSn;
    private Integer status;//是否回床 0否,1是
    private Date createTime;// 创建日期 即起床时间
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 199 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepDeviceReport.java

@ -0,0 +1,199 @@
package com.yihu.jw.entity.care.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Bing on 2021/8/12.
 * 睡眠带
 */
@Entity
@Table(name="base_sleep_device")
public class BaseSleepDeviceReport extends IdEntity {
    public String patient;
    public String deviceSN; //睡眠带MAC地址
    public String fallaSleep;   //入睡时长 (分钟)
    public String sleepTime;    //睡眠时长 (分钟)
    public String restTime;     //休息时长 (分钟)
    public String awakeTime;    //清醒时长 (分钟)
    public String lightTime;//浅睡时长 (分钟)
    public String remTime;  //rem时长  (分钟)
    public String deepTime; //深睡时长 (分钟)
    public String bucket;   //睡眠时段
    public String avghr;    //平均心率
    public String avgbr;    //平均呼吸率
    public String awakePer; //清醒百分比
    public String remPer;   //rem百分比
    public String lightPer; //浅睡百分比
    public String deepPer;  //深睡百分比
    public String efficiency;   //睡眠效率
    public String score;    //睡眠评分
    public Date createTime; // //日期
    public Integer del; //是否有效 1有效 0无效
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getDeviceSN() {
        return deviceSN;
    }
    public void setDeviceSN(String deviceSN) {
        this.deviceSN = deviceSN;
    }
    public String getFallaSleep() {
        return fallaSleep;
    }
    public void setFallaSleep(String fallaSleep) {
        this.fallaSleep = fallaSleep;
    }
    public String getSleepTime() {
        return sleepTime;
    }
    public void setSleepTime(String sleepTime) {
        this.sleepTime = sleepTime;
    }
    public String getRestTime() {
        return restTime;
    }
    public void setRestTime(String restTime) {
        this.restTime = restTime;
    }
    public String getAwakeTime() {
        return awakeTime;
    }
    public void setAwakeTime(String awakeTime) {
        this.awakeTime = awakeTime;
    }
    public String getLightTime() {
        return lightTime;
    }
    public void setLightTime(String lightTime) {
        this.lightTime = lightTime;
    }
    public String getRemTime() {
        return remTime;
    }
    public void setRemTime(String remTime) {
        this.remTime = remTime;
    }
    public String getDeepTime() {
        return deepTime;
    }
    public void setDeepTime(String deepTime) {
        this.deepTime = deepTime;
    }
    public String getBucket() {
        return bucket;
    }
    public void setBucket(String bucket) {
        this.bucket = bucket;
    }
    public String getAvghr() {
        return avghr;
    }
    public void setAvghr(String avghr) {
        this.avghr = avghr;
    }
    public String getAvgbr() {
        return avgbr;
    }
    public void setAvgbr(String avgbr) {
        this.avgbr = avgbr;
    }
    public String getAwakePer() {
        return awakePer;
    }
    public void setAwakePer(String awakePer) {
        this.awakePer = awakePer;
    }
    public String getRemPer() {
        return remPer;
    }
    public void setRemPer(String remPer) {
        this.remPer = remPer;
    }
    public String getLightPer() {
        return lightPer;
    }
    public void setLightPer(String lightPer) {
        this.lightPer = lightPer;
    }
    public String getDeepPer() {
        return deepPer;
    }
    public void setDeepPer(String deepPer) {
        this.deepPer = deepPer;
    }
    public String getEfficiency() {
        return efficiency;
    }
    public void setEfficiency(String efficiency) {
        this.efficiency = efficiency;
    }
    public String getScore() {
        return score;
    }
    public void setScore(String score) {
        this.score = score;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 81 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepNightRecord.java

@ -0,0 +1,81 @@
package com.yihu.jw.entity.care.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by Bing on 2021/8/17.
 */
@Entity
@Table(name="base_sleep_night_record")
public class BaseSleepNightRecord extends IdEntity {
    private String patient ;
    private String deviceSn;
    private String outTime;//离床时长 秒
    private Integer status;//是否回床 -1否 0否,1是
    private String day;//监控日期
    private Date createTime;// 创建日期 即起床时间
    private Date updateTime;// 更新日期
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getOutTime() {
        return outTime;
    }
    public void setOutTime(String outTime) {
        this.outTime = outTime;
    }
    public Integer getStatus() {
        return status;
    }
    public void setStatus(Integer status) {
        this.status = status;
    }
    public String getDay() {
        return day;
    }
    public void setDay(String day) {
        this.day = day;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}

+ 77 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepPlan.java

@ -0,0 +1,77 @@
package com.yihu.jw.entity.care.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
/***
 * @ClassName: BaseSleepPlan
 * @Description:    睡眠带监测计划
 * @Auther: shi kejing
 * @Date: 2021/8/23 17:17
 */
@Entity
@Table(name="base_sleep_plan")
public class BaseSleepPlan extends IdEntity {
    private String patient;
    private String deviceSn;
    private String getUpTime;
    private String napTime;
    private String nightRestTime;
    private Date createTime;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getGetUpTime() {
        return getUpTime;
    }
    public void setGetUpTime(String getUpTime) {
        this.getUpTime = getUpTime;
    }
    public String getNapTime() {
        return napTime;
    }
    public void setNapTime(String napTime) {
        this.napTime = napTime;
    }
    public String getNightRestTime() {
        return nightRestTime;
    }
    public void setNightRestTime(String nightRestTime) {
        this.nightRestTime = nightRestTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
}

+ 191 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepPlanDetail.java

@ -0,0 +1,191 @@
package com.yihu.jw.entity.care.device;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
import java.util.List;
/**
 * Created by Bing on 2021/8/23.
 */
@Entity
@Table(name="base_sleep_plan_detail")
public class BaseSleepPlanDetail extends IdEntity {
    private String  patient;
    private String  deviceSn;
    private String  day; //睡眠监控日期
    private Integer  upStatus; //起床状态 0起床 1未起床
    private Date  upTime; //起床时间
    private Integer  siestaStatus; //午睡状态 0未上床 1已上床
    private Date  siestaTimeBegin; //午睡开始时间
    private Date  siestaTimeEnd;  //午睡结束时间
    private String  siestaLong; //午睡时长 单位秒
    private Integer  inStatus; //睡觉状态 0未上床 1已上床
    private Date  inTimeBegin; //夜眠开始时间
    private Date  inTimeEnd; //夜眠结束时间
    private Date createTime;
    private Date  updateTime;
    private List<BaseSleepNightRecord> sleepNightRecordList;
    private String heartRate;
    private String breath;
    private Integer bedStatus; //0未在床 1在床
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getDay() {
        return day;
    }
    public void setDay(String day) {
        this.day = day;
    }
    public Integer getUpStatus() {
        return upStatus;
    }
    public void setUpStatus(Integer upStatus) {
        this.upStatus = upStatus;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpTime() {
        return upTime;
    }
    public void setUpTime(Date upTime) {
        this.upTime = upTime;
    }
    public Integer getSiestaStatus() {
        return siestaStatus;
    }
    public void setSiestaStatus(Integer siestaStatus) {
        this.siestaStatus = siestaStatus;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getSiestaTimeBegin() {
        return siestaTimeBegin;
    }
    public void setSiestaTimeBegin(Date siestaTimeBegin) {
        this.siestaTimeBegin = siestaTimeBegin;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getSiestaTimeEnd() {
        return siestaTimeEnd;
    }
    public void setSiestaTimeEnd(Date siestaTimeEnd) {
        this.siestaTimeEnd = siestaTimeEnd;
    }
    public String getSiestaLong() {
        return siestaLong;
    }
    public void setSiestaLong(String siestaLong) {
        this.siestaLong = siestaLong;
    }
    public Integer getInStatus() {
        return inStatus;
    }
    public void setInStatus(Integer inStatus) {
        this.inStatus = inStatus;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getInTimeBegin() {
        return inTimeBegin;
    }
    public void setInTimeBegin(Date inTimeBegin) {
        this.inTimeBegin = inTimeBegin;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getInTimeEnd() {
        return inTimeEnd;
    }
    public void setInTimeEnd(Date inTimeEnd) {
        this.inTimeEnd = inTimeEnd;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    @Transient
    public List<BaseSleepNightRecord> getSleepNightRecordList() {
        return sleepNightRecordList;
    }
    public void setSleepNightRecordList(List<BaseSleepNightRecord> sleepNightRecordList) {
        this.sleepNightRecordList = sleepNightRecordList;
    }
    @Transient
    public String getHeartRate() {
        return heartRate;
    }
    public void setHeartRate(String heartRate) {
        this.heartRate = heartRate;
    }
    @Transient
    public String getBreath() {
        return breath;
    }
    public void setBreath(String breath) {
        this.breath = breath;
    }
    @Transient
    public Integer getBedStatus() {
        return bedStatus;
    }
    public void setBedStatus(Integer bedStatus) {
        this.bedStatus = bedStatus;
    }
}

+ 46 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseYxDeviceIndex.java

@ -0,0 +1,46 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 * 云芯拐杖设备上传记录
 * @Author: yeshijie
 * @Date: 2021/8/26
 * @Description:
 */
@Entity
@Table(name = "base_yxdevice_index")
public class BaseYxDeviceIndex extends UuidIdentityEntityWithCreateTime{
    private String sn;//设备sn码
    private String lat;//纬度
    private String lon;//经度
    public String getSn() {
        return sn;
    }
    public void setSn(String sn) {
        this.sn = sn;
    }
    public String getLat() {
        return lat;
    }
    public void setLat(String lat) {
        this.lat = lat;
    }
    public String getLon() {
        return lon;
    }
    public void setLon(String lon) {
        this.lon = lon;
    }
}

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

@ -43,11 +43,14 @@ public class DeviceDetail extends IdEntity {
    private Integer isBinding;//是否绑定(0否 1 绑定单端口 2 绑定双端口)
    private String bindingCount;//绑定次数({"1":"0", "2":"0"})
    private Date grantTime;//发放时间
    private Integer deviceType;
    //1.5.0版本新增字段
    private String grantDoctor;//发放医生code
    private String grantDoctorName;//发放医生姓名
    private Integer contactStatus;// 失联状态 1未失联 0失联
    private Date contactStatusTime;//失联状态更新时间
    /** default constructor */
    public DeviceDetail() {
    }
@ -314,4 +317,31 @@ public class DeviceDetail extends IdEntity {
    public void setGrantDoctorName(String grantDoctorName) {
        this.grantDoctorName = grantDoctorName;
    }
    @Column(name = "device_type")
    public Integer getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(Integer deviceType) {
        this.deviceType = deviceType;
    }
    @Column(name = "contact_status")
    public Integer getContactStatus() {
        return contactStatus;
    }
    public void setContactStatus(Integer contactStatus) {
        this.contactStatus = contactStatus;
    }
    @Column(name = "contact_status_time")
    public Date getContactStatusTime() {
        return contactStatusTime;
    }
    public void setContactStatusTime(Date contactStatusTime) {
        this.contactStatusTime = contactStatusTime;
    }
}

+ 65 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DeviceHealthIndex.java

@ -0,0 +1,65 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 * base_device_health_index
 * 烟感气感实时数据
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
@Entity
@Table(name = "base_device_health_index")
public class DeviceHealthIndex extends UuidIdentityEntityWithCreateTime{
    private String deviceSn;//设备sn
    private String deviceType;//设备类型 1气感 2烟感
    private String value;//测量值
    private String unit;//单位
    private String recordTime;//记录时间
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(String deviceType) {
        this.deviceType = deviceType;
    }
    public String getValue() {
        return value;
    }
    public void setValue(String value) {
        this.value = value;
    }
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public String getRecordTime() {
        return recordTime;
    }
    public void setRecordTime(String recordTime) {
        this.recordTime = recordTime;
    }
}

+ 47 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientDevice.java

@ -21,7 +21,7 @@ public class DevicePatientDevice extends IdEntity {
    private String deviceName;
    // 用户code
    private String user;
    // 设备类型标识 1血糖仪,2.血压计,3药盒,4智能手表,7 = 居家报警器,12 监控器
    // 设备类型标识 1血糖仪,2.血压计,3药盒,4智能手表,7 = 居家报警器,12 监控器 13 睡眠带 14气感报警器 15烟感报警器
    private String categoryCode;
    // 用户类型标准 -1代表单用户
    private String userType;
@ -68,6 +68,8 @@ public class DevicePatientDevice extends IdEntity {
    //设备类型为报警器时,需要填写投放地址 category_code = 7
    private String sosAddress;
    private Integer onlineStatus;// 0不在线 1在线
  //========================非表字段======================
    //患者居住地址
    private String address;
@ -76,6 +78,18 @@ public class DevicePatientDevice extends IdEntity {
     */
    private String deviceImgUrl;
    private Integer deviceType;//设备种类 0健康设备 1安防设备
    /**
     * wifi对应的设备
     */
    private String iotDeviceSn;
    /**
     * 智能拐杖对应的围栏
     */
    private String safeAreaGz;
    @Column(name = "device_id")
    public Long getDeviceId() {
        return deviceId;
@ -318,4 +332,36 @@ public class DevicePatientDevice extends IdEntity {
    public void setDeviceImgUrl(String deviceImgUrl) {
        this.deviceImgUrl = deviceImgUrl;
    }
    public Integer getOnlineStatus() {
        return onlineStatus;
    }
    public void setOnlineStatus(Integer onlineStatus) {
        this.onlineStatus = onlineStatus;
    }
    public Integer getDeviceType() {
        return deviceType;
    }
    public void setDeviceType(Integer deviceType) {
        this.deviceType = deviceType;
    }
    public String getIotDeviceSn() {
        return iotDeviceSn;
    }
    public void setIotDeviceSn(String iotDeviceSn) {
        this.iotDeviceSn = iotDeviceSn;
    }
    public String getSafeAreaGz() {
        return safeAreaGz;
    }
    public void setSafeAreaGz(String safeAreaGz) {
        this.safeAreaGz = safeAreaGz;
    }
}

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

@ -51,6 +51,7 @@ public class DevicePatientHealthIndex extends IdEntity {
	//设备编号
	private String deviceSn;
	private Integer manageResult;//0未干预 1异常有效干预 2异常无效干预
	private Integer status;//状态:0为标准,1为异常
	private String name;//居民姓名
	private String hospital;//医院
@ -195,6 +196,14 @@ public class DevicePatientHealthIndex extends IdEntity {
		this.deviceSn = deviceSn;
	}
	public Integer getManageResult() {
		return manageResult;
	}
	public void setManageResult(Integer manageResult) {
		this.manageResult = manageResult;
	}
	public Integer getStatus() {
		return status;
	}

+ 37 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/HvDeviceRecord.java

@ -0,0 +1,37 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 * '海康烟感气感设备记录表'
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
@Entity
@Table(name = "base_hvdevice_record")
public class HvDeviceRecord extends UuidIdentityEntity {
    private String deviceId;//海康平台设备id
    private String deviceSn;//设备sn
    public String getDeviceId() {
        return deviceId;
    }
    public void setDeviceId(String deviceId) {
        this.deviceId = deviceId;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
}

+ 130 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/HvDeviceSosLog.java

@ -0,0 +1,130 @@
package com.yihu.jw.entity.care.device;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 * 烟感气感设备报警日志记录表
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
@Entity
@Table(name = "base_hvdevice_sos_log")
public class HvDeviceSosLog extends UuidIdentityEntityWithCreateTime{
    private String resourceID;
    private String resourceSerial;
    private String resourceName;
    private Integer alarmNum;
    private String alarmTime;
    private String monitorValue;
    private String alarmType;
    private String systemType;
    private String alarmID;
    private String resourceType;
    private String location;
    @Column(name = "resource_id")
    public String getResourceID() {
        return resourceID;
    }
    public void setResourceID(String resourceID) {
        this.resourceID = resourceID;
    }
    @Column(name = "resource_serial")
    public String getResourceSerial() {
        return resourceSerial;
    }
    public void setResourceSerial(String resourceSerial) {
        this.resourceSerial = resourceSerial;
    }
    @Column(name = "resource_name")
    public String getResourceName() {
        return resourceName;
    }
    public void setResourceName(String resourceName) {
        this.resourceName = resourceName;
    }
    @Column(name = "alarm_num")
    public Integer getAlarmNum() {
        return alarmNum;
    }
    public void setAlarmNum(Integer alarmNum) {
        this.alarmNum = alarmNum;
    }
    @Column(name = "alarm_time")
    public String getAlarmTime() {
        return alarmTime;
    }
    public void setAlarmTime(String alarmTime) {
        this.alarmTime = alarmTime;
    }
    @Column(name = "monitor_value")
    public String getMonitorValue() {
        return monitorValue;
    }
    public void setMonitorValue(String monitorValue) {
        this.monitorValue = monitorValue;
    }
    @Column(name = "alarm_type")
    public String getAlarmType() {
        return alarmType;
    }
    public void setAlarmType(String alarmType) {
        this.alarmType = alarmType;
    }
    @Column(name = "system_type")
    public String getSystemType() {
        return systemType;
    }
    public void setSystemType(String systemType) {
        this.systemType = systemType;
    }
    @Column(name = "alarm_id")
    public String getAlarmID() {
        return alarmID;
    }
    public void setAlarmID(String alarmID) {
        this.alarmID = alarmID;
    }
    @Column(name = "resource_type")
    public String getResourceType() {
        return resourceType;
    }
    public void setResourceType(String resourceType) {
        this.resourceType = resourceType;
    }
    @Column(name = "location")
    public String getLocation() {
        return location;
    }
    public void setLocation(String location) {
        this.location = location;
    }
}

+ 12 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/lifeCare/LifeCareOrderDO.java

@ -25,7 +25,7 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
        cancel(-1, "已取消"),
        waitForPay(0, "待支付"),
        waitForAccept(1, "待(医生)接单"),//待服务
        signIn(3, "已签到"),
        signIn(3, "已签到"),//conclusionTime有值 即登记服务小结
        complete(2,"已完成");
        private Integer type;
@ -331,6 +331,8 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
     */
    private Integer payStatus;//支付状态
    private String doctorPhone;//医生手机信息
    @Column(name = "number")
    public String getNumber() {
        return number;
@ -743,4 +745,13 @@ public class LifeCareOrderDO extends UuidIdentityEntityWithOperator {
    public void setPayStatus(Integer payStatus) {
        this.payStatus = payStatus;
    }
    @Transient
    public String getDoctorPhone() {
        return doctorPhone;
    }
    public void setDoctorPhone(String doctorPhone) {
        this.doctorPhone = doctorPhone;
    }
}

+ 10 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java

@ -318,11 +318,12 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    private String serviceStatus;//服务类型 1-预约项目 2-即时项目
    private String orderInfo;//工单详情 0-未推送 1-未确认 2-已确认
    private String doctorConfirmFinishImg;
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警 4监控器发起
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警 4监控器发起 5睡眠带 6气感报警器 7 烟感报警器
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String topicItem;//安防工单所属专题 base_system_dict_entry表service_item
    private String sceneImg;//现场照片
    private String deviceSn;//设备sn  设备触发是才有该字段值
    private String warnInfo;//触发工单时信息如 烟雾心率等
    /**
     * 医生确认医生结束服务时间
@ -736,4 +737,12 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
    public String getWarnInfo() {
        return warnInfo;
    }
    public void setWarnInfo(String warnInfo) {
        this.warnInfo = warnInfo;
    }
}

+ 6 - 0
common/common-request-mapping/src/main/java/com/yihu/jw/rm/hospital/BaseHospitalRequestMapping.java

@ -1494,6 +1494,12 @@ public class BaseHospitalRequestMapping {
        public static final String findDeptHomepageBanner = "/findDeptHomepageBanner";
        public static final String updateDeptHomepageBanner = "/updateDeptHomepageBanner";
        public static final String delDeptHomepageBanner = "/delDeptHomepageBanner";
        //疫情防控
        public static final String confirmedList = "/confirmedList";//确诊列表
        public static final String yqfkStatisticsHead = "/yqfkStatisticsHead";//头部确诊数量
        public static final String yqfkStatisticsTail = "/yqfkStatisticsTail";//密接数量统计
    }
    /**

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

@ -39,7 +39,7 @@ public class LatitudeUtils {
        try {
            //将地址转换成utf-8的16进制
            address = URLEncoder.encode(address, "UTF-8");
            URL tirc = new URL("http://api.map.baidu.com/geocoder/v2/?address="+ address +"&output=json&key="+ UUID.randomUUID().toString().replace("-","")+"&ak="+ak);
            URL tirc = new URL("https://api.map.baidu.com/geocoder/v2/?address="+ address +"&output=json&key="+ UUID.randomUUID().toString().replace("-","")+"&ak="+ak);
            in = new BufferedReader(new InputStreamReader(tirc.openStream(),"UTF-8"));

+ 20 - 1
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -79,7 +79,7 @@ public class DateUtil {
    }
    public static String dateToChineseTime(Date date) {
        SimpleDateFormat formatter =   new SimpleDateFormat( "yyyy年MM月dd日 hh:mm:ss", Locale.CHINA);
        SimpleDateFormat formatter =   new SimpleDateFormat( "yyyy年MM月dd日 HH:mm:ss", Locale.CHINA);
        return formatter.format(date);
    }
@ -1355,6 +1355,23 @@ public class DateUtil {
        return dateTime.substring(0, 10);
    }
    /**
     * 判断时间是否在某个区间内
     * @param time
     * @param begin
     * @param end
     * @return
     */
    public static boolean isInArea(Date time,Date begin,Date end) {
        Long beginTime = DateUtil.compareDateTime(time,begin);
        Long endTime = DateUtil.compareDateTime(time, end);
        if (beginTime > 0 && endTime < 0) {
            return true;
        } else {
            return false;
        }
    }
    /**
     *  返回 xx天XX小时XX分钟XX秒前
     * @param date1 当前时间
@ -1405,4 +1422,6 @@ public class DateUtil {
        return result.toString();
    }
}

+ 11 - 0
gateway/ag-basic/src/main/resources/application.yml

@ -271,3 +271,14 @@ spring:
  redis:
    host: 127.0.0.1 # Redis server host.
    port: 6380 # Redis server port.
---
spring:
  profiles: hcyyProd
  datasource:
     url: jdbc:mysql://192.168.120.103:6001/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
     username: wlyy
     password: 2oEq3Kf7@zjxl
  redis:
    host: 192.168.120.103 # Redis server host.
    port: 6007 # Redis server port.

+ 17 - 0
gateway/ag-basic/src/main/resources/bootstrap.yml

@ -141,6 +141,23 @@ spring:
---
spring:
  profiles: dsyy
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: hcyyProd
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://192.168.250.39:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: yqfk
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://127.0.0.1:1221}

+ 9 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/model/WlyyUserSimple.java

@ -46,6 +46,7 @@ WlyyUserSimple implements Serializable {
    private int expiresIn;
    private String state;
    private String openid; //患者openid
    private String archiveType;//档案类型 1老人 2新生儿
    public String getId() {
        return id;
@ -171,4 +172,12 @@ WlyyUserSimple implements Serializable {
    public void setOpenid(String openid) {
        this.openid = openid;
    }
    public String getArchiveType() {
        return archiveType;
    }
    public void setArchiveType(String archiveType) {
        this.archiveType = archiveType;
    }
}

+ 3 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -339,6 +339,9 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }
        WlyyUserSimple wlyyUserSimple = userDetailsService.authSuccess(parameters.get("username"));
        if ("pad".equals(parameters.get("clientType"))&&!("1".equals(wlyyUserSimple.getArchiveType())) ){//医养平板端登录限制
            throw new InvalidGrantException("不允许登录该平台");
        }
        wlyyUserSimple.setAccessToken(token.getValue());
        wlyyUserSimple.setTokenType(token.getTokenType());
        wlyyUserSimple.setExpiresIn(token.getExpiresIn());

+ 67 - 1
server/svr-authentication/src/main/resources/application.yml

@ -522,4 +522,70 @@ im:
  im_list_get: http://172.26.0.105:3000/
wechat:
  id: xm_dsyy_wx
  id: xm_dsyy_wx
---
spring:
  profiles: hcyyProd
  datasource:
    url: jdbc:mysql://192.168.120.103:6001/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: wlyy
    password: 2oEq3Kf7@zjxl
  redis:
    host: 192.168.120.103 # Redis server host.
    port: 6007 # Redis server port.
    password: Kb6wKDQP1W4
iHealth:
  user-info-uri: http://www.xmtyw.cn/wlyy/iHealth/userInfo
zhongshanHospital:
  user-info-uri: http://laptop-u738dn2p:10023/mqsdk/getUserInfoByOpenid
fastDFS:
  fastdfs_file_url: http://192.168.120.103:6002
wlyy:
  url: http://www.xmtyw.cn/wlyy/
testPattern: #文件服务器上传配置 0本地,1.I健康,2.内网调用
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_hcyy_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://127.0.0.1:3000/
kick:
    eachOther: 1 #互踢 1开通 0关闭
---
spring:
  profiles: yqfk
  datasource:
    url: jdbc:mysql://10.90.32.3:22042/base?useUnicode:true&amp;characterEncoding=utf-8&amp;autoReconnect=true&useSSL=false
    username: jkzl_root
    password: jkzlehr@2020%
  redis:
    host: 127.0.0.1 # Redis server host.
    port: 6380 # Redis server port.
    password: Kb6wKDQP1W4
iHealth:
  user-info-uri: http://www.xmtyw.cn/wlyy/iHealth/userInfo
zhongshanHospital:
  user-info-uri: http://laptop-u738dn2p:10023/mqsdk/getUserInfoByOpenid
fastDFS:
  fastdfs_file_url: http://192.168.120.103:6002
wlyy:
  url: http://www.xmtyw.cn/wlyy/
testPattern: #文件服务器上传配置 0本地,1.I健康,2.内网调用
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
wechat:
  id: xm_hcyy_wx  # base库中,wx_wechat 的id字段
im:
  im_list_get: http://127.0.0.1:3000/
kick:
    eachOther: 1 #互踢 1开通 0关闭

+ 18 - 2
server/svr-authentication/src/main/resources/bootstrap.yml

@ -130,7 +130,7 @@ spring:
  cloud:
    config:
      uri: ${wlyy-spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy-spring.config.label:jwdev}
      label: ${wlyy-spring.config.label:master}
---
spring:
@ -146,4 +146,20 @@ spring:
  cloud:
    config:
      uri: ${wlyy-spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy-spring.config.label:master}
      label: ${wlyy-spring.config.label:master}
---
spring:
  profiles: hcyyProd
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://192.168.250.39:1221}
      label: ${wlyy.spring.config.label:master}
---
spring:
  profiles: yqfk
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy.spring.config.label:master}

+ 30 - 0
server/svr-configuration/src/main/resources/bootstrap.yml

@ -222,4 +222,34 @@ spring:
          basedir: /usr/local/wlyy2.0.config
          username: jkzl
          password: jkzl
        default-label: ${wlyy.spring.config.git.label:master}
---
spring:
  profiles: hcyyProd
##git配置
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      server:
        git:
          uri: ${wlyy.spring.config.git.uri:http://127.0.0.1:3001/jkzl/wlyy2.0.config.git}
          basedir: /data/wlyy2.0/wlyy2.0.config
          username: jkzl
          password: jkzl
        default-label: ${wlyy.spring.config.git.label:master}
---
spring:
  profiles: yqfk
##git配置
  cloud:
    config:
      failFast: true #启动快速失败 即链接不到配置服务就启动失败
      server:
        git:
          uri: ${wlyy.spring.config.git.uri:http://127.0.0.1:3001/jkzl/wlyy2.0.config.git}
          basedir: /data/wlyy2.0/wlyy2.0.config
          username: jkzl
          password: jkzl
        default-label: ${wlyy.spring.config.git.label:master}

+ 0 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/servicePackage/ServicePackageItemDao.java

@ -13,8 +13,6 @@ import java.util.List;
 */
public interface ServicePackageItemDao extends PagingAndSortingRepository<ServicePackageItemDO, String>, JpaSpecificationExecutor<ServicePackageItemDO> {
    @Query("from ServicePackageItemDO w where w.teamCode =?1 and w.code=?2")
    List<ServicePackageItemDO> findByTeamCode(String teamCode,String code);
    @Query("from ServicePackageItemDO w where w.servicePackageId =?1 and w.del='1'")
    List<ServicePackageItemDO> findByServicePackageId(String servicePackageId);

+ 4 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageEndpoint.java

@ -80,12 +80,12 @@ public class ServicePackageEndpoint extends EnvelopRestEndpoint {
        for (ServicePackageDO servicePackageDO:servicePackageDOS){
            List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByServicePackageId(servicePackageDO.getId());
            List<String> orgNames = itemDOList.stream().map(p -> p.getOrgName()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
            List<String> teamNames = itemDOList.stream().map(p -> p.getTeamName()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
//            List<String> teamNames = itemDOList.stream().map(p -> p.getTeamName()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
            List<String> orgCodes = itemDOList.stream().map(p -> p.getOrgCode()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
 //           List<String> teamCodes = itemDOList.stream().map(p -> p.getTeamCode()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
            servicePackageDO.setOrgNames(StringUtils.join(orgNames,","));
            servicePackageDO.setTeamNames(StringUtils.join(teamNames,","));
//            servicePackageDO.setTeamNames(StringUtils.join(teamNames,","));
            servicePackageDO.setOrgCodes(StringUtils.join(orgCodes,","));
            for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:wlyyHospitalSysDictDOS){
@ -112,9 +112,9 @@ public class ServicePackageEndpoint extends EnvelopRestEndpoint {
        ServicePackageDO servicePackageDO = servicePackageDao.findOne(id);
        List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByServicePackageId(servicePackageDO.getId());
        List<String> orgNames = itemDOList.stream().map(p -> p.getOrgName()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
        List<String> teamNames = itemDOList.stream().map(p -> p.getTeamName()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
//        List<String> teamNames = itemDOList.stream().map(p -> p.getTeamName()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
        servicePackageDO.setOrgNames(StringUtils.join(orgNames,","));
        servicePackageDO.setTeamNames(StringUtils.join(teamNames,","));
//        servicePackageDO.setTeamNames(StringUtils.join(teamNames,","));
        servicePackageDO.setPackageItemDOList(itemDOList);
        return success(servicePackageDO);
    }

+ 6 - 11
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageItemService.java

@ -59,12 +59,12 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
                }
            }
            //新增
            List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByTeamCode(itemDO.getTeamCode(),itemDO.getCode());
            if(itemDOList!=null&&itemDOList.size()>0){
                result.put("msg","该服务团队已存在此服务项,请勿重复添加");
                result.put("response", ConstantUtils.FAIL);
                return result;
            }
//            List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByTeamCode(itemDO.getTeamCode(),itemDO.getCode());
//            if(itemDOList!=null&&itemDOList.size()>0){
//                result.put("msg","该服务团队已存在此服务项,请勿重复添加");
//                result.put("response", ConstantUtils.FAIL);
//                return result;
//            }
            itemDO.setPrice(new BigDecimal(0));
            itemDO.setServicePackageId("system");
            itemDO.setCreateTime(DateUtil.getStringDate());
@ -83,11 +83,6 @@ public class ServicePackageItemService extends BaseJpaService<ServicePackageItem
            oldItemDO.setCode(itemDO.getCode());
            oldItemDO.setFeeType(itemDO.getFeeType());
            oldItemDO.setIntroduce(itemDO.getIntroduce());
//            oldItemDO.setOrgCode(itemDO.getOrgCode());
//
//            oldItemDO.setOrgName(itemDO.getOrgName());
            oldItemDO.setTeamCode(itemDO.getTeamCode());
            oldItemDO.setTeamName(itemDO.getTeamName());
            servicePackageItemDao.save(oldItemDO);
        }

+ 48 - 1
svr/svr-base/src/main/resources/application.yml

@ -687,4 +687,51 @@ testPattern:
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
im:
  im_list_get: http://10.9.1.247:3000/
  im_list_get: http://10.9.1.247:3000/
---
spring:
  profiles: hcyyProd
  datasource:
    url: jdbc:mysql://192.168.120.103:6001/base?useUnicode:true&characterEncoding=utf-8&autoReconnect=true
    username: wlyy
    password: 2oEq3Kf7@zjxl
  elasticsearch:
    cluster-name: jkzl #集群名 默认elasticsearch
    cluster-nodes: 192.168.120.103:6005 #配置es节点信息,逗号分隔,如果没有指定,则启动ClientNode
    client-transport-sniff: false
    jest:
      uris: http://192.168.120.103:6006
      connection-timeout: 60000 # Connection timeout in milliseconds.
      multi-threaded: true # Enable connection requests from multiple execution threads.
  activemq:
    broker-url: tcp://59.61.92.90:9103
    user: jkzl
    password: jkzlehr
  redis:
    host: 192.168.120.103 # Redis server host.
    port: 6007 # Redis server port.
    password: Kb6wKDQP1W4
fastDFS:
  fastdfs_file_url: http://192.168.120.103:6004/
demo:
  flag: true
hospital:
  url: https://wx.xmzsh.com
  mqUser: JKZL
  mqPwd: 123456
  SourceSysCode: S60
  TargetSysCode: S01
pay:
  flag: false
wlyy:
  url: http://ehr.yihu.com/wlyy/
wechat:
  id: xm_hcyy_wx
  url: https://zhyzh.gongshu.gov.cn/
  flag: false
testPattern: #文件服务器上传配置 0本地,1.I健康,2.内网调用
  sign: 0
  remote_inner_url: 172.16.100.240:10023/open/fileUpload/upload_stream
im:
  im_list_get: http://127.0.0.1:3000/

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

@ -117,4 +117,12 @@ spring:
  cloud:
    config:
      uri: ${wlyy-spring.config.uri:http://127.0.0.1:1221}
      label: ${wlyy-spring.config.label:jwdev}
      label: ${wlyy-spring.config.label:jwdev}
---
spring:
  profiles: hcyyProd
  cloud:
    config:
      uri: ${wlyy.pring.config.uri:http://192.168.250.39:1221}
      label: ${wlyy.spring.config.label:master}

+ 9 - 0
svr/svr-cloud-care/pom.xml

@ -219,6 +219,10 @@
                    <groupId>xalan</groupId>
                    <artifactId>xalan</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.his.hesb</groupId>
                    <artifactId>mqSdk</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
@ -256,6 +260,11 @@
            <artifactId>es-service</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.hikvision.ga</groupId>
            <artifactId>artemis-http-client</artifactId>
            <version>1.1.3</version>
        </dependency>
    </dependencies>
    <build>

+ 2 - 0
svr/svr-cloud-care/src/main/java/com/yihu/SvrCloudCareApplication.java

@ -4,6 +4,7 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
/**
@ -11,6 +12,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
 */
@SpringBootApplication
@EnableJpaAuditing
@ComponentScan("com.yihu")
public class SvrCloudCareApplication extends SpringBootServletInitializer {
    public static void main(String[] args)  {

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

@ -36,8 +36,23 @@ public class AqgConfig {
     * 设置智能手环安全区域
     */
    public static final String S3fence_area = baseUrl +"/api/device/{0}/fences/{1}";
    public static final String X1fence_area = baseUrl +"/api/device/{0}/4g/fences/{1}";
    /**
     * X1定位数据  即轨迹
     */
    public static final String X1_locations = baseUrl+"/api/locationdata/";
    /**
     * 睡眠带 修改心率呼吸率报警阈值
     */
    public static final String  sleepDevice_edit=baseUrl+ "/api/sleepdevice/{0}/edit/";
    /**
     * 睡眠带 查询睡眠带信息
     */
    public static final String  sleepDevice_info=baseUrl+"/api/sleepdevice/";
    public static final String username = "13559485270";
    public static final String password = "zjxl@2021";

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

@ -0,0 +1,14 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BasePatientOutBed;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/8/18.
 */
public interface BasePatientOutBedDao extends PagingAndSortingRepository<BasePatientOutBed,Long>,
        JpaSpecificationExecutor<BasePatientOutBed> {
    BasePatientOutBed findByPatientAndDeviceSnAndStatus(String patient,String deviceSn,Integer status);
}

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

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

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

@ -0,0 +1,25 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BaseSleepNightRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
 * Created by Bing on 2021/8/17.
 */
public interface BaseSleepNightRecordDao extends PagingAndSortingRepository<BaseSleepNightRecord,Long>,
        JpaSpecificationExecutor<BaseSleepNightRecord> {
    @Query(value = "select r from BaseSleepNightRecord r where r.deviceSn=?1 and r.patient=?2 order by r.createTime desc")
    List<BaseSleepNightRecord> findByDeviceSnAndPatient(String deviceSn, String patient);
    @Query(value = "select r from BaseSleepNightRecord r where r.deviceSn=?1 and r.patient=?2 and r.status=?3 and r.createTime>?4 order by r.createTime desc")
    List<BaseSleepNightRecord> findBySnStaPaTime(String deviceSn,String patient,Integer status, Date benIn);
    List<BaseSleepNightRecord> findByPatientAndDayOrderByCreateTimeDesc(String patient,String day);
}

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

@ -0,0 +1,21 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BaseSleepDeviceReport;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.awt.print.Pageable;
import java.util.List;
/***
 * @ClassName: BaseSleepPlanDao
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/23 17:20
 */
public interface BaseSleepPlanDao extends PagingAndSortingRepository<BaseSleepPlan,Long>,
        JpaSpecificationExecutor<BaseSleepPlan> {
    List<BaseSleepPlan> findByPatient(String patient);
}

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

@ -0,0 +1,24 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BaseSleepPlanDetail;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;
/**
 * Created by Bing on 2021/8/23.
 */
public interface BaseSleepPlanDetailDao extends PagingAndSortingRepository<BaseSleepPlanDetail,Long>,
        JpaSpecificationExecutor<BaseSleepPlanDetail> {
    List<BaseSleepPlanDetail> findByPatientAndDay(String patient, String day);
    @Query("SELECT a FROM BaseSleepPlanDetail a WHERE a.patient = ?1 AND a.day>=?2 and a.day<=?3 ORDER BY a.day desc")
    Page<BaseSleepPlanDetail> findByListByPage(String patient, String begin, String end, Pageable pageRequest);
}

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

@ -17,6 +17,8 @@ public interface DeviceDetailDao extends PagingAndSortingRepository<DeviceDetail
    List<DeviceDetail> findByDeviceCode(String deviceCode);
    List<DeviceDetail> findBySim(String sim);
    @Query("select a from DeviceDetail a where a.deviceCode = ?1 and a.manufacturerCode = ?2")
    DeviceDetail findByDeviceCodeAndManufacturerCode(String deviceCode,String manufacturerCode);

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

@ -3,6 +3,7 @@ package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
@ -73,5 +74,7 @@ public interface DevicePatientHealthIndexDao
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.deviceSn = ?2 and a.value1 = ?3 and a.value2=?7 and a.value3=?8 and a.type = ?4 and a.recordDate >= ?5 and a.recordDate<=?6 and a.del = '1' ")
	List<DevicePatientHealthIndex> findByTypeInHalfMinuteAllValue(String patient, String deviceSn, String value1, Integer type, Date minDate,Date maxDate,String value2,String value3);
	@Modifying
	@Query("update DevicePatientHealthIndex a set a.manageResult=1 where a.id in (?1) ")
	void handleHealthIndex(Long[] id);
}

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

@ -1,5 +1,6 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
@ -54,6 +55,12 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatie
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();
    @Query("select a from DevicePatientDevice a group by a.user")
    List<DevicePatientDevice> findAllGroupUser();
    @Query("select a from DevicePatientDevice a where a.categoryCode = ?1 and a.del=0 group by a.user")
    List<DevicePatientDevice> findAllByCategoryCode(String categoryCode);
    @Modifying
    @Query("delete DevicePatientDevice a where a.deviceSn = ?1")
    int deleteByDeviceSn(String deviceSN);
@ -61,6 +68,9 @@ 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);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
    List<DevicePatientDevice> findAllByUserAndCategoryCode(String user,String categoryCode);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
    List<DevicePatientDevice> findByUserAndCategoryCode(String user,String categoryCode);
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/label/WlyyPatientLabelDao.java

@ -17,6 +17,6 @@ public interface WlyyPatientLabelDao extends PagingAndSortingRepository<WlyyPati
    @Query("delete WlyyPatientLabelDO a where a.patient=?1 and a.labelType=?2")
    int deleteByPatientAndLabelType(String patient,String labelType) throws Exception;
    @Query("from WlyyPatientLabelDO w where  w.patient=?1 ")
    @Query("from WlyyPatientLabelDO w where  w.patient=?1 group by w.labelType,w.labelCode order by w.czrq desc")
    List<WlyyPatientLabelDO> findByPatient(String patient);
}

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

@ -13,8 +13,6 @@ import java.util.List;
 */
public interface ServicePackageItemDao extends PagingAndSortingRepository<ServicePackageItemDO, String>, JpaSpecificationExecutor<ServicePackageItemDO> {
    @Query("from ServicePackageItemDO w where w.teamCode =?1 and w.code=?2")
    List<ServicePackageItemDO> findByTeamCode(String teamCode, String code);
    @Query("from ServicePackageItemDO w where w.servicePackageId =?1 and w.del='1'")
    List<ServicePackageItemDO> findByServicePackageId(String servicePackageId);

+ 4 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/team/BaseTeamMemberDao.java

@ -53,4 +53,8 @@ public interface BaseTeamMemberDao extends PagingAndSortingRepository<BaseTeamMe
    @Query("SELECT d FROM BaseTeamMemberDO m, BaseTeamDO t, BaseDoctorDO d WHERE t.id = :teamCode AND t.id = m.teamCode " +
            "AND m.doctorCode = d.id AND t.del = '1' AND m.del = '1' ")
    List<BaseDoctorDO> findAllMembers(@Param(value = "teamCode") String teamCode);
    @Query("SELECT count(1) FROM BaseTeamMemberDO m, BaseTeamDO t, BaseDoctorDO d WHERE t.id = :teamCode AND t.id = m.teamCode " +
            "AND m.doctorCode = d.id AND t.del = '1' AND m.del = '1' ")
    Integer findMemCount(@Param(value = "teamCode") String teamCode);
}

+ 18 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/BaseController.java

@ -4,7 +4,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.entity.base.dict.BaseExceptionDictDO;
import com.yihu.jw.entity.iot.gateway.IdEntity;
import com.yihu.jw.restmodel.exception.dao.BaseExceptionDictDao;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
@ -80,6 +79,24 @@ public class BaseController {
        }
    }
    /**
     * 获取代理人的code
     * 老人亲属
     * @return
     */
    public String getAgentUID() {
        try {
            String userAgent = request.getHeader("userAgent");
            if (StringUtils.isEmpty(userAgent)) {
                userAgent = request.getHeader("User-Agent");
            }
            JSONObject json = new JSONObject(userAgent);
            return json.getString("agent");
        } catch (Exception e) {
            return null;
        }
    }
    /**
     * 获取平台端

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

@ -112,7 +112,7 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "existApplyStatus")
    @ApiOperation(value = "查看居民救助状态是否在申请中")
    public ObjEnvelop existApplyStatus(@ApiParam(name="patient",value = "患者(代预约家人为主)")
    public ObjEnvelop existApplyStatus(@ApiParam(name="patient",value = "服务对象id")
                                    @RequestParam(value = "patient") String patient){
        try {
            JSONObject result = assistanceService.existApplyStatus(patient);
@ -318,16 +318,6 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getMonitorUrl")
    @ApiOperation(value = "获取监控录像地址")
    public ObjEnvelop getMonitorUrl(@ApiParam(name="patient")@RequestParam(value = "patient")String patient){
        try {
            return null;
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping("doctorSendMessageLog")
    @ApiOperation(value = "助老员紧急预警im发送消息日志")
    public ObjEnvelop doctorSendMessageLog(

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

@ -314,4 +314,35 @@ public class DoctorHealthController extends BaseController {
			return errorResult(e);
		}
	}
	@RequestMapping(value = "getErrorHealthIndexPatients",method = RequestMethod.GET)
	@ApiOperation("获取签约医生底下未干预异常体征患者")
	public String getErrorHealthIndexPatients(@ApiParam(name="doctor")@RequestParam(value = "doctor")String doctor) {
		try {
			return write(200, "查询成功", "data", healthIndexService.getErrorHealthIndexPatients(doctor));
		} catch (Exception e) {
			return errorResult(e);
		}
	}
	@RequestMapping(value = "getErrorHealthIndexByPatients",method = RequestMethod.GET)
	@ApiOperation("获取患者未干预异常体征列表")
	public String getErrorHealthIndexByPatients(@ApiParam(name="patient")@RequestParam(value = "patient")String patient) {
		try {
			return write(200, "查询成功", "data", healthIndexService.getErrorHealthIndexByPatients(patient));
		} catch (Exception e) {
			return errorResult(e);
		}
	}
	@RequestMapping(value = "handleHealthIndex",method = RequestMethod.POST)
	@ApiOperation("医生体征干预")
	public String handleHealthIndex(@ApiParam(name="user")@RequestParam(value = "user")String ids) {
		try {
			healthIndexService.handleHealthIndex(ids);
			return write(200, "处理成功");
		} catch (Exception e) {
			return errorResult(e);
		}
	}
}

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

@ -2,7 +2,9 @@ package com.yihu.jw.care.endpoint.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.contacts.ContactsService;
@ -13,24 +15,31 @@ 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.DeviceDetail;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.utils.StringUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import jxl.Sheet;
import jxl.Workbook;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
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 org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
/***
 * @ClassName: PadDeviceController
@ -54,6 +63,9 @@ public class PadDeviceController extends BaseController {
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private ContactsService contactsService;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    /**
     * 设备列表获取
     *
@ -104,10 +116,19 @@ public class PadDeviceController extends BaseController {
    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,
                             @ApiParam(name = "doctorCode", value = "管理员code") @RequestParam(value = "doctorCode", required = false) String doctorCode
                             @ApiParam(name = "doctorCode", value = "管理员code") @RequestParam(value = "doctorCode", required = false) String doctorCode,
                             @ApiParam(name = "sleepPlanJson", value = "睡眠计划json") @RequestParam(value = "sleepPlanJson", required = false) String sleepPlanJson,
                             @ApiParam(name = "iotDeviceSn", value = "iotDeviceSn") @RequestParam(value = "iotDeviceSn", required = false) String iotDeviceSn,
                             @ApiParam(name = "safeAreaGz", value = "safeAreaGz") @RequestParam(value = "safeAreaGz", required = false) String safeAreaGz
                             //{"deviceSn": "7052169111","getUpTime": "07:00","napTime": "13:00","nightRestTime": "21:30"}
                             ) {
        try {
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            BaseSleepPlan sleepPlan = new BaseSleepPlan();
            if (StringUtils.isNotBlank(sleepPlanJson)){
                sleepPlan = objectMapper.readValue(sleepPlanJson,BaseSleepPlan.class);
                sleepPlan.setPatient(patientCode);
            }
            // 设置患者标识
            device.setUser(patientCode);
            //患者和设备是否首绑
@ -123,9 +144,19 @@ public class PadDeviceController extends BaseController {
            device.setAgentName(doctor.getName());
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
                Boolean flagDevice = patientDeviceService.saveDevice(device);
                if (flagDevice == false){
                int flagDevice = patientDeviceService.saveDevice(device,sleepPlan,iotDeviceSn,safeAreaGz);
                if (flagDevice == 0){
                    return write(-1,"请填写投放地址");
                } else if (flagDevice == -1) {
                    return write(-1,"设备不存在");
                } else if (flagDevice == -2) {
                    return write(-1,"请完善睡眠时间规划");
                } else if (flagDevice == -3) {
                    return write(-1,"sn码已被使用");
                } else if (flagDevice == -4) {
                    return write(-1,"不存在该条记录");
                } else if (flagDevice == -5) {
                    return write(-1,"请勿重复绑定设备");
                }
                //注册设备地址
                deviceDetailService.registerToWlyy(device);
@ -167,5 +198,114 @@ public class PadDeviceController extends BaseController {
        }
    }
    @RequestMapping(value = "/importDeviceFromExcel", produces = "application/json;charset=UTF-8",method = RequestMethod.POST)
    @ResponseBody
    public String importFromExcel(HttpServletRequest request,@ApiParam(value = "文件", required = true)
    @RequestParam(value = "file", required = true) MultipartFile file) {
        List errorLs = new ArrayList<>();
        List correctLs = new ArrayList<>();
        Map<String, String> errorMsgMap = new HashMap<>();
        List<String> deviceCodes = new ArrayList<>();
        try {
            request.setCharacterEncoding("UTF-8");
            InputStream inputStream = file.getInputStream();
            Workbook rwb = Workbook.getWorkbook(inputStream);
            Sheet[] sheets = rwb.getSheets();
            int rows;
            int row;
            String manufacturer=null;//厂商名称
            String deviceName; //设备名称
            String deviceModel; //设备型号
            String deviceCode;  //设备SN
            String sim;  //sim卡号
            String bindingCount; //单人{"1":"0"}  多人{"1":"0", "2":"0"}
            String deviceType; //设备种类  0健康设备 1安防设备
            Sheet sheet = sheets[0];    //第一张表
            rows = sheet.getRows();
            for (int j = 1; j < rows; j++) {
                if (sheet.getRow(j).length == 0) {
                    continue;
                }
                DeviceDetail deviceDetail = new DeviceDetail();
                row = j;
                manufacturer = sheet.getCell(0, row).getContents().trim();    //0 厂商名称
                deviceName = sheet.getCell(1, row).getContents().trim();  //1 设备名称
                deviceModel = sheet.getCell(2, row).getContents().trim();   //2 设备型号
                deviceCode = sheet.getCell(3, row).getContents().trim(); //3 设备SN
                sim = sheet.getCell(4, row).getContents().trim();  //4 sim卡号
                bindingCount = sheet.getCell(5, row).getContents().trim(); //5
                deviceType = sheet.getCell(6, row).getContents().trim(); //6 设备种类
                if (StringUtils.isBlank(deviceCode)){
                    continue;
                }
                if (deviceCodes.contains(deviceCode)){
                    errorMsgMap.put(deviceCode,"设备SN码重复");
                    continue;
                }
                deviceCodes.add(deviceCode);
                if (StringUtils.isBlank(manufacturer)){
                    errorMsgMap.put(deviceCode,"厂商名称不能为空");
                    continue;
                }
                if (StringUtils.isBlank(deviceName)){
                    errorMsgMap.put(deviceCode,"设备名称不能为空");
                    continue;
                }
                if (StringUtils.isBlank(deviceModel)){
                    errorMsgMap.put(deviceCode,"设备型号不能为空");
                    continue;
                }
                if (StringUtils.isBlank(bindingCount)){
                    errorMsgMap.put(deviceCode,"设备类型不能为空");
                    continue;
                }
                if (StringUtils.isBlank(deviceType)){
                    errorMsgMap.put(deviceCode,"设备种类不能为空");
                    continue;
                }else {
                    if ("健康设备".equals(deviceType)){
                        deviceType = "1";
                    }
                    else if ("安防设备".equals(deviceType)){
                        deviceType= "0";
                    }
                    else {
                        errorMsgMap.put(deviceCode,"不支持该设备种类");
                        continue;
                    }
                }
                if (deviceDetailDao.findByDeviceCode(deviceCode).size()>0){
                    errorMsgMap.put(deviceCode,"该设备SN码已存在");
                    continue;
                }
                if (deviceDetailDao.findBySim(sim).size()>0){
                    errorMsgMap.put(deviceCode,"该sim卡号已存在");
                    continue;
                }
                deviceDetail.setManufacturer(manufacturer);
                deviceDetail.setDeviceName(deviceName);
                deviceDetail.setDeviceModel(deviceModel);
                deviceDetail.setDeviceCode(deviceCode);
                deviceDetail.setSim(sim);
                deviceDetail.setBindingCount(bindingCount);
                deviceDetail.setDeviceType(Integer.parseInt(deviceType));
                correctLs.add(deviceDetail);
            }
            deviceDetailDao.save(correctLs);
            //包装导入结果(导入成功数量、错误对象集合)
            Map<String, Object> map = new HashMap<>();
            map.put("successNum", correctLs.size());
            map.put("failedNum", rows-1 - correctLs.size() );
            map.put("errorData", JSON.toJSONString(errorMsgMap, SerializerFeature.WriteMapNullValue));
            return write(200, "操作成功", "data", map);
        } catch (Exception e) {
            error(e);
            return error(-1, "操作失败!");
        }
    }
}

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

@ -1,5 +1,6 @@
package com.yihu.jw.care.endpoint.device;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.endpoint.BaseController;
@ -7,10 +8,11 @@ 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.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.util.entity.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@ -68,6 +70,30 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @ApiOperation("燃气浓度")
    @RequestMapping(value = "gasConcentration", method = RequestMethod.GET)
    public String gasConcentration(@ApiParam(name = "patientId", value = "居民id", defaultValue = "808080eb7917a3be017918a979380055")
                             @RequestParam(value = "patientId", required = true) String patientId,
                                   @ApiParam(name = "date", value = "日期", defaultValue = "2021-08-24")
                                   @RequestParam(value = "date", required = true) String date){
        try {
            return write(200,"获取成功","data",patientDeviceService.gasConcentration(patientId,date));
        } catch (Exception ex) {
            return errorResult(ex);
        }
    }
    @ApiOperation("环境信息")
    @RequestMapping(value = "envMessage", method = RequestMethod.GET)
    public String envMessage(@ApiParam(name = "patientId", value = "居民id", defaultValue = "1")
                                    @RequestParam(value = "patientId", required = true) String patientId){
        try {
            JSONObject json = patientDeviceService.envMessage(patientId);
            return write(200,"获取成功","data",json);
        } catch (Exception ex) {
            return errorResult(ex);
        }
    }
    /**
     * 设备保存接口  ---增加血糖时间段保存 Reece v1.3.3
@ -75,9 +101,18 @@ public class PatientDeviceController extends BaseController {
    @ApiOperation("设备保存接口")
    @RequestMapping(value = "SavePatientDevice", method = RequestMethod.POST)
    public String saveDevice(@ApiParam(name = "json", value = "设备数据json", defaultValue = "{\"deviceId\": \"3\",\"deviceName\": \"血压计-优瑞恩\",\"deviceSn\": \"7052169111\",\"categoryCode\": \"1\",\"userType\": \"-1\"}")
                             @RequestParam(value = "json", required = true) String json) {
                             @RequestParam(value = "json", required = true) String json,
                             @ApiParam(name = "sleepPlanJson", value = "睡眠计划json") @RequestParam(value = "sleepPlanJson", required = false) String sleepPlanJson,
                             @ApiParam(name = "iotDeviceSn", value = "对应的设备sn码") @RequestParam(value = "iotDeviceSn", required = false) String iotDeviceSn,
                             @ApiParam(name = "safeAreaGz", value = "智能拐杖时需要传围栏地址") @RequestParam(value = "safeAreaGz", required = false) String safeAreaGz){
        //{"deviceSn": "7052169111","getUpTime": "07:00","napTime": "13:00","nightRestTime": "21:30"})
        try {
            DevicePatientDevice device = objectMapper.readValue(json, DevicePatientDevice.class);
            BaseSleepPlan sleepPlan = new BaseSleepPlan();
            if (StringUtils.isNotBlank(sleepPlanJson)){
                sleepPlan = objectMapper.readValue(sleepPlanJson,BaseSleepPlan.class);
                sleepPlan.setPatient(getRepUID());
            }
            // 设置患者标识
            device.setUser(getRepUID());
            //患者和设备是否首绑
@ -96,9 +131,19 @@ public class PatientDeviceController extends BaseController {
            String sn = device.getDeviceSn();
            synchronized (sn.intern()){
//                patientDeviceService.saveDevice(device);
                Boolean flagDevice = patientDeviceService.saveDevice(device);
                if (flagDevice == false){
                int flagDevice = patientDeviceService.saveDevice(device,sleepPlan,iotDeviceSn,safeAreaGz);
                if (flagDevice == 0){
                    return write(-1,"请填写投放地址");
                } else if (flagDevice == -1) {
                    return write(-1,"设备不存在");
                } else if (flagDevice == -2) {
                    return write(-1,"请完善睡眠时间规划");
                } else if (flagDevice == -3) {
                    return write(-1,"sn码已被使用");
                } else if (flagDevice == -4) {
                    return write(-1,"不存在该条记录");
                } else if (flagDevice == -5) {
                    return write(-1,"请勿重复绑定设备");
                }
                //注册设备地址
                deviceDetailService.registerToWlyy(device);
@ -305,17 +350,76 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @ApiOperation("获取X1手表定位数据列表")
    @RequestMapping(value = "getX1Locations",method = RequestMethod.GET)
    public String getX1Locations(@ApiParam(name = "deviceSn",value = "设备sn码")
                                        @RequestParam(value = "deviceSn",required = true)String deviceSn,
                                        @ApiParam(name = "time_begin",value = "YYYYMMDD 定位日期")
                                        @RequestParam(value = "time_begin",required = false)String time_begin){
        try {
            return write(200,"获取成功","data",patientDeviceService.getX1Locations(deviceSn, time_begin));
        }catch (Exception e){
            return errorResult(e);
        }
    }
    @ApiOperation("获取睡眠带设备信息")
    @RequestMapping(value = "getSleepDeviceInfo",method = RequestMethod.GET)
    public String getSleepDeviceInfo(@ApiParam(name = "deviceSn",value = "睡眠带MAC 去除符号:")
                                        @RequestParam(value = "deviceSn",required = true)String deviceSn){
        try {
            return write(200,"获取成功","data",patientDeviceService.getSleepDeviceInfo(deviceSn));
        }catch (Exception e){
            return errorResult(e);
        }
    }
    @ApiOperation("修改心率呼吸率报警阈值")
    @RequestMapping(value = "sleepDeviceEdit",method = RequestMethod.GET)
    public String sleepDeviceEdit(@ApiParam(name = "deviceSn",value = "睡眠带MAC 去除符号:")
                                        @RequestParam(value = "deviceSn",required = true)String deviceSn,
                                        @ApiParam(name = "heart_check_enable",value = "心率异常检查开关0是关,1是开 ")
                                        @RequestParam(value = "heart_check_enable",required = false)Integer heart_check_enable,
                                        @ApiParam(name = "breath_check_enable",value = "呼吸率异常检查开关")
                                        @RequestParam(value = "breath_check_enable",required = false)Integer breath_check_enable,
                                        @ApiParam(name = "offbed_check_enable",value = "离床异常检查开关")
                                        @RequestParam(value = "offbed_check_enable",required = false)Integer offbed_check_enable,
                                        @ApiParam(name = "theshold_heartrate_h",value = "心率上限 默认100")
                                        @RequestParam(value = "theshold_heartrate_h",required = false)Integer theshold_heartrate_h,
                                        @ApiParam(name = "theshold_heartrate_l",value = "心率下限  默认50")
                                        @RequestParam(value = "theshold_heartrate_l",required = false)Integer theshold_heartrate_l,
                                        @ApiParam(name = "theshold_breath_h",value = "呼吸率上限  默认25")
                                        @RequestParam(value = "theshold_breath_h",required = false)Integer theshold_breath_h,
                                        @ApiParam(name = "theshold_breath_l",value = "呼吸率下限  默认8")
                                        @RequestParam(value = "theshold_breath_l",required = false)Integer theshold_breath_l,
                                        @ApiParam(name = "offbed_long",value = "离床报警时长(分钟)  默认10,最低5")
                                        @RequestParam(value = "offbed_long",required = false)Integer offbed_long,
                                        @ApiParam(name = "check_time_begin",value = "监控开始时间(秒数)  默认79200")
                                        @RequestParam(value = "check_time_begin",required = false)Integer check_time_begin,
                                        @ApiParam(name = "check_time_end",value = "监控结束时间(秒数)  默认21600")
                                        @RequestParam(value = "check_time_end",required = false)Integer check_time_end
                                        ){
        try {
            return write(200,"获取成功","data",patientDeviceService.sleepDeviceEdit(deviceSn,heart_check_enable,breath_check_enable,offbed_check_enable,
                    theshold_heartrate_h,theshold_heartrate_l,theshold_breath_h,theshold_breath_l,offbed_long,check_time_begin,check_time_end));
        }catch (Exception e){
            return errorResult(e);
        }
    }
    @ApiOperation("获取设备详情信息")
    @RequestMapping(value = "getPatientDeviceDetail",method = RequestMethod.GET)
    public String getPatientDeviceDetail(@ApiParam(name="patient")
                                         @RequestParam(value = "patient")String patient,
                                         @ApiParam(name="deviceSN")
                                         @RequestParam(value = "deviceSN")String deviceSn){
                                         @RequestParam(value = "deviceSN")String deviceSn,
                                         @ApiParam(name="day",value = "yyyy-mm-dd")
                                         @RequestParam(value = "day",required = false)String day){
        try {
            JSONObject result = patientDeviceService.getPatientDeviceDetail(patient,deviceSn);
            JSONObject result = patientDeviceService.getPatientDeviceDetail(patient,deviceSn,day);
            if (result.getInt(ResponseContant.resultFlag)==ResponseContant.success){
                return write(200,"获取成功","data",result.getJSONObject(ResponseContant.resultMsg));
                return write(200,"获取成功","data", JSON.parseObject(result.getString(ResponseContant.resultMsg)));
            }else {
                return error(-1,result.getString(ResponseContant.resultMsg));
            }

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

@ -145,10 +145,14 @@ public class YsDeviceController extends BaseController {
            @RequestParam(value = "speed",required = true) Integer speed,
            HttpServletRequest request){
        try {
            JSONObject result = ysDeviceService.ptzStart(deviceSerial,channelNo,direction,speed,request);
            if ("200".equals(result.getString("code"))){
                return write(200,"查询成功","data",result);
            }else {
                return write(-1,result.getString("msg"));
            }
            return write(200,"查询成功","data",ysDeviceService.ptzStart(deviceSerial,channelNo,direction,speed,request));
        }catch (Exception e){
            return errorResult(e);
        }
    }
@ -164,8 +168,12 @@ public class YsDeviceController extends BaseController {
            @RequestParam(value = "direction",required = true) Integer direction,
            HttpServletRequest request){
        try {
            return write(200,"查询成功","data",ysDeviceService.ptzStop(deviceSerial,channelNo,direction,request));
            JSONObject result = ysDeviceService.ptzStop(deviceSerial,channelNo,direction,request);
            if ("200".equals(result.getString("code"))){
                return write(200,"查询成功","data",result);
            }else {
                return write(-1,result.getString("msg"));
            }
        }catch (Exception e){
            return errorResult(e);
        }

+ 9 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorBirthdayWishesEndpoint.java

@ -229,8 +229,8 @@ public class DoctorBirthdayWishesEndpoint extends BaseController {
            //根据openid进行发送祝福
            String patient = one.getPatientCode();
            if (StringUtils.isNotBlank(patient)){
                String sql = " select p.id as patient,p.name,we.openid from base_patient p inner join  base_patient_wechat we on p.id = we.patient_id " +
                        "and we.patient_id = '"+patient+"' " +
                String sql = " select p.id as patient,p.name,we.openid from base_patient p Left join  base_patient_wechat we on p.id = we.patient_id " +
                        "where p.id = '"+patient+"' " +
                        "  order by we.create_time desc  ";
                List<Map<String,Object>> patients = jdbcTemplate.queryForList(sql);
                if (patients.size()>0){//发送生日祝福
@ -244,8 +244,13 @@ public class DoctorBirthdayWishesEndpoint extends BaseController {
//                    json.put("content", one.getContent());
//                    json.put("openid",tmp.get("openid").toString());
//                    json.put("represented","");//被代理人
                    boolean success =  messageUtil.putTemplateWxMessage(wxId,"template_success_notice","srzf",tmp.get("openid").toString(),first,
                            null,one.getContent(),26,json,"已发送", DateUtil.dateToChineseTime(new Date()));
                    boolean success=false;
                    if (null!=tmp.get("openid")&&StringUtils.isNotBlank(tmp.get("openid").toString())) {
                        success = messageUtil.putTemplateWxMessage(wxId, "template_success_notice", "srzf", tmp.get("openid").toString(), first,
                                null, one.getContent().replace("<br>",""), 26, json, "已发送", DateUtil.dateToChineseTime(new Date()));
                    }else {
                        success=true;
                    }
                    if (success){
                        SystemMessageDO messageDO = new SystemMessageDO();
                        messageDO.setTitle("收到来自"+one.getDoctorName()+"的关怀祝福:祝您"+tmp.get("name").toString()+"节日快乐!");

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

@ -47,7 +47,8 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
    public Envelop addFamilyMember(@RequestParam("member") String member,
                                   @RequestParam(value = "captcha", required = false) String captcha,
                                   @RequestParam(value = "password", required = false) String password,
                                   @RequestParam("relation") int relation) {
                                   @RequestParam("relation") int relation,
                                   @RequestParam("client_id") String client_id) {
        try {
            if (StringUtils.isEmpty(member)) {
                return failed("添加成员不能为空",-1);
@ -59,7 +60,7 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
                return failed( "家庭关系无效",-1);
            }
            int result = familyMemberService.addMember(getUID(), member, captcha, password, relation);
            int result = familyMemberService.addMember(client_id,getUID(), member, captcha, password, relation);
            if (result == -1) {
                return failed( "居民信息查询失败",-1);
@ -345,7 +346,8 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
                                      @RequestParam("mobile") String mobile,
                                      @RequestParam("archiveType") Integer archiveType,
                                     @RequestParam("captcha") String captcha,
                                     @RequestParam("relation") int relation){
                                     @RequestParam("relation") int relation,
                                      @RequestParam("client_id") String client_id){
        try {
            if (StringUtils.isEmpty(idcard)) {
                return failed( "添加成员身份证不能为空",-1);
@ -363,7 +365,7 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
                return failed( "家庭关系无效",-1);
            }
            int result = familyMemberService.addMemberByCaptcha(getUID(),idcard,name,mobile,archiveType,captcha,relation);
            int result = familyMemberService.addMemberByCaptcha(client_id,getUID(),idcard,name,mobile,archiveType,captcha,relation);
            if(result==0){
                return failed( "不能添加自己",-1);

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/message/DoctorMessageEndpoint.java

@ -24,7 +24,7 @@ public class DoctorMessageEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "messages")
    @ApiOperation("应用消息")
    public ObjEnvelop messages(@ApiParam(name = "type", value = "消息类型 10床位申请,11安全监护,12紧急救助")
    public ObjEnvelop messages(@ApiParam(name = "type", value = "消息类型 10床位申请,11安全监护,12紧急救助,13体征异常消息")
                               @RequestParam(value = "type", required = false) String type,
                               @ApiParam(name = "doctor", value = "doctor")
                               @RequestParam(value = "doctor", required = false) String doctor){

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

@ -173,6 +173,19 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findPatientLabelAndCar")
    @ApiOperation(value = "获取居民标签及能力评估结果信息")
    public Envelop findPatientLabelAndCar(@ApiParam(name = "patientId", value = "居民id")
                                    @RequestParam(value = "patientId", required = true)String patientId){
        try{
            return success("获取成功",patientService.findPatientLabelAndCar(patientId));
        }catch (Exception e){
            return failedException2(e);
        }
    }
    @PostMapping(value = "updPatientLabel")
    @ApiOperation(value = "修改居民标签信息")
    @ObserverRequired
@ -285,4 +298,14 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "patientIconStatus")
    @ApiOperation("patientIconStatus")
    public ObjEnvelop patientIconStatus(@ApiParam(name="patient")@RequestParam(value = "patient")String patient){
        try {
            return ObjEnvelop.getSuccess("success",patientService.patientIconStatus(patient));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
}

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

@ -324,7 +324,7 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
    public ObjEnvelop patientMonitoringInfo(@ApiParam(name = "patient", value = "patient")
                                @RequestParam(value = "patient") String patient,
                                @ApiParam(name = "topicItem", value = "专题code,关联security_topic_dict字典", required = false)
                                @RequestParam(value = "topicItem",required = false) String topicItem) {
                                @RequestParam(value = "topicItem",required = false,defaultValue = "preventLost") String topicItem) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", securityMonitoringOrderService.patientMonitoringInfo(patient,topicItem));
        } catch (Exception e) {
@ -332,6 +332,20 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("获取居民签约专题信息")
    @RequestMapping(value = "patientSignTopicInfo", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public ObjEnvelop patientSignTopicInfo(@ApiParam(name = "patient", value = "patient")
                                            @RequestParam(value = "patient") String patient,
                                            @ApiParam(name = "topicItem", value = "专题code,关联security_topic_dict字典", required = false)
                                            @RequestParam(value = "topicItem") String topicItem) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", securityMonitoringOrderService.patientSignTopicInfo(null,patient,topicItem));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping("responseOrder")
    @ApiOperation(value = "医生响应紧急预警(点击立即前往)")
    @ObserverRequired
@ -397,4 +411,48 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getPatientSleepPlan")
    @ApiOperation(value = "获取居民睡眠计划")
    public ObjEnvelop getPatientSleepPlan(@ApiParam(name="patient",value = "patient")
                                           @RequestParam(value = "patient") String patient){
        try {
            return ObjEnvelop.getSuccess("获取成功",securityMonitoringOrderService.getPatientSleepPlan(patient));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getPatientSleepDetainList")
    @ApiOperation(value = "获取居民睡眠监护列表")
    public ObjEnvelop getPatientSleepDetainList(@ApiParam(name="patient",value = "patient")
                                          @RequestParam(value = "patient") String patient,
                                          @ApiParam(name="begin",value = "beginTime yyyy-MM-dd")
                                          @RequestParam(value = "begin") String begin,
                                          @ApiParam(name="end",value = "endTime")
                                          @RequestParam(value = "end",required = false) String end,
                                          @ApiParam(name="page",value = "page")
                                          @RequestParam(value = "page",defaultValue = "0") Integer page,
                                          @ApiParam(name="pageSize",value = "pageSize")
                                          @RequestParam(value = "pageSize",defaultValue = "1") Integer pageSize){
        try {
            return ObjEnvelop.getSuccess("查询成功",securityMonitoringOrderService.getPatientSleepDetainList(patient,begin,end,page,pageSize)) ;
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getPatientSleepNightRecord")
    @ApiOperation(value = "获取居民起夜记录")
    public ListEnvelop getPatientSleepPlan(@ApiParam(name="patient",value = "patient")
                                          @RequestParam(value = "patient") String patient,
                                          @ApiParam(name="day",value = "监护日期 yyyy-MM-dd")
                                          @RequestParam(value = "day") String day){
        try {
            return ListEnvelop.getSuccess("获取成功",securityMonitoringOrderService.getPatientSleepNightRecord(patient,day));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
}

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

@ -48,6 +48,17 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ServicePackageService servicePackageService;
    @PostMapping(value = "addPatientSignList")
    @ApiOperation(value = "添加签约数据")
    public Envelop addPatientSignList () throws Exception {
        try{
            servicePackageService.addPatientSignList();
            return success("添加成功");
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "findSignOrg")
    @ApiOperation(value = "查找签约机构")
    public ListEnvelop findSignOrg (
@ -167,7 +178,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "servicePackageByTopicType")
    @ApiOperation(value = "根据服务专题获取服务项目")
    @ApiOperation(value = "根据服务专题获取服务项目--存在绑定设备的专题")
    public ObjEnvelop servicePackageByTopicType (
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient,
@ -227,9 +238,11 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "signYear", value = "签约时长 0长期 1 1年 2 2年", required = true)
            @RequestParam String signYear,
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam String doctorId) {
            @RequestParam String doctorId,
            @ApiParam(name = "labelCode", value = "能力评估结论", required = true)
            @RequestParam String labelCode) {
        try{
           JSONObject result  = servicePackageService.servicePackageSign(jsonData,doctorId,patientId,signYear);
           JSONObject result  = servicePackageService.servicePackageSign(jsonData,doctorId,patientId,signYear,labelCode);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg));
            }

+ 92 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java

@ -0,0 +1,92 @@
package com.yihu.jw.care.endpoint.statistics;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.service.statistics.DetectionPlatformService;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/***
 * @ClassName: DetectionPlatformEndpoint
 * @Description: 社区云照护平台--物联网健康监测展示平台 v1.0.0
 * @Auther: shi kejing
 * @Date: 2021/8/20 9:28
 */
@RestController
@RequestMapping(value = "open/platform")
@Api(value = "物联网健康监测展示平台v1.0.0", description = "物联网健康监测展示平台v1.0.0", tags = {"物联网健康监测展示平台v1.0.0"})
public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private DetectionPlatformService platformService;
    @GetMapping(value = "getHealthMonitoringListNew")
    @ApiOperation(value = "体征监测/安防监护")
    public PageEnvelop getHealthMonitoringListNew(
            @ApiParam(name="page",value = "page") @RequestParam(required = true) int page,
            @ApiParam(name="size",value = "size") @RequestParam(required = true) int size,
            @ApiParam(name="type",value = "type=1(健康监测)   type=2(安防检测)") @RequestParam(required = true) int type) {
        try {
            return platformService.getHealthMonitoringListNew(page,size,type);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getDeviceCompany")
    @ApiOperation(value = "设备入驻")
    public ObjEnvelop getDeviceCompany(){
        try {
            JSONObject o = platformService.getDeviceComapny();
            return success(o);
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "getDeviceType")
    @ApiOperation(value = "设备类型")
    public ListEnvelop getDeviceType(){
        try {
            return success("查询成功",200,platformService.getDeviceType());
        }catch (Exception e){
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "getDeviceByCondition")
    @ApiOperation(value = "地图展示,根据不同的条件展示不同的数据")
    public ListEnvelop<Object> getDeviceByCondition(            @ApiParam(name="categoryCode",value = "categoryCode") @RequestParam(required = false) String categoryCode,
                                                                @ApiParam(name="patient",value = "patient") @RequestParam(required = false) String patient){
        try {
            JSONArray object = platformService.getDeviceByCondition(categoryCode,patient);
            return success("查询成功",200,object);
        }catch (Exception e){
            return failedListEnvelopException(e);
        }
    }
    @GetMapping(value = "getDeviceInfo")
    @ApiOperation(value = "地图展示,根据设备sn码查询详情")
    public ObjEnvelop getDeviceInfo(            @ApiParam(name="deviceSn",value = "deviceSn") @RequestParam(required = true) String deviceSn){
        try {
            JSONObject object = platformService.getDeviceInfo(deviceSn);
            return success("查询成功",200,object);
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
}

+ 11 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -80,6 +80,17 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getAllDynamics")
    @ApiOperation(value = "综合动态v0.7.0")
    public PageEnvelop getAllDynamics(
            @RequestParam(required = true) Integer page,@RequestParam(required = true) Integer size) {
        try {
            return statisticsService.getAllDynamics(page,size);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "serviceRankingAnalysis")
    @ApiOperation(value = "服务排名分析")
    public ListEnvelop serviceRankingAnalysis(

+ 5 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/team/TeamEndpoint.java

@ -109,6 +109,8 @@ public class TeamEndpoint extends EnvelopRestEndpoint {
            for (String doctorCode : doctorCodes) {
                teamService.addMember(team, doctorCode);
            }
            team.setTeamNum( teamService.findMemCount(teamCode)+"");
            teamDao.save(team);
            return success("添加成功");
        } catch (Exception e) {
            return failedException2(e);
@ -135,7 +137,9 @@ public class TeamEndpoint extends EnvelopRestEndpoint {
                               @PathVariable("doctorCode") String doctorCode) {
        try {
            teamService.removeMember(teamCode, doctorCode);
            BaseTeamDO team = teamDao.findOne(teamCode);
            team.setTeamNum( teamService.findMemCount(teamCode)+"");
            teamDao.save(team);
            return success("移除成功");
        } catch (Exception e) {
            return failedException2(e);

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

@ -9,7 +9,6 @@ import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.BaseEmergencyWarnLogDao;
import com.yihu.jw.care.dao.security.EmergencyWarnConclusionDao;
import com.yihu.jw.care.dao.security.EmergencyWarnDoctorResponseDao;
import com.yihu.jw.care.dao.security.SecurityMonitoringOrderDao;
import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.service.common.DictService;
@ -30,7 +29,6 @@ import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnDoctorResponseDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
@ -108,6 +106,24 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    @Autowired
    private ContactsService contactsService;
    /**
     * 获取百度天气
     */
    public JSONObject getBaiduWeather(){
        try {
            String url = "https://api.map.baidu.com/weather/v1/?district_id=330100&data_type=now&ak=0vjnCSReegE7A47a941ohjv9a07ONiMC";
            String response = httpClientUtil.get(url,"UTF-8");
            JSONObject responseObj = JSONObject.parseObject(response);
            if (responseObj.getInteger("status")==0){
                JSONObject now = responseObj.getJSONObject("result").getJSONObject("now");
                return now;
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return new JSONObject();
    }
    /**
     * 新建居民紧急救助
     * @param patient
@ -164,8 +180,8 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
//            return result;
//        }
        //签约防走失服务包
        String sql ="SELECT i.code,i.team_code,i.org_code,i.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
        String sql ="SELECT i.code,r.team_code,pack.org_code,pack.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+assistanceDO.getPatient()+"' and i.code='emergencyAssistance' ";
        List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
        if (items.size()==0){
@ -575,7 +591,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    public JSONObject existApplyStatus(String patient){
        JSONObject result = new JSONObject();
        JSONObject tmpObj = new JSONObject();
        List<EmergencyAssistanceDO> assistanceDO = emergencyAssistanceDao.findByProxyPatientAndStatus(patient,1);
        List<EmergencyAssistanceDO> assistanceDO = emergencyAssistanceDao.findByPatientAndStatus(patient,1);
        if (assistanceDO.size()==0){
            tmpObj.put("exist","false");
            result.put(ResponseContant.resultFlag, ResponseContant.success);
@ -966,10 +982,10 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
     */
    public PageEnvelop getEmergencyAssistanceList(Integer page, Integer size,String doctor){
        page = page>0?page-1:0;
        String sql = " select '20' as OrderType,ord.id,ord.doctor,ord.status,p.name,'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time" +
        String sql = " select '20' as OrderType,ord.id,ord.doctor,ord.status,ord.patient,ord.patient_name as name,p.name as doctorName,'紧急呼叫' as serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time" +
                " from base_emergency_assistance_order ord INNER JOIN base_doctor p on ord.doctor = p.id where ord.doctor='"+doctor+"'" ;
        sql +="UNION " +
                "select  '22' as 'OrderType',ord.id,ord.doctor,ord.status,p.name,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "select  '22' as 'OrderType',ord.id,ord.doctor,ord.status,ord.patient,ord.patient_name as name,p.name as doctorName,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "from base_security_monitoring_order ord INNER JOIN base_doctor p on ord.doctor = p.id  where ord.doctor='"+doctor+"'" ;
        String countSql = "select count(id) from ("+sql+")A ";
        long count = jdbcTemplate.queryForObject(countSql,long.class);

+ 18 - 21
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/birthday/BirthdayWishesService.java

@ -177,10 +177,10 @@ public class BirthdayWishesService {
                "p.idcard, p.photo," +
                " CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END date " +
                "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 r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = r.team_code and m.doctor_code = '"+doctor+"' ) "+
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r,base_service_package pack, " +
                "base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient and r.service_package_id = pack.id  " +
                "and m.team_code = r.team_code and m.doctor_code = '"+doctor+"' ) "+
                " and (p.archive_status<>2 or p.archive_status is null) " +
                "AND CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END =  '" + dateString + "' " ;
        List<Map<String, Object>> patientInfos =  jdbcTemplate.queryForList(sql);
@ -224,9 +224,9 @@ public class BirthdayWishesService {
        String sql = "SELECT DISTINCT p.id " +
                "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 r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = r.team_code and m.doctor_code = '"+doctor+"' ) "+
                "base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient and sr.id = r.sign_id " +
                "and m.team_code = r.team_code and m.doctor_code = '"+doctor+"' ) "+
                " and (p.archive_status<>2 or p.archive_status is null) " +
                "AND CASE LENGTH(p.idcard) WHEN  18 then SUBSTR(p.idcard,11,4) when 15 then SUBSTR(p.idcard, 9,4) END =  '" + dateString + "'  " ;
        List<String> patientInfos =  jdbcTemplate.queryForList(sql,String.class);
@ -258,10 +258,10 @@ public class BirthdayWishesService {
        String sqlCount = "SELECT count(distinct p.idcard) ";
        String whereSql = "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 r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = r.team_code ";
                "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r,base_service_package pack , " +
                "base_team_member m " +
                "WHERE  sr.id = r.sign_id and sr.patient = a.patient and  r.service_package_id = pack.id " +
                "and m.team_code = r.team_code ";
        //根据权限获取生日居民列表
        if (roleType == 1) {
@ -269,19 +269,19 @@ public class BirthdayWishesService {
        } else {//管理员
            switch (currentUserRoleLevel) {
                case "1": {//省
                    whereSql += " and i.org_code in ( select org.code from base_org org where org.province_code = '"+currentUserRole+"' and org.del=1 )  ";
                    whereSql += " and pack.org_code in ( select org.code from base_org org where org.province_code = '"+currentUserRole+"' and org.del=1 )  ";
                    break;
                }
                case "2": {//市
                    whereSql += " and i.org_code in ( select org.code from base_org org where org.city_code = '"+currentUserRole+"' and org.del=1 )  ";
                    whereSql += " and pack.org_code in ( select org.code from base_org org where org.city_code = '"+currentUserRole+"' and org.del=1 )  ";
                    break;
                }
                case "3": {//区
                    whereSql += " and i.org_code in ( select org.code from base_org org where org.town_code = '"+currentUserRole+"' and org.del=1 )  ";
                    whereSql += " and pack.org_code in ( select org.code from base_org org where org.town_code = '"+currentUserRole+"' and org.del=1 )  ";
                    break;
                }
                case "4": {//社区机构
                    whereSql += " and i.org_code = '" + currentUserRole + "' ";
                    whereSql += " and pack.org_code = '" + currentUserRole + "' ";
                    break;
                }
            }
@ -403,13 +403,13 @@ public class BirthdayWishesService {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd");
        String createTime = f.format(new Date())+" 00:00:00";
        //医生今日推送的居民
        List<BirthDayWishesToPatient> sendPatientList = findSendPatientByCreateTime(p.toString(),createTime);
        List<BirthDayWishesToPatient> sendPatientList = findSendPatientByCreateTime(createTime);
        Set<String> sendPatient = sendPatientList.stream().map(BirthDayWishesToPatient::getPatientCode).collect(Collectors.toSet());
        Set<String> openidSet = new HashSet<>();
        BaseDoctorDO doctor = doctorDao.findById(doctorCode);
        String sql = " select * from ( select p.id as patient,p.name,we.openid from base_patient p inner join  base_patient_wechat we on p.id = we.patient_id and we.patient_id in ( "+p.toString()+") " +
        String sql = " select * from ( select p.id as patient,p.name,we.openid from base_patient p Left join  base_patient_wechat we on p.id = we.patient_id where p.id in ( "+p.toString()+") " +
                "  order by we.create_time desc )A group by A.patient  ";
        List<Map<String, Object>> patientInfos = jdbcTemplate.queryForList(sql);
@ -501,13 +501,10 @@ public class BirthdayWishesService {
     * @param
     * @return
     */
    public List<BirthDayWishesToPatient> findSendPatientByCreateTime(String patient,String createTime) {
    public List<BirthDayWishesToPatient> findSendPatientByCreateTime(String createTime) {
        StringBuffer sql = new StringBuffer("select patient_code patientCode from  birthday_wishes_to_patient  "+
                " where user_type=1 and create_time>'" + createTime + "' ");
        if (StringUtils.isNotBlank(patient)){
            sql.append(" and patient_code in ( "+patient+" ) ") ;
        }
        sql.append(" limit 0,500000 ");
        List<BirthDayWishesToPatient> patientList = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper<>(BirthDayWishesToPatient.class));
        return patientList;

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

@ -203,10 +203,10 @@ public class ContactsService {
        String sql =  "select * from base_org org  " ;
        if (StringUtils.isNotBlank(patient)){
            sql +=" LEFT JOIN ( " +
                    "SELECT  DISTINCT i.org_code,'1' as signFlag FROM  base_service_package_sign_record sr,  base_service_package_record r, " +
                    " base_service_package_item i WHERE  sr.id = r.sign_id and sr.status=1 and sr.patient = '"+patient+"'" +
                    " AND r.service_package_id = i.service_package_id " +
                    " AND i.del = 1  AND sr.`status` = 1)A on org.code = A.org_code ";
                    "SELECT  DISTINCT pack.org_code,'1' as signFlag FROM  base_service_package_sign_record sr,  base_service_package_record r, " +
                    " base_service_package pack  WHERE  sr.id = r.sign_id and sr.status=1 and sr.patient = '"+patient+"'" +
                    "  and r.service_package_id = pack.id  " +
                    " AND sr.`status` = 1)A on org.code = A.org_code ";
        }
        sql +=  " where org.del=1 and org.type=3 " ;
        result = jdbcTemplate.queryForList(sql);
@ -317,9 +317,8 @@ public class ContactsService {
                        }
                    }
                    if (StringUtils.isNotBlank(del_num)) {
//                        String response = networkCardService.setPatientContacts(sim, null, null, "4", del_num, null);
//                        if (StringUtils.isNotBlank(response)) {
                        if (StringUtils.isNotBlank("111")) {//todo 对接时不做
                        String response = networkCardService.setPatientContacts(sim, null, null, "4", del_num, null);
                        if (StringUtils.isNotBlank(response)) {//todo 对接时不做
                            String[] DelNums = del_num.split("_");
                            for (String tmp:DelNums){
                                if (!delSuccess.contains(tmp)){//本次已删除过 不再作删除操作

+ 10 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java

@ -61,10 +61,9 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	 * @param isFirst
	 * @throws Exception
	 */
	@Transactional
	@Transactional(rollbackFor = Exception.class)
	public void updateAfterBinding(DevicePatientDevice devicePatientDevice, Date grantTime, boolean isFirst)throws Exception{
		DeviceDetail deviceDetail = deviceDetailDao.findBySn(devicePatientDevice.getDeviceSn());
		int bind = deviceDetail.getIsBinding();
		long adminTeam=0L;
		String hospital = "";
		String isFirstBind = "";
@ -77,8 +76,12 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
		}
		//设备表没有数据则插入一条数据
		if (deviceDetail==null){
			insertDevice(devicePatientDevice,String.valueOf(adminTeam),hospitalName,hospital,"",doctorCode,doctorName,1);
			deviceDetail = deviceDetailDao.findBySn(devicePatientDevice.getDeviceSn());
			deviceDetail = insertDevice(devicePatientDevice,String.valueOf(adminTeam),hospitalName,hospital,"",doctorCode,doctorName,1);
		}
		Integer bind = deviceDetail.getIsBinding();
		if(bind==null){
			bind = 0;
		}
		isFirstBind = deviceDetail.getBindingCount();
@ -116,7 +119,7 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	 * @param isBind 0未绑定  1已绑定
	 * @throws Exception
	 */
	public void insertDevice(DevicePatientDevice devicePatientDevice, String adminTeam, String orgName, String orgCode, String bindCount, String doctorCode, String doctorName, int isBind)throws Exception{
	public DeviceDetail insertDevice(DevicePatientDevice devicePatientDevice, String adminTeam, String orgName, String orgCode, String bindCount, String doctorCode, String doctorName, int isBind)throws Exception{
		//获取原始数据
		DeviceDetail deviceDetail = new DeviceDetail();
		BasePatientDO patient = patientDao.findById(devicePatientDevice.getUser());
@ -133,6 +136,8 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
		deviceDetail.setOrgName(orgName);
		deviceDetail.setGrantDoctor(doctorCode);
		deviceDetail.setGrantDoctorName(doctorName);
		deviceDetail.setContactStatus(1);
		deviceDetail.setContactStatusTime(new Date());
		if (isBind>0){
			deviceDetail.setIsGrant(1);
			deviceDetail.setIsBinding(1);

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

@ -4,25 +4,29 @@ package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.BaseSleepPlanDao;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.wechat.WeiXinAccessTokenUtils;
import com.yihu.jw.care.util.ConcealUtil;
import com.yihu.jw.care.util.MyJdbcTemplate;
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.care.device.BaseSleepPlan;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
@ -43,6 +47,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -87,6 +92,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    private HttpClientUtil httpClientUtil;
    @Autowired
    private YsDeviceService ysDeviceService;
    @Autowired
    private BaseSleepPlanDao sleepPlanDao;
    @Autowired
    WeiXinAccessTokenUtils tokenUtils;
@ -103,6 +110,10 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    private ContactsService contactsService;
    @Autowired
    private HealthIndexUtil healthIndexUtil;
    @Autowired
    private EmergencyAssistanceService emergencyAssistanceService;
    @Autowired
    private SecurityMonitoringOrderService securityMonitoringOrderService;
    @PostConstruct
    public void init() {
@ -117,6 +128,60 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        relations.put(8, "免疫关联");
    }
    /**
     * 获取烟雾 燃气浓度
     * @param patient
     */
    public JSONObject concentrationMessage(String patient){
        JSONObject result = new JSONObject();
        String sql = "SELECT CONCAT(r.value,r.unit) value from wlyy_patient_device pd,base_device_health_index r " +
                "WHERE pd.device_sn = r.device_sn and pd.`user` = '"+patient+"' ";
        String sql1 = sql + " and pd.category_code='14' ORDER BY r.create_time desc LIMIT 1";
        String sql2 = sql + " and pd.category_code='15' ORDER BY r.create_time desc LIMIT 1";
        List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql1);
        if(list1.size()==0){
            result.put("methane","-1");
        }else{
            result.put("methane",list1.get(0).get("value"));
        }
        List<Map<String,Object>> list2 = jdbcTemplate.queryForList(sql2);
        if(list2.size()==0){
            result.put("smoke","-1");
        }else{
            result.put("smoke",list2.get(0).get("value"));
        }
        return result;
    }
    /**
     * 环境信息
     * @return
     */
    public JSONObject envMessage(String patient){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("concentration",concentrationMessage(patient));
        jsonObject.put("weather",emergencyAssistanceService.getBaiduWeather());
        return jsonObject;
    }
    /**
     * 燃气浓度
     * @param patient
     */
    public List<Map<String,Object>> gasConcentration(String patient,String date){
        String sql = "SELECT r.value,r.create_time from wlyy_patient_device pd,base_device_health_index r " +
                "WHERE pd.device_sn = r.device_sn and pd.`user` = '"+patient+"' ";
        sql += " and pd.category_code='14' and r.create_time>'"+date+" 00:00:00' and r.create_time<'"+date+" 23:59:59'  ORDER BY r.create_time desc ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
    /**
     * 验证sn码 先调总部接口 未注册才查询本地数据库,如果也没有才不能绑定
     * 屏蔽总部调总部接口,直接本地数据库验证,modify by Hmf on 2020.1.15
@ -136,13 +201,14 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    /**
     * 保存患者设备
     */
    public boolean saveDevice(DevicePatientDevice devicePatientDevice) throws Exception {
    public int saveDevice(DevicePatientDevice devicePatientDevice, BaseSleepPlan sleepPlan, String iotDeviceSn, String safeAreaGz) throws Exception {
        //判断sn码是否被使用
        String sn = devicePatientDevice.getDeviceSn();
        String type = devicePatientDevice.getCategoryCode();
        Long deviceId = devicePatientDevice.getDeviceId();
        String userType = devicePatientDevice.getUserType();
        String sosAddress = null;
        String url ="";
        if (userType == null) {
            userType = "-1";
            devicePatientDevice.setUserType("-1");
@ -150,7 +216,13 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        if (type.equals("7")){
            if (StringUtils.isBlank(devicePatientDevice.getSosAddress())){
                return false;
                return 0;
            }
        }
        if (type.equals("13")){
            if (StringUtils.isBlank(devicePatientDevice.getSosAddress())){
                return 0;
            }
        }
@ -163,7 +235,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                    needVerify = false;
                }
            } else {
                throw new Exception("不存在该条记录!");
//                throw new Exception("不存在该条记录!");
                return -4;
            }
        }
@ -171,7 +244,19 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        if (needVerify) {
            DevicePatientDevice device = patientDeviceDao.findByDeviceSnAndUserType(sn, userType);
            if (device != null && !device.getId().equals(devicePatientDevice.getId()) && device.getDel() == 0) {
                throw new Exception("sn码" + sn + "已被使用!");
                //V1.0.0    监控器、报警器、燃气传感器 烟雾传感器支持一个设备绑定多个居民
                //监控器 12   报警器 7  14  15
                if ("12".equals(type) || "14".equals(type) || "15".equals(type) || "7".equals(type) ) {
                    if (devicePatientDevice.getUser().equals(device.getUser())) {
                        System.out.println("居民已经绑定此sn码:"+sn);
                        return -5;
                    }
                    System.out.println("此类设备支持多绑定");
                } else {
                    System.out.println("sn码" + sn + "已被使用!");
                    return -3;
                }
            }
        }
        devicePatientDevice.setCzrq(new Date());
@ -180,14 +265,30 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        BasePatientDO patient = patientDao.findById(devicePatientDevice.getUser());
        devicePatientDevice.setUserIdcard(patient.getIdcard());
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if(checkDeviceSn(sn)){
            if ("13".equals(type)){ //睡眠带
                if (StringUtils.isBlank(sleepPlan.getGetUpTime()) || StringUtils.isBlank(sleepPlan.getNightRestTime())) {
                    String message = "请完善睡眠时间规划";
                    return -2;
                }
                sleepPlanDao.save(sleepPlan);
            }
            if ("17".equals(type)) {    //判断设备是不是随身wifi,如果是,则添加对应的设备sn
                devicePatientDevice.setIotDeviceSn(iotDeviceSn);
            }
            if ("16".equals(type)) {   //判断设备是不是拐杖,如果是拐杖,需要保存围栏地址
                devicePatientDevice.setSafeAreaGz(safeAreaGz);
            }
            patientDeviceDao.save(devicePatientDevice);
        }else {
            String message = "设备不存在";
            throw new Exception(message);
            return -1;
        }
        return true;
        return 1;
    }
    public int delDeviceByDeviceSn(String deviceSn){
@ -295,6 +396,11 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                "when category_code=4 then '智能手表'\n" +
                "when category_code=7 then '报警器'\n" +
                "when category_code=12 then '监控器'\n" +
                "when category_code=13 then '睡眠带'\n" +
                "when category_code=14 then '可燃气体探测器'\n" +
                "when category_code=15 then '火灾探测报警器'\n" +
                "when category_code=16 then '智能拐杖'\n" +
                "when category_code=17 then '随身WiFi'\n" +
                "else '未知'\n" +
                "end as categoryName\n" +
                " from dm_device where del=1 GROUP BY category_code ";
@ -310,6 +416,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                "when category_code=4 then '智能手表'\n" +
                "when category_code=7 then '报警器'\n" +
                "when category_code=12 then '监控器'\n" +
                "when category_code=13 then '睡眠带'\n" +
                "else '未知'\n" +
                "end as categoryName\n" +
                " from dm_device where del=1 and category_code='"+category_code+"' GROUP BY model ";
@ -778,7 +885,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
     * @param deviceSn 设备sn码
     * @return
     */
    public JSONObject getPatientDeviceDetail(String patient,String deviceSn){
    public JSONObject getPatientDeviceDetail(String patient,String deviceSn,String day) throws Exception {
        JSONObject result = new JSONObject();
        BasePatientDO patientDO = patientDao.findById(patient);
        if (null==patientDO){
@ -797,7 +904,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
            }else {
                String sql = "select dd.photo,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime " +
                        "from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model and pd.device_sn = wd.device_code \n" +
                        "where 1=1 and  pd.del=0 and pd.device_sn ='"+deviceSn+"' ";
                        "where 1=1 and  pd.del=0 and pd.device_sn ='"+deviceSn+"' group by pd.user";
                Map<String,Object> devInfo = jdbcTemplate.queryForMap(sql);
                devInfo.put("patient",patient);
                devInfo.put("patientName",patientDO.getName());
@ -805,8 +912,48 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                if ("4".equals(device.getCategoryCode())||"7".equals(device.getCategoryCode())){
                    devInfo.put("sosContactsDOS",contactsService.getPatientSosContacts(patient));
                }
                com.alibaba.fastjson.JSONObject devInfoObj = JSON.parseObject(JSON.toJSONString(devInfo, SerializerFeature.WriteMapNullValue));
                switch (device.getCategoryCode()){
                    case "1"://血压设备
                        break;
                    case "2"://血糖设备
                        break;
                    case "4"://手表 围栏与轨迹
                        devInfoObj =  securityMonitoringOrderService.patientSignTopicInfo(devInfoObj,patient,"preventLost");
                        //轨迹动态
                        break;
                    case "7"://报警器 紧急工单
                        break;
                    case "12"://监控 视频地址
                        com.alibaba.fastjson.JSONObject tmp =ysDeviceService.getDeviceLiveAddress(patient,deviceSn,1,null);
                        devInfoObj.put("monitorInfoStatus",tmp.getIntValue(ResponseContant.resultFlag));
                        if (tmp.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
                            devInfoObj.put("monitorInfo",tmp.getString(ResponseContant.resultMsg));
                        }
                        else {
                            devInfoObj.put("monitorInfo",tmp.getJSONObject(ResponseContant.resultMsg));
                        }
                        break;
                    case "13"://睡眠带 获取当天睡眠详情
                        securityMonitoringOrderService.preventOutOfBed(devInfoObj,patient,false,day);
                        break;
                    case "14"://气感报警器 当天监测记录以及最新浓度
                        if (StringUtils.isBlank(day)){
                            day = DateUtil.getStringDateShort();
                        }
                        List<Map<String,Object>> listTmp = gasConcentration(patient,day);
                        devInfoObj.put("monitorInfo",listTmp);
                        devInfoObj.put("day",day);
                        securityMonitoringOrderService.preventGasLeakage(devInfoObj,patient,false);
                        break;
                    case "15"://烟感报警器 获取最新浓度
                        securityMonitoringOrderService.preventFire(devInfoObj,patient,false);
                        devInfoObj.put("day",DateUtil.getStringDateShort());
                        break;
                }
                result.put(ResponseContant.resultFlag,ResponseContant.success);
                result.put(ResponseContant.resultMsg,JSON.parseObject(JSON.toJSONString(devInfo, SerializerFeature.WriteMapNullValue)));
                result.put(ResponseContant.resultMsg,JSON.toJSONString(devInfoObj,SerializerFeature.WriteMapNullValue));
            }
        }
        return result;
@ -833,24 +980,8 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
                    case "2"://血糖设备
                        result = getHealthIndex(result,deviceSn,patient,page,pageSize);
                        break;
                    case "4"://手表 紧急工单与安防工单
                        result = getEmeWarn(result,deviceSn,patient,page,pageSize);
                        break;
                    case "7"://报警器 紧急工单
                        result = getEmeWarn(result,deviceSn,patient,page,pageSize);
                        break;
                    case "12"://监控
                        com.alibaba.fastjson.JSONObject tmp =ysDeviceService.getDeviceLiveAddress(patient,deviceSn,1,null);
                        result.put("monitorInfoStatus",tmp.getIntValue(ResponseContant.resultFlag));
                        if (tmp.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
                            result.put("monitorInfo",tmp.getString(ResponseContant.resultMsg));
                        }
                        else {
                            result.put("monitorInfo",tmp.getJSONObject(ResponseContant.resultMsg));
                        }
                        break;
                    default://安防设备
                        result = null;
                        result  = getEmeWarn(result,deviceSn,patient,page,pageSize);
                        break;
                }
            }
@ -863,7 +994,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    public JSONObject getHealthIndex(JSONObject result,String deviceSn,String patient,Integer page,Integer pageSize){
        String sqlCount = "select count(id) from wlyy_patient_health_index where user ='"+patient+"' and device_sn='"+deviceSn+"' " +
                " and del=1 ";
        String sql = "select *,CAST(DATE_FORMAT(record_date,'%Y-%m-%d %H:%i:%S') as char) sign_status from wlyy_patient_health_index where user ='"+patient+"' and device_sn='"+deviceSn+"' " +
        String sql = "select *,CAST(DATE_FORMAT(record_date,'%Y-%m-%d %H:%i:%S') as char) record_date from wlyy_patient_health_index where user ='"+patient+"' and device_sn='"+deviceSn+"' " +
                " and del=1 order by record_date desc limit "+page*pageSize+","+pageSize;
        long count = jdbcTemplate.queryForObject(sqlCount,long.class);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
@ -1065,6 +1196,73 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return response.getBody();
    }
    /**
     *获取设备轨迹
     * @param deviceSn
     * @param time_begin YYYYMMDD 日期
     * @return
     */
    public com.alibaba.fastjson.JSONObject getX1Locations(String deviceSn,String time_begin){
        String url = AqgConfig.X1_locations+"?device="+deviceSn+"&depth="+1+"&rows_per_page="+300;
        if (StringUtils.isNotBlank(time_begin)){
            url += "&time_begin="+time_begin;
        }
        Map<String,Object> headers = new HashMap<>();
        headers.put("Accept", MediaType.APPLICATION_JSON.toString());
        headers.put("Cookie", getCookie());
        String  responseStr = httpClientUtil.get(url,"utf-8",headers);
        com.alibaba.fastjson.JSONObject result = JSON.parseObject(responseStr);
        return result;
    }
    public com.alibaba.fastjson.JSONObject getSleepDeviceInfo(String deviceSn){
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        param.add("mac", deviceSn);
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(AqgConfig.sleepDevice_info, param, HttpMethod.GET, getCookie());
        return response.getBody();
    }
    public com.alibaba.fastjson.JSONObject sleepDeviceEdit(String deviceSn,Integer heart_check_enable,Integer breath_check_enable,Integer offbed_check_enable,
                                                           Integer theshold_heartrate_h,Integer theshold_heartrate_l,Integer theshold_breath_h,Integer theshold_breath_l,
                                                           Integer offbed_long,Integer check_time_begin,Integer check_time_end){
        String url = MessageFormat.format(AqgConfig.sleepDevice_edit, deviceSn);
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if (null!=heart_check_enable){
            param.add("heart_check_enable", heart_check_enable+"");
        }
        if (null!=breath_check_enable){
            param.add("breath_check_enable", breath_check_enable+"");
        }
        if (null!=offbed_check_enable){
            param.add("offbed_check_enable", offbed_check_enable+"");
        }
        if (null!=theshold_heartrate_h){
            param.add("theshold_heartrate_h", theshold_heartrate_h+"");
        }
        if (null!=theshold_heartrate_l){
            param.add("theshold_heartrate_l", theshold_heartrate_l+"");
        }
        if (null!=theshold_breath_h){
            param.add("theshold_breath_h", theshold_breath_h+"");
        }
        if (null!=theshold_breath_l){
            param.add("theshold_breath_l", theshold_breath_l+"");
        }
        if (null!=offbed_long){
            param.add("offbed_long", offbed_long+"");
        }
        if (null!=check_time_begin){
            param.add("check_time_begin", check_time_begin+"");
        }
        if (null!=check_time_end){
            param.add("check_time_end", check_time_end+"");
        }
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.POST, getCookie());
        return response.getBody();
    }
    /******************************************* 爱牵挂设备end *****************************************************/
}

+ 26 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientHealthIndexService.java

@ -10,6 +10,7 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.patient.Patient;
import com.yihu.jw.message.dao.MessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
@ -1604,4 +1605,29 @@ public class PatientHealthIndexService extends BaseJpaService<DevicePatientHealt
    public DevicePatientHealthIndex getHealthIndexById(Long id) {
        return patientHealthIndexDao.findOne(id);
    }
    public List<Map<String,Object>> getErrorHealthIndexPatients(String doctor){
        String sql = " select count(id),patient,name,photo,mobile,record_date from (\n" +
                "select idx.id,p.id patient,p.name,p.photo,DATE_FORMAT(idx.record_date,'%Y-%m-%d %H:%i:%S')record_date ,p.mobile from wlyy_patient_health_index idx,base_patient p " +
                "where  idx.user = p.id and  status=1 and (manage_result=0 or manage_result is null)  and EXISTS ( " +
                " SELECT 1 from base_service_package_sign_record sr,base_service_package_record r ,base_team_member m where " +
                "idx.user = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and   m.team_code = r.team_code  " +
                " and sr.`status`=1  and m.doctor_code = '"+doctor+"' and m.del = '1') order by idx.record_date " +
                " desc)A GROUP BY A.patient order by record_date desc ";
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        return result;
    }
    public List<Map<String,Object>> getErrorHealthIndexByPatients(String patient){
        String sql = " select *,cast(DATE_FORMAT(max(idx.record_date),'%Y-%m-%d %H:%i:%S') as char)record_date  from  wlyy_patient_health_index idx where user='"+patient+"' and  " +
                "status=1 and (manage_result=0 or manage_result is null) ";
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        return result;
    }
    @Transactional
    public void handleHealthIndex(String id){
        String sql = " update wlyy_patient_health_index a set a.manageResult=1 where a.user='"+id+"' and  status=1 and (manage_result=0 or manage_result is null)  ";
        jdbcTemplate.execute(sql);
    }
}

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

@ -76,9 +76,9 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        //签约老人数、紧急救助完成数、生活照料完成数、安防监护完成数
        String sql1 = "SELECT COUNT(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.status=1  AND r.service_package_id = i.service_package_id " +
                " AND i.del = 1 and m.team_code = r.team_code " +
                " base_service_package_sign_record sr, base_service_package_record r, base_team_member m " +
                " WHERE  sr.id = r.sign_id and sr.status=1 " +
                "  and m.team_code = r.team_code " +
                "  and m.del = '1' and m.doctor_code = '"+doctorId+"'";
        Integer signNum = jdbcTemplate.queryForObject(sql1,Integer.class);
        String sqlLife= "SELECT COUNT(*) from base_life_care_order where `status` = 2";
@ -593,8 +593,8 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        //人文关怀
        try {
            Integer counts = birthdayWishesService.getPatientByDoctorCount(doctor);
            if (count>0){
                result.put("patientCare",count);
            if (counts>0){
                result.put("patientCare",counts);
            }
        }catch (Exception e){
            e.printStackTrace();

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

@ -130,7 +130,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
     * @param member  成员
     * @return
     */
    public int addMember(String patient, String member, String captcha, String password, int relation) throws Exception {
    public int addMember(String client_id,String patient, String member, String captcha, String password, int relation) throws Exception {
        if (patient.equals(member)) {
            return 0;
        }
@ -815,7 +815,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
    }
    @Transactional
    public int addMemberByCaptcha(String patient, String idcard, String name, String mobile, Integer archiveType, String captcha, int relation) throws Exception {
    public int addMemberByCaptcha(String client_id,String patient, String idcard, String name, String mobile, Integer archiveType, String captcha, int relation) throws Exception {
        BasePatientDO p = patientDao.findById(patient);
        if (p == null) {

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

@ -37,10 +37,9 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
        String sql = "SELECT COUNT(a.id) num,dict.dict_code labelCode,dict.dict_value labelName " +
                " from wlyy_hospital_sys_dict dict " +
                "LEFT JOIN (SELECT DISTINCT l.id,l.label_code  " +
                "from base_service_package_sign_record sr,base_service_package_record r,  " +
                "                base_service_package_item i,base_patient p,wlyy_patient_label l " +
                "                WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
                "                and i.del = 1 and i.team_code = '"+teamCode+"' " +
                "from base_service_package_sign_record sr,base_service_package_record r  " +
                "                ,base_patient p,wlyy_patient_label l " +
                "                WHERE sr.id = r.sign_id and sr.status=1 and r.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+"' and dict_code<>5  " +
@ -65,9 +64,9 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
        sql +=",(select COUNT(*) from wlyy_patient_device a where a.`user` = p.id) deviceFlag ";
        String countSql = "SELECT count(DISTINCT p.id) ";
        String filters = "from base_service_package_sign_record sr,base_service_package_record r,  " +
                "                base_service_package_item i,base_patient p,wlyy_patient_label l " +
                "                WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
                "                and i.del = 1 and i.team_code =  '"+teamCode+"' " +
                "                base_patient p,wlyy_patient_label l " +
                "                WHERE sr.id = r.sign_id and sr.status=1  " +
                "                and r.team_code =  '"+teamCode+"' " +
                "                and sr.patient = p.id and p.id = l.patient and l.label_type = 1 and l.label_code =  '"+labelCode+"' ";
        if(StringUtils.isNotBlank(name)){
            filters += " and (p.name like '%"+name+"%' or p.idcard like '%"+name+"%') ";

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

@ -158,6 +158,12 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        }
        // 获取服务次数
        lifeCareOrderDO.setFeeDetailList(getFeeDetails(id));
        if (StringUtils.isNotBlank(lifeCareOrderDO.getDoctor())){
            BaseDoctorDO doctorDO = doctorDao.findById(lifeCareOrderDO.getDoctor());
            if (null!=doctorDO){
                lifeCareOrderDO.setDoctorPhone(doctorDO.getMobile());
            }
        }
        return lifeCareOrderDO;
    }
@ -784,6 +790,8 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        //3 已签到
        lifeCareOrderDO.setStatus(3);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
        lifeCareOrderDO.setDoctor(doctorId);
        lifeCareOrderDO.setDoctorName(doctorDO.getName());
        lifeCareOrderDO.setSignDoctor(doctorId);
        lifeCareOrderDO.setSignDoctorName(doctorDO.getName());
        lifeCareOrderDO.setUpdateTime(new Date());

+ 22 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/BaseServiceNewsService.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.service.message;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.message.BaseServiceNewsDao;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.message.BaseServiceNews;
import com.yihu.jw.restmodel.iot.device.WlyyPatientDeviceVO;
@ -13,6 +14,7 @@ import org.springframework.data.domain.Sort.Direction;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -33,13 +35,15 @@ public class BaseServiceNewsService {
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DeviceService deviceService;
    /**
     * 查找机构坐标
     * @return
     */
    public List<Map<String,Object>> findOrgLocations(){
        String sql = "SELECT code,name,brief,address,photo,mobile,longitude,latitude from base_org WHERE type in ('3','4') and del =1";
        String sql = "SELECT code,name,brief,address,photo,mobile,longitude,latitude,type from base_org WHERE type in ('3','4') and del =1";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
@ -49,7 +53,7 @@ public class BaseServiceNewsService {
     * @return
     */
    public List<Map<String,Object>> findPatinetByName(String name){
        String sql = "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,CAST(archive_type AS char) type from base_patient p\n" +
        String sql = "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,p.pad_imei,p.openid,CAST(archive_type AS char) type from base_patient p\n" +
                "WHERE p.del = 1 and p.name like '%"+name+"%'";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        List<DevicePatientDevice> feeDetail = patientDeviceDao.findByAll();
@ -57,6 +61,13 @@ public class BaseServiceNewsService {
                .collect(Collectors.groupingBy(DevicePatientDevice::getUser));
        for (Map<String,Object> map:list){
            String idcard = map.get("idcard").toString();
            String devices= deviceService.getPatientDeviceCategoryCode(map.get("id").toString());
            if ("0".equals(devices)){
                map.put("category",new ArrayList<>());
            }else {
                String[] ss = devices.split(",");
                map.put("category",ss);
            }
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            List<DevicePatientDevice> patientDevices = byDept1.get(map.get("id"));
            map.put("devices",patientDevices);
@ -70,13 +81,20 @@ public class BaseServiceNewsService {
     * @return
     */
    public List<Map<String,Object>> findPatinetLocations(){
        String sql = "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,archive_type type from base_doctor_patient_tmp t,base_patient p " +
        String sql = "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,archive_type type,p.pad_imei,p.openid from base_doctor_patient_tmp t,base_patient p " +
                "WHERE t.patient = p.id and t.del=1 and t.`status`=1 and p.del =1 " +
                "UNION  " +
                "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,archive_type type from base_service_package_sign_record t,base_patient p " +
                "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,archive_type type,p.pad_imei,p.openid from base_service_package_sign_record t,base_patient p " +
                "WHERE t.patient = p.id and t.`status`=1 and p.del =1";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){
            String devices= deviceService.getPatientDeviceCategoryCode(map.get("id").toString());
            if ("0".equals(devices)){
                map.put("devices",new ArrayList<>());
            }else {
                String[] ss = devices.split(",");
                map.put("devices",ss);
            }
            String idcard = map.get("idcard").toString();
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
        }

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

@ -21,10 +21,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
 * Created by Bing on 2021/4/10.
@ -49,7 +47,7 @@ public class DoctorMessageService {
    /**
     *
     * @param doctor
     * @param type  11床位申请,11安全监护 ,12紧急救助
     * @param type  11床位申请,11安全监护 ,12紧急救助,13体征异常消息
     * @return
     */
    public JSONObject findDoctorAllMessage(String doctor,String type){
@ -92,10 +90,10 @@ public class DoctorMessageService {
            List<Map<String,Object>> listTmp = new ArrayList<>();
            String sql ="select count(*) count,patient_name,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time,serve_desc from base_security_monitoring_order ord where 1=1 " +
                    "and status <>-1 and status<> 0  ";
            sql+= "and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i ," +
            sql+= "and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r," +
                    "base_team_member m " +
                    "where ord.patient = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and " +
                    " r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' and m.doctor_code = '"+doctor+"' and m.del = '1') ";
                    "  m.team_code = r.team_code   and sr.`status`=1  and m.doctor_code = '"+doctor+"' and m.del = '1') ";
            sql+=" order by create_time asc ";
            Map<String,Object> sqlResult  = jdbcTemplate.queryForMap(sql);
            if (sqlResult.containsKey("count")){
@ -134,6 +132,16 @@ public class DoctorMessageService {
            }
            result.put("assistance",tmpJson);
        }
        if (typeNull||type.equals("13")){//居民体征异常消息
            JSONObject tmpJson = new JSONObject();
            Map<String,Object> tmpObj = new HashMap<>();
            String sql = " select count(idx.id) count,DATE_FORMAT( max(idx.record_date),'%Y-%m-%d %H:%i:%S') record_date from wlyy_patient_health_index idx where status=1 and (manage_result=0 or manage_result is null) " +
                    "and  EXISTS ( SELECT 1 from base_service_package_sign_record sr,base_service_package_record r ,base_team_member m " +
                    " where idx.user = CONVERT(sr.patient USING utf8) and  sr.id = r.sign_id and sr.status=1 and m.team_code = r.team_code " +
                    "  and sr.`status`=1  and m.doctor_code = '"+doctor+"' and m.del = '1')  order by idx.record_date desc   ";
            tmpObj = jdbcTemplate.queryForMap(sql);
            result.put("errorHealthIndex",tmpObj);
        }
        return result;
    }
@ -146,9 +154,9 @@ public class DoctorMessageService {
            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" +
                    "SELECT 1 from base_service_package_sign_record sr,base_service_package_record r, \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 = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' \n" +
                    "  m.team_code = r.team_code  and sr.`status`=1  \n" +
                    "and m.doctor_code = '"+doctor+"' and m.del = '1') \n" +
                    "order by create_time DESC ";
@ -159,7 +167,7 @@ public class DoctorMessageService {
                        "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 = r.team_code  and i.del = 1 and sr.`status`=1  and i.code='preventLost' \n" +
                        "r.service_package_id = i.service_package_id and  m.team_code = r.team_code  and i.del = 1 and sr.`status`=1   \n" +
                        "and m.doctor_code = '"+doctor+"' and m.del = '1') ";
            }

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

@ -5,10 +5,13 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.CapacityAssessmentRecordService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
@ -25,6 +28,7 @@ import com.yihu.mysql.query.BaseJpaService;
import com.yihu.utils.security.MD5;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -63,6 +67,12 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    private PatientFamilyMemberService familyMemberService;
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Value("${wechat.id}")
    private String wxId;
    @Autowired
    private DeviceService deviceService;
    /**
     * 签约记录
@ -101,6 +111,19 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
    }
    public JSONObject findPatientLabelAndCar(String patientId) throws Exception{
        JSONObject res = new JSONObject();
        List<WlyyPatientLabelDO> list = patientLabelDao.findByPatient(patientId);
        res.put("label",list);
        CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
        if(recordDO==null){
            res.put("levelConclusionName","");
        }else{
            res.put("levelConclusionName",recordDO.getLevelConclusionName());
        }
        return res;
    }
    /**
     * 居民id
     * @param patientId
@ -149,8 +172,9 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
                res.put("capAssRecordDO",recordDO);
            }
        }
        JSONObject tmp = res.getJSONObject("patient");
        tmp.put("deviceType",deviceService.getPatientDeviceCategoryCode(patientId));
        res.put("patient",tmp);
        return res;
    }
@ -226,17 +250,21 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     */
    @Transactional(rollbackFor = Exception.class)
    public void updPatientLabel(String jsonData,String patientId) throws Exception{
        patientLabelDao.deleteByPatientAndLabelType(patientId,"2");
        JSONArray jsonArray = JSON.parseArray(jsonData);
        List<WlyyPatientLabelDO> labelDOList = new ArrayList<>();
        for (int i=0;i<jsonArray.size();i++){
            WlyyPatientLabelDO labelDO = JSONObject.parseObject(jsonArray.getJSONObject(i).toJSONString(), WlyyPatientLabelDO.class);
            labelDO.setPatient(patientId);
            labelDO.setCzrq(new Date());
            labelDO.setLabelType("2");
            if(StringUtils.isNotBlank(labelDO.getLabelType())){
                patientLabelDao.deleteByPatientAndLabelType(patientId,labelDO.getLabelType());
            }else {
                patientLabelDao.deleteByPatientAndLabelType(patientId,"2");
                labelDO.setLabelType("2");
            }
            labelDOList.add(labelDO);
        }
        patientLabelDao.save(labelDOList);
            patientLabelDao.save(labelDOList);
    }
    public Boolean updatePatientPw(String id,String pw,String orgPw){
@ -549,6 +577,15 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        String sqlSecurity= "SELECT COUNT(*) from base_security_monitoring_order where `status` = 7 ";
        for (Map<String,Object> map:list){
            String doctorId = map.get("id").toString();
            List<BaseDoctorHospitalDO> hospitalDOS = doctorHospitalDao.findByDoctorCode(doctorId);
            if (hospitalDOS.size()>0){
                map.put("residentialArea",hospitalDOS.get(0).getOrgName());
                map.put("org_code",hospitalDOS.get(0).getOrgCode());
            }else {
                map.put("residentialArea",null);
                map.put("org_code",null);
            }
            String filter = " and doctor = '"+doctorId+"'";
            Integer lifeCare = jdbcTemplate.queryForObject(sqlLife+filter,Integer.class);
            Integer emergency = jdbcTemplate.queryForObject(sqlEmergency+filter,Integer.class);
@ -585,4 +622,15 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        }
        patientDao.save(list);
    }
    public Map<String,Object> patientIconStatus(String patient){
        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex,p.pad_imei padImei " +
                "from base_patient p INNER JOIN base_patient_wechat wc on p.id = wc.patient_id where p.del=1 and p.id='"+patient+"' and " +
                " wc.wechat_id = '"+wxId+"' GROUP BY p.id ORDER BY wc.create_time desc";
        Map<String,Object> result = jdbcTemplate.queryForMap(sql);
        result.put("deviceType",deviceService.getPatientDeviceCategoryCode(result.get("id").toString()));
        return result;
    }
}

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

@ -61,6 +61,9 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
                list.add(helperObj);
                obj.put("helperObj",list);///助老员
            }
        } else {
            List list = new ArrayList();
            obj.put("helperObj",list);///助老员
        }
        if (jsList.size() > 0){
@ -94,6 +97,9 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
                list.add(familyObj);
                obj.put("familyObj",list);
            }
        }else {
            List list = new ArrayList();
            obj.put("familyObj",list);
        }
        if (fwzList.size() > 0){
@ -108,6 +114,9 @@ public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePati
                list.add(serStationObj);
                obj.put("serStationObj",list);
            }
        }else {
            List list = new ArrayList();
            obj.put("serStationObj",list);
        }
        return obj;
    }

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

@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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.device.*;
import com.yihu.jw.care.dao.security.*;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.service.common.DictService;
@ -17,41 +17,43 @@ import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import com.yihu.jw.entity.care.device.*;
import com.yihu.jw.entity.care.securitymonitoring.*;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.emergency.EmergencyOrderVO;
import com.yihu.jw.restmodel.web.PageEnvelop;
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;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.securitymonitoring.*;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.EntityUtils;
import com.yihu.mysql.query.BaseJpaService;
import jdk.management.resource.internal.inst.FileOutputStreamRMHooks;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
 * Created by Bing on 2021/4/6.
@ -111,6 +113,16 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    private BaseEmergencyWarnLogDao logDao;
    @Autowired
    private ContactsService contactsService;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private BasePatientOutBedDao outBedDao;
    @Autowired
    private BaseSleepPlanDao sleepPlanDao;
    @Autowired
    private BaseSleepPlanDetailDao sleepPlanDetailDao;
    @Autowired
    private BaseSleepNightRecordDao nightRecordDao;
    private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
@ -165,8 +177,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        }
        //签约防走失服务包
        String sql ="SELECT i.code,i.team_code,i.org_code,i.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
        String sql ="SELECT i.code,r.team_code,pack.org_code,pack.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack    \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id  and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+orderDO.getPatient()+"' and i.code='preventLost' ";
        List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
        if (items.size()==0) {
@ -342,8 +354,46 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                e.printStackTrace();
            }
        }
        //TODO 火灾、燃气、离床专题返回值
        // http://192.168.1.103:85/%E5%8C%BB%E5%85%BB%E7%BB%93%E5%90%88/V0.7.0/#g=1&p=%E6%96%B0%E5%AE%89%E9%98%B2%E5%8C%85
        if (5==orderDO.getOrderSource()){//睡眠带工单
            try {
                JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
                List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patientDO.getId());
                if (sleepPlans.size()>0){
                    BaseSleepPlan sleepPlan = sleepPlans.get(0);
                    String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);
                    monitorInfo.put("sleepPlan",true);
                    monitorInfo.put("getUpTime",sleepPlan.getGetUpTime());
                    monitorInfo.put("siestaTime",sleepPlan.getNapTime());
                    monitorInfo.put("nightRestTime",sleepPlan.getNightRestTime());
                    monitorInfo.put("nightRecordTime",sleepPlan.getNightRestTime()+"-隔日"+endTime);
                }else {
                    monitorInfo.put("sleepPlan",false);
                }
                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall");
                emergencyOrderVO.setInformation(monitorInfo);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if (6==orderDO.getOrderSource()){//气感工单
            try {
                JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall");
                emergencyOrderVO.setInformation(monitorInfo);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if (7==orderDO.getOrderSource()){//烟感工单
            try {
                JSONObject monitorInfo = JSONObject.parseObject(orderDO.getWarnInfo());
                monitorInfo = patientSignTopicInfo(monitorInfo,orderDO.getPatient(),"preventFall");
                emergencyOrderVO.setInformation(monitorInfo);
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        //通知对象
        List<Map<String,Object>> noticePersons = new ArrayList<>();
@ -377,8 +427,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            noticePersons.add(noticeObj);
        }
        //医生信息
        String sql ="SELECT i.code,i.team_code,i.org_code,i.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
        String sql ="SELECT i.code,r.team_code,pack.org_code,pack.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id  and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+orderDO.getPatient()+"' and i.code='preventLost' ";
        List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
        if (items.size()>0){
@ -410,14 +460,14 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                if (StringUtils.isBlank(doc.getDoctorLat()) || StringUtils.isBlank(doc.getDoctorLon())) {
                    continue;
                }
                double distanceTmp = countDistance.getDistance(Double.parseDouble(orderDO.getServeLat()),Double.parseDouble(orderDO.getServeLon()),Double.parseDouble(doc.getDoctorLat()),Double.parseDouble(doc.getDoctorLon()));
                //double distanceTmp = countDistance.getDistance(Double.parseDouble(orderDO.getServeLat()),Double.parseDouble(orderDO.getServeLon()),Double.parseDouble(doc.getDoctorLat()),Double.parseDouble(doc.getDoctorLon()));
                otherDoctorDistanceObj = new JSONObject();
                otherDoctorDistanceObj.put("doctor",doc.getId());
                otherDoctorDistanceObj.put("doctorName",doc.getName());
                otherDoctorDistanceObj.put("doctorAddress",doc.getDoctorLocateAddress());
                otherDoctorDistanceObj.put("doctorLon",doc.getDoctorLon());
                otherDoctorDistanceObj.put("doctorLat",doc.getDoctorLat());
                otherDoctorDistanceObj.put("distance",distanceTmp);//两点距离
                otherDoctorDistanceObj.put("distance",null);//两点距离
                otherDoctorDistance.add(otherDoctorDistanceObj);
            }
            emergencyOrderVO.setOtherDoctorDistance(otherDoctorDistance.toJSONString());
@ -1157,7 +1207,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    public List<Map<String,Object>> getSecurityServerDoctor(String patient,String topicItem){
        //获取患者签约防走失服务的团队
        String sql="SELECT DISTINCT i.team_code from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
        String sql="SELECT DISTINCT r.team_code from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+patient+"' and i.code='"+topicItem+"'";
        List<String> teams = jdbcTemplate.queryForList(sql,String.class);
@ -1166,7 +1216,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            return new ArrayList<>();
        }else {
            for (String team:teams){
                sql = "select DISTINCT doc.id doctor,CONCAT(doc.`name`,\n" +
                sql = "select DISTINCT doc.id doctor,doc.name as doctorName,CONCAT(doc.`name`,\n" +
                        "CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile from base_team_member mem " +
                        "INNER JOIN base_doctor doc on mem.doctor_code = doc.id and mem.del=1 and mem.team_code='"+team+"'";
                List<Map<String,Object>>tmp = jdbcTemplate.queryForList(sql);
@ -1180,96 +1230,273 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        JSONObject result = new JSONObject();
        result.put("location",null);
        result.put("fences",null);
        result.put("smoke",null);
        result.put("gasLeakage",null);
        result.put("fire",null);
        result.put("fall",null);
        result.put("sleep",null);
        result.put("deviceSn",null);
        result.put("monitorInfo",null);
        if ((StringUtils.isNotBlank(topicItem)&&"preventLost".equals(topicItem))||StringUtils.isBlank(topicItem)){
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
            if (devicePatientDeviceDos.size()==0){
        String sql = " select dict.code,count(ord.id) total from base_system_dict_entry dict LEFT JOIN base_security_monitoring_order ord " +
                " on dict.code = ord.topic_item COLLATE utf8_unicode_ci and ord.status="+SecurityMonitoringOrderDO.Status.apply.getType()+" where dict.dict_code='service_item' " +
                "and dict.remark='security' and ord.patient='"+patient+"' GROUP BY dict.code ";
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
        for (Map<String,Object>tmp:sqlResult){
            switch (tmp.get("code").toString()){
                case "preventGasLeakage":
                   Integer count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("gasLeakage",true);
                    }else {
                        result.put("gasLeakage",false);
                    }
                    break;
                case "preventFire":
                    count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("fire",true);
                    }else {
                        result.put("fire",false);
                    }
                    break;
                case "preventFall":
                    count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("fall",true);
                    }else {
                        result.put("fall",false);
                    }
                    break;
                case "preventOutOfBed":
                    count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("sleep",true);
                    }else {
                        result.put("sleep",false);
                    }
                    break;
            }
            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",response.getString("last_city"));
                            tmp.put("province",response.getString("last_province"));
                            tmp.put("address",response.getString("last_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);
        }
        result = patientSignTopicInfo(result,patient,topicItem);
        return result;
    }
    public void preventLost(JSONObject result,String patient){
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
        if (devicePatientDeviceDos.size()==0){
            return;
        }
        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",response.getString("last_city"));
                    tmp.put("province",response.getString("last_province"));
                    tmp.put("address",response.getString("last_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);
                        }
                    }
                }catch (Exception e){
                    e.printStackTrace();
                    result.put("location",null);
                    if (fencesEnables.size()>0){
                        result.put("fences",fencesEnables);
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            result.put("location",null);
        }
        if ((StringUtils.isNotBlank(topicItem)&&"preventFall".equals(topicItem))||StringUtils.isBlank(topicItem)){
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
            if (devicePatientDeviceDos.size()==0){
    }
            }
            else{
                String sql = " select count(id) from base_security_monitoring_order where patient='"+patient+"' and topic_item='preventFall' and status="+SecurityMonitoringOrderDO.Status.apply.getType();
                Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
                if (count>0){
                    result.put("fall",true);
                }
                else {
                    result.put("fall",false);
                }
                try {
                    JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(patient,devicePatientDeviceDos.get(0).getDeviceSn(),1,null);
                    result.put("monitorInfoStatus",monitorUrl.getIntValue(ResponseContant.resultFlag));
                    result.put("patientAddress",devicePatientDeviceDos.get(0).getSosAddress());
                    if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
                        result.put("monitorInfo",monitorUrl.getString(ResponseContant.resultMsg));
    public void preventOutOfBed(JSONObject result,String patient,boolean video,String dayTime){
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"13");
        if (devicePatientDeviceDos.size()==0){}
        else {
            DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
            JSONObject deviceInfo =  patientDeviceService.getSleepDeviceInfo(deviceDo.getDeviceSn());
            if(deviceInfo.getBooleanValue("success")){
                result.put("patientAddress",deviceDo.getSosAddress());
                JSONArray objInfo = deviceInfo.getJSONArray("objs");
                if (objInfo.size()>0){
                    result.put("sleepStatus",true);
                    JSONObject tmp = objInfo.getJSONObject(0);
                    JSONObject sleepInfo = new JSONObject();
                    if (StringUtils.isBlank(dayTime)){
                        dayTime = getSleepMonitoringDay(new Date(),patient);
                    }
                    else {
                        result.put("monitorInfo",monitorUrl.getJSONObject(ResponseContant.resultMsg));
                    List<BaseSleepPlanDetail> planDetails = sleepPlanDetailDao.findByPatientAndDay(patient,dayTime);
                    if (planDetails.size()>0){
                        BaseSleepPlanDetail planDetail =  planDetails.get(0);
                        List<BaseSleepNightRecord> sleepNightRecordList = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient,dayTime);
                        planDetail.setSleepNightRecordList(sleepNightRecordList);
                        String jsonStr = JSON.toJSONStringWithDateFormat(planDetail, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
                        sleepInfo = JSONObject.parseObject(jsonStr);
                        sleepInfo.put("day",dayTime);
                    }
                }catch (Exception e){
                    e.printStackTrace();
                    List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
                    if (sleepPlans.size()>0){
                        BaseSleepPlan sleepPlan = sleepPlans.get(0);
                        String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);
                        sleepInfo.put("sleepPlan",true);
                        sleepInfo.put("getUpTime",sleepPlan.getGetUpTime());
                        sleepInfo.put("siestaTime",sleepPlan.getNapTime());
                        sleepInfo.put("nightRestTime",sleepPlan.getNightRestTime());
                        sleepInfo.put("nightRecordTime",sleepPlan.getNightRestTime()+"-隔日"+endTime);
                    }else {
                        sleepInfo.put("sleepPlan",false);
                    }
                    sleepInfo.put("online",tmp.getBooleanValue("online"));
                    if(tmp.getBooleanValue("onbed")){
                        sleepInfo.put("bedStatus",1);
                        sleepInfo.put("heartRate",tmp.getString("heartrate"));
                        sleepInfo.put("breath",tmp.getString("breathrate"));
                    }else {
                        sleepInfo.put("bedStatus",0);
                        sleepInfo.put("heartRate",null);
                        sleepInfo.put("breath",null);
                    }
                    BasePatientOutBed outBed = outBedDao.findByPatientAndDeviceSnAndStatus(patient,deviceDo.getDeviceSn(),0);
                    if (null!=outBed){
                        String outBedTime = "";
                        Date date = new Date();
                        long millisecondsDiff = date.getTime() - outBed.getCreateTime().getTime();
                        long minutesDiff = millisecondsDiff / TimeUnit.MINUTES.toMillis(1L);
                        long hoursDiff = millisecondsDiff / TimeUnit.HOURS.toMillis(1L);
                        long minuteFieldDiff = minutesDiff - TimeUnit.HOURS.toMinutes(hoursDiff);
                        if (hoursDiff > 0L) {
                            outBedTime += String.format("%d小时", hoursDiff);
                        }
                        if (minuteFieldDiff>0){
                            outBedTime +=String.format("%d分钟", minuteFieldDiff);
                        }
                        sleepInfo.put("outBedTime",outBedTime);
                    }else {
                        sleepInfo.put("outBedTime","无");
                    }
                    result.put("sleepInfo",sleepInfo);
                }
            }else {
                result.put("sleepStatus",false);
                result.put("sleepInfo","获取睡眠带数据失败");
            }
        }
        if (video){
            monitorInfo(result, patient);
        }
    }
    public void preventFire(JSONObject result,String patient,boolean video){
        String sql = "SELECT r.value from wlyy_patient_device pd,base_device_health_index r " +
                "WHERE pd.device_sn = r.device_sn and pd.`user` = '"+patient+"' ";
        sql += " and pd.category_code='15' ORDER BY r.create_time desc LIMIT 1";
        List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql);
        if(list1.size()==0){
            result.put("smoke","-1");
        }else{
            result.put("smoke",list1.get(0).get("value"));
        }
        result.put("smokeOrderNum",getOrder(patient,"preventFire"));
        if (video){
            monitorInfo(result, patient);
        }
    }
    public Integer getOrder(String patient,String topicItem){
        String sql = "select count(1) from base_security_monitoring_order " +
                "WHERE patient = '"+patient+"' and `status` = 1 and topic_item = '"+topicItem+"'";
        Integer num = jdbcTemplate.queryForObject(sql,Integer.class);
        return num;
    }
    public void preventGasLeakage(JSONObject result,String patient,boolean video){
        String sql = "SELECT r.value from wlyy_patient_device pd,base_device_health_index r " +
                "WHERE pd.device_sn = r.device_sn and pd.`user` = '"+patient+"' ";
        sql += " and pd.category_code='14' ORDER BY r.create_time desc LIMIT 1";
        List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql);
        if(list1.size()==0){
            result.put("methane","-1");
        }else{
            result.put("methane",list1.get(0).get("value"));
        }
        result.put("methaneOrderNum",getOrder(patient,"preventGasLeakage"));
        if (video){
            monitorInfo(result, patient);
        }
    }
    public void monitorInfo(JSONObject result,String patient){
        //监控
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
        if (devicePatientDeviceDos.size()==0){
            return;
        }
        try {
            DevicePatientDevice deviceDo = devicePatientDeviceDos.get(0);
            JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(patient,deviceDo.getDeviceSn(),1,null);
            result.put("monitorInfoStatus",monitorUrl.getIntValue(ResponseContant.resultFlag));
            result.put("patientAddress",deviceDo.getSosAddress());
            if (monitorUrl.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail){
                result.put("monitorInfo",monitorUrl.getString(ResponseContant.resultMsg));
            }
            else {
                result.put("monitorInfo",monitorUrl.getJSONObject(ResponseContant.resultMsg));
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
    public JSONObject patientSignTopicInfo(JSONObject result,String patient,String topicItem){
        if (null==result){
            result = new JSONObject();
        }
        if ("preventLost".equals(topicItem)||StringUtils.isBlank(topicItem)){
            preventLost(result, patient);
        }
        if ("preventFall".equals(topicItem)||StringUtils.isBlank(topicItem)){
            monitorInfo(result, patient);
        }
        if ("preventOutOfBed".equals(topicItem)||StringUtils.isBlank(topicItem)){
            preventOutOfBed(result, patient,true,null);
        }
        if ("preventFire".equals(topicItem)||StringUtils.isBlank(topicItem)){
            preventFire(result, patient,true);
        }
        if ("preventGasLeakage".equals(topicItem)||StringUtils.isBlank(topicItem)){
            preventGasLeakage(result, patient,true);
        }
        return result;
    }
@ -1353,6 +1580,66 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    /**
     *获取居民睡眠计划
     */
    public BaseSleepPlan getPatientSleepPlan(String patient){
        List<BaseSleepPlan> list = sleepPlanDao.findByPatient(patient);
        if (list.size()>0){
            return list.get(0);
        }else {
            return null;
        }
    }
    /**
     *获取居民睡眠监护列表
     */
    public JSONObject getPatientSleepDetainList(String patient,String begin,String end,Integer page,Integer pageSize){
        page=page>0?page-1:0;
        PageRequest pageRequest = new PageRequest(page, pageSize);
        if (StringUtils.isBlank(end)){
            end = begin;
        }
        JSONArray array = new JSONArray();
        Page<BaseSleepPlanDetail> list = sleepPlanDetailDao.findByListByPage(patient,begin,end,pageRequest);
        List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
        BaseSleepPlan sleepPlan=null;
        if (sleepPlans.size()>0){
            sleepPlan = sleepPlans.get(0);
        }
        for (BaseSleepPlanDetail tmp:list){
            List<BaseSleepNightRecord> records = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient,tmp.getDay());
            tmp.setSleepNightRecordList(records);
            String str = JSON.toJSONStringWithDateFormat(tmp, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue);
            JSONObject jsonObject = JSONObject.parseObject(str);
            if (null==sleepPlan){
                jsonObject.put("sleepPlan",false);
            }else {
                jsonObject.put("sleepPlan",true);
                String endTime = DateUtil.getNextMin(sleepPlan.getGetUpTime(),-1);
                jsonObject.put("getUpTime",sleepPlan.getGetUpTime());
                jsonObject.put("siestaTime",sleepPlan.getNapTime());
                jsonObject.put("nightRestTime",sleepPlan.getNightRestTime());
                jsonObject.put("nightRecordTime",sleepPlan.getNightRestTime()+"-隔日"+endTime);
                array.add(jsonObject);
            }
        }
        JSONObject result = (JSONObject) JSONObject.toJSON(list);
        result.put("content",array);
        return result;
    }
    /**
     *获取居民起夜记录
     */
    public List<BaseSleepNightRecord> getPatientSleepNightRecord(String patient, String day){
        List<BaseSleepNightRecord> records = nightRecordDao.findByPatientAndDayOrderByCreateTimeDesc(patient,day);
        return records;
    }
    private String getRandomIntStr(){
        Random rand = new Random();
        int i = rand.nextInt(); //int范围类的随机数
@ -1367,4 +1654,20 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        one.setUpdateUserName(one.getDoctorName());
    }
    private String getSleepMonitoringDay(Date date,String patient){
        List<BaseSleepPlan> sleepPlans = sleepPlanDao.findByPatient(patient);
        if (sleepPlans.size()>0){
            BaseSleepPlan sleepPlan = sleepPlans.get(0);
            String bedUpStr = sleepPlans.get(0).getGetUpTime();
            Date bedUp = DateUtil.strToDate(DateUtil.getStringDateShort()+" "+bedUpStr+":00");// 起床时间 起床前一小时内算为起床
            if (date.before(bedUp)&&bedUp.getTime()-date.getTime()>1000*1*3600){
                bedUp = DateUtil.getNextDay1(bedUp,-1);
            }
            String dayTime = DateUtil.dateToStr(bedUp,DateUtil.YYYY_MM_DD);//监测日期
            return dayTime;
        }else {
            return null;
        }
    }
}

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

@ -81,7 +81,7 @@ 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 * from ( 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 sql = " select * from ( SELECT a.create_time,p.openid,p.pad_imei padImei,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 " +
@ -97,7 +97,7 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
        }
        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" +
                    " SELECT a.create_time,p.openid,p.pad_imei padImei,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 " +

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

@ -86,8 +86,10 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
    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;
        if(recordDO!=null){
            recordDO.setLevelConclusionName(dictService.fingByNameAndCode(ConstantUtil.DICT_LEVEL_CONCLUSION,String.valueOf(recordDO.getLevelConclusion())));
        }
         return recordDO;
    }
    /**
@ -126,14 +128,14 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
        res.put("2",0);
        res.put("3",0);
        String sql = "SELECT COUNT(DISTINCT ar.patient) count,level_conclusion from  " +
                "base_capacity_assessment_record 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 = r.team_code and ar.patient = sr.patient " +
                "                and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1 " +
                "GROUP BY ar.level_conclusion" ;
        String sql = " SELECT COUNT(DISTINCT A.patient) count,A.level_conclusion \n" +
                " from ( select ar.patient,ar.label_code as level_conclusion from  wlyy_patient_label 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 = r.team_code and ar.patient = sr.patient and ar.label_type = 1 " +
                " and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1  " +
                " GROUP BY ar.patient ORDER BY ar.czrq desc)A " +
                " GROUP BY a.level_conclusion " ;
        List<Map<String,Object>> countMapList = jdbcTemplate.queryForList(sql);
        for(Map<String,Object> map:countMapList){
            int c = Integer.valueOf(map.get("count").toString());

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

@ -3,7 +3,10 @@ package com.yihu.jw.care.service.sign;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.dao.sign.*;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
@ -14,6 +17,7 @@ import com.yihu.jw.entity.base.servicePackage.ServicePackageRecordDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.apply.PatientBedApplyDo;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
@ -32,6 +36,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@ -73,6 +78,92 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    private PatientBedApplyDao bedApplyDao;
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private WlyyPatientLabelDao patientLabelDao;
    @Autowired
    private DictService dictService;
    public void addPatientSignList(){
        String lableCode = "0";
        //根据idcard/mobile导入居民信息
        String sql = "SELECT p.idcard,p.id,p.`name`,d.id AS doctor,d.name AS doctorName,pa.start,pa.end,pa.service_package AS servicePackage,pa.team_code AS teamCode FROM base_patient_add pa,base_patient p,base_doctor d WHERE d.mobile = pa.mobile AND d.del = 1 AND pa.del = 1 AND p.del =1 AND p.idcard = pa.idcard OR p.mobile = pa.mobile group by p.id ";
        List<Map<String , Object>> mapList = jdbcTemplate.queryForList(sql);
        ServicePackageSignRecordDO signRecordDO = new ServicePackageSignRecordDO();
        String patientId = "";
        String patientName = "";
        String doctorId = "";
        String doctorName = "";
        String idcard = "";
        String signId = "";
        for (int i=0;i<mapList.size();i++){
            try {
                patientId = (String) mapList.get(i).get("id");
                patientName = (String) mapList.get(i).get("name");
                doctorId = (String) mapList.get(i).get("doctor");
                doctorName = (String) mapList.get(i).get("doctorName");
                idcard = (String) mapList.get(i).get("idcard");
                List<ServicePackageSignRecordDO> signRecordDOs = servicePackageSignRecordDao.findByStatusAndPatient(1,patientId);
                if (signRecordDOs.size() == 0) {
                    signRecordDO.setPatient(patientId);
                    signRecordDO.setName(patientName);
                    signRecordDO.setSignDoctor(doctorId);
                    signRecordDO.setSignDoctorName(doctorName);
                    if (StringUtils.isNotBlank((String) mapList.get(i).get("start"))){
                        signRecordDO.setStartTime((Date) mapList.get(i).get("start"));
                    }else {
                        signRecordDO.setStartTime(new Date());
                    }
                    if (StringUtils.isNotBlank((String) mapList.get(i).get("end"))){
                        signRecordDO.setEndTime((Date) mapList.get(i).get("end"));
                    }else {
                        signRecordDO.setEndTime(new Date(System.currentTimeMillis() + 365*24*60*60*1000));
                    }
                    signRecordDO.setStatus(1);
                    servicePackageSignRecordDao.save(signRecordDO);
                    ServicePackageRecordDO packageRecordDO = new ServicePackageRecordDO();
                    packageRecordDO.setPatient(patientId);
                    packageRecordDO.setCreateTime(new Date());
                    packageRecordDO.setSignId(signRecordDO.getId());
                    packageRecordDO.setServicePackageId((String) mapList.get(i).get("servicePackage"));
                    packageRecordDO.setTeamCode((String) mapList.get(i).get("teamCode"));
                    servicePackageRecordDao.save(packageRecordDO);
                    //建档状态
                    ArchiveDO archiveDO = new ArchiveDO();
                    archiveDO.setCreateTime(new Date());
                    archiveDO.setArchiveOperatorName(doctorName);
                    archiveDO.setPatient(patientId);
                    archiveDO.setSickName(patientName);
                    archiveDO.setIdcard(idcard);
                    archiveDO.setSignStatus(1);
                    archiveDao.save(archiveDO);
                    //居民标签
                    WlyyPatientLabelDO patientLabelDO = new WlyyPatientLabelDO();
                    patientLabelDO.setCzrq(new Date());
                    patientLabelDO.setLabelType("1");
                    patientLabelDO.setPatient((String) mapList.get(i).get("patient"));
                    patientLabelDO.setLabelCode(lableCode);
                    patientLabelDO.setLabelName(dictService.fingByNameAndCode(ConstantUtil.DICT_SERVICE_TYPE,lableCode));
                    patientLabelDao.save(patientLabelDO);
                    //修改base_patient_add里面的del,状态修改成0
                }else {
                    logger.info("居民已签约,patient:"+patientId);
                }
            }catch (Exception e){
                logger.info(e.getMessage());
            }
        }
    }
    /**
     * 查找签约机构
@ -206,10 +297,10 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @param signId
     */
    public List<Map<String,Object>> fingdBySignId(String signId){
        String sql = "SELECT DISTINCT p.id,p.`name`,item.org_code,item.org_name from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package p,base_service_package_item item " +
                "WHERE sr.id = r.sign_id and  p.id = r.service_package_id and item.service_package_id = r.service_package_id and p.del = 1 " +
                " and item.del=1 and sr.id = '"+signId+"' GROUP BY item.service_package_id ORDER BY item.create_time desc ";
        String sql = "SELECT DISTINCT p.id,p.`name`,p.org_code,p.org_name from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package p " +
                "WHERE sr.id = r.sign_id and  p.id = r.service_package_id and p.del = 1 " +
                "  and sr.id = '"+signId+"' GROUP BY r.service_package_id ORDER BY r.create_time desc ";
        return jdbcTemplate.queryForList(sql);
    }
@ -268,7 +359,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @param doctorId
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject servicePackageSign(String jsonData,String doctorId,String patientId,String signYear) throws Exception{
    public JSONObject servicePackageSign(String jsonData,String doctorId,String patientId,String signYear,String lableCode) throws Exception{
        BasePatientDO patientDO = patientDao.findById(patientId);
        JSONObject result = new JSONObject();
        ServicePackageSignRecordDO signRecordDO = objectMapper.readValue(jsonData, ServicePackageSignRecordDO.class);
@ -324,6 +415,15 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
            result.put(ResponseContant.resultMsg,"请勿重复签约");
            return result;
        }
        //生成居民标签
        patientLabelDao.deleteByPatientAndLabelType(patientId,"1");
        WlyyPatientLabelDO patientLabelDO = new WlyyPatientLabelDO();
        patientLabelDO.setCzrq(new Date());
        patientLabelDO.setLabelType("1");
        patientLabelDO.setPatient(patientId);
        patientLabelDO.setLabelCode(lableCode);
        patientLabelDO.setLabelName(dictService.fingByNameAndCode(ConstantUtil.DICT_SERVICE_TYPE,lableCode));
        patientLabelDao.save(patientLabelDO);
        //服务项目 emergencyAssistance 只能签约一个
        String sqlItem = "select item.`code`,item.name from base_service_package_item item INNER JOIN base_service_package_record pr on item.service_package_id = pr.service_package_id\n" +
@ -479,18 +579,35 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                " and pack.del=1 and  item.topic_item='"+topicType+"' and re.sign_id in (\n" +
                "select rd.id from base_service_package_sign_record rd  where rd.patient='"+patient+"' and rd.status=1) GROUP BY item.code; ";
        List<Map<String,Object>> result = jdbcTemplate.queryForList(sql);
        Iterator<Map<String, Object>> iterator = result.iterator();
        while (iterator.hasNext()){
            Map<String, Object> map = iterator.next();
            String item = map.get("serverItem").toString();
            sql = " select count(pd.device_sn) from dm_device dd INNER JOIN wlyy_patient_device " +
                    "pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model" +
                    " and pd.device_sn = wd.device_code \n" +
                    "where 1=1 and  pd.del=0  and  pd.`user`='"+patient+"'  and dd.service_topic " +
                    "like '%"+item+"%'   ";
            Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
            if (count>0){
            }else {
                iterator.remove();
            }
        }
        return result;
    }
    public List<Map<String,Object>> getServerDoctorAll(String patient,String onlineFlag){
        String sql="SELECT  DISTINCT doc.id doctor,doc.name as doctorName,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 " +
        String sql="SELECT DISTINCT doc.id doctor,doc.name as doctorName,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 " +
                " THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,doc.job_title_name as jobName,doc.job_title_code as job, " +
                " 0 as onLineFlag,org.code,org.name as orgName " +
                "from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor doc, " +
                "base_service_package pack,base_org org " +
                "WHERE sr.patient='"+patient+"' and sr.status=1  and m.team_code = r.team_code and " +
                " m.doctor_code = doc.id and sr.id=r.sign_id and pack.id = r.service_package_id and pack.org_code = org.code " +
                " and m.del = '1'";
                " and m.del = '1' group by doc.id";
        List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
        if ("1".equals(onlineFlag)){//展示是否在线
            String listStr = imUtil.getOnlineListByType("helper");

+ 273 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java

@ -0,0 +1,273 @@
package com.yihu.jw.care.service.statistics;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.xerces.internal.xs.datatypes.ByteList;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.service.device.PatientDeviceService;
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.PageEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import com.yihu.jw.utils.StringUtil;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/***
 * @ClassName: DetectionPlatformService
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/20 9:39
 */
@Service
public class DetectionPlatformService  {
    Logger logger = LoggerFactory.getLogger(DetectionPlatformService.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    /**
     * 体征监测 安防监护
     * @param page
     * @param pageSize
     * @param type
     * @return
     */
    public PageEnvelop getHealthMonitoringListNew(Integer page, Integer pageSize, Integer type){
        page = page>0?page-1:0;
        if (type == 1) {
            String sql = " SELECT id,user,`name`,'健康监测' as serve_desc,czrq,value1,value2,value3,value4,value5,value6,value7,type \n" +
                    "FROM wlyy_patient_health_index WHERE del = 1 AND type < 3 ORDER BY czrq desc ";
            String countSql = "select count(id) from ("+sql+")A ";
            long count = jdbcTemplate.queryForObject(countSql,long.class);
            sql +=" limit "+page*pageSize+","+pageSize;
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
        }else {
            String sql = " select  '22' as 'OrderType',ord.id,ord.patient,p.name,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time,ord.`status` \n" +
                    "from base_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id order by create_time desc ";
            String countSql = "select count(id) from ("+sql+")A ";
            long count = jdbcTemplate.queryForObject(countSql,long.class);
            sql +=" limit "+page*pageSize+","+pageSize;
            List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
            return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
        }
    }
    public JSONObject getDeviceComapny(){
        JSONObject object = new JSONObject();
        String deviceTypeSum = "SELECT * FROM wlyy_devices WHERE device_name IS NOT NULL AND device_name != '' GROUP BY device_name";
        List<Map<String , Object>> deviceList = jdbcTemplate.queryForList(deviceTypeSum);
        if (deviceList.size() > 0) {
            object.put("deviceTypeCount",deviceList.size()); //设备品牌数量
        } else {
            object.put("deviceTypeCount",0);
        }
        String manufacturerSql = "SELECT * FROM wlyy_devices WHERE manufacturer IS NOT NULL AND manufacturer != '' GROUP BY manufacturer ;";
        List<Map<String , Object>> manufacturerList = jdbcTemplate.queryForList(manufacturerSql);
        if (manufacturerList.size() > 0) {
            object.put("manufacturerCount",manufacturerList.size()); //入驻厂商数量
        } else {
            object.put("manufacturerCount",0);
        }
        String securitySql = "SELECT allCount,isUse,(allCount - isUse) inventory FROM \n" +
                "(SELECT COUNT(1) allCount FROM wlyy_devices WHERE device_type = 1) allCount,\n" +
                "(SELECT COUNT(pd.id) isUse FROM wlyy_devices d,wlyy_patient_device pd WHERE d.device_type = 1 AND d.device_code = pd.device_sn AND pd.del = 0) isUse";
        List<Map<String , Object>> securityList = jdbcTemplate.queryForList(securitySql);
        if (securityList.size() > 0) {
            object.put("securityAllCount",securityList.get(0).get("allCount")); //安防设备总量
            object.put("securityIsUseCount",securityList.get(0).get("isUse"));//安防设备使用中数量
            object.put("securityInventoryCount",securityList.get(0).get("inventory"));//安防设备库存量
        } else {
            object.put("securityAllCount",0); //安防设备总量
            object.put("securityIsUseCount",0);//安防设备使用中数量
            object.put("securityInventoryCount",0);//安防设备库存量
        }
        String healthSql = "SELECT allCount,isUse,(allCount - isUse) inventory FROM \n" +
                "(SELECT COUNT(1) allCount FROM wlyy_devices WHERE device_type = 0) allCount,\n" +
                "(SELECT COUNT(pd.id) isUse FROM wlyy_devices d,wlyy_patient_device pd WHERE d.device_type = 0 AND d.device_code = pd.device_sn AND pd.del = 0) isUse";
        List<Map<String , Object>> healthList = jdbcTemplate.queryForList(healthSql);
        if (healthList.size() > 0) {
            object.put("healthAllCount",securityList.get(0).get("allCount"));//健康设备总量
            object.put("healthIsUseCount",securityList.get(0).get("isUse"));//健康设备使用中数量
            object.put("healthInventoryCount",securityList.get(0).get("inventory"));//健康设备库存量
        } else {
            object.put("healthAllCount",0);//健康设备总量
            object.put("healthIsUseCount",0);//健康设备使用中数量
            object.put("healthInventoryCount",0);//健康设备库存量
        }
        Long securityIsUser = (Long) securityList.get(0).get("isUse");
        Long healthIsUser = (Long) healthList.get(0).get("isUse");
        Long securityAllCount = (Long) securityList.get(0).get("allCount");
        Long healthAllCount = (Long) healthList.get(0).get("allCount");
        object.put("lawOfIOT",getRange( (securityIsUser.intValue() + healthIsUser.intValue() ),( securityAllCount.intValue() + healthAllCount.intValue()  ) ));//物联率
        object.put("isUseAllIot",(securityIsUser.intValue() + healthIsUser.intValue()));//已发放设备
        object.put("allIot",securityAllCount.intValue() + healthAllCount.intValue());//总设备
//        String unUseSql = "";//连续一周为上传数据
//        List<Map<String , Object>> unUseList = jdbcTemplate.queryForList(unUseSql);
//        Long unUseCount = (Long) securityList.get(0).get("allCount");
////        if (unUseList.size() > 0){
////            unUseCount = (Long) securityList.get(0).get("allCount");
////        }
//        object.put("lostLaw",getRange(unUseCount.intValue(),securityIsUser.intValue() + healthIsUser.intValue()));//设备失联率
        object.put("lostLaw","0%");//设备失联率
        return object;
    }
    public String getRange(int first, int second) {
        if (second == 0 && first > 0) {
            //如果分母为0 分子不为0 返回100%
            return "100%";
        } else if (second == 0 && first == 0) {
            //如果分母为0 分子为0 返回0%
            return "0%";
        }
        float size = (float) (first * 100) / second;
        DecimalFormat df = new DecimalFormat("0.00");//格式化小数,不足的补0
        String filesize = df.format(size);
        return filesize + "%";
    }
    public List<Map<String , Object>> getDeviceType(){
        String sql = "SELECT category_code categoryCode,name FROM dm_device GROUP BY category_code";
        return jdbcTemplate.queryForList(sql);
    }
    public JSONArray getDeviceByCondition(String categoryCode , String user){
        JSONArray jsonArray = new JSONArray();
        List<DevicePatientDevice> patientDevices = patientDeviceDao.findAllGroupUser();
        if (StringUtils.isNotBlank(categoryCode)) {  //categoryCode != null   根据设备类型查询
            patientDevices = patientDeviceDao.findAllByCategoryCode(categoryCode);
        }
        if (StringUtils.isNotBlank(user)) {  //categoryCode != null   根据设备类型查询
            String sql = "select a.* from wlyy_patient_device a where a.user='"+user+"' and a.del=0 LIMIT 1";
            patientDevices = jdbcTemplate.query(sql, new BeanPropertyRowMapper(DevicePatientDevice.class));
        }
        List<BasePatientDO> patientDOS = patientDao.findAllByDel();
//        if (StringUtils.isNotBlank(user)) {
//            patientDOS = patientDao.findAllByDelAndId(user);  //user != null   根据居民查询
//        }
        Map<String, List<BasePatientDO>> byId = patientDOS.stream().collect(Collectors.groupingBy(BasePatientDO::getId));
        //首页默认根据居民展示  绑定设备的居民
//        String userSql = "SELECT `user` FROM wlyy_patient_device WHERE del = 0 GROUP BY `user`";
//        List<Map<String , Object>> userList = jdbcTemplate.queryForList(userSql);
        if (patientDevices.size() > 0) {
            for (int i=0;i<patientDevices.size();i++) {
                JSONArray arrayAll = new JSONArray();
                JSONArray array = new JSONArray();
                JSONObject userObj = new JSONObject();
                userObj.put("patient",patientDevices.get(i).getUser());
                userObj.put("patientName",byId.get(patientDevices.get(i).getUser()).get(0).getName());
                userObj.put("patientType",byId.get(patientDevices.get(i).getUser()).get(0).getArchiveType());
                userObj.put("latLon",byId.get(patientDevices.get(i).getUser()).get(0).getLatLon());
                List<DevicePatientDevice> deviceList = patientDeviceDao.findAllByUser(patientDevices.get(i).getUser());
                if (StringUtils.isNotBlank(categoryCode)) {
                    deviceList = patientDeviceDao.findAllByUserAndCategoryCode(patientDevices.get(i).getUser(),categoryCode);
                }
                if (deviceList != null) {
                    if (deviceList.size() > 1) {    //居民绑定多台设备
                        for (int j=0;j<deviceList.size();j++) {
                            JSONObject obj = new JSONObject();
                            obj.put("deviceSn",deviceList.get(j).getDeviceSn());
                            obj.put("deviceName",deviceList.get(j).getDeviceName());
                            obj.put("categoryCode",deviceList.get(j).getCategoryCode());
                            array.add(obj);
                        }
                        userObj.put("deviceCount",deviceList.size());
                        userObj.put("deviceInfo",array);
                        arrayAll.add(userObj);
                    } else {    //居民只绑定一台设备
                        for (int j=0;j<deviceList.size();j++) {
                            JSONObject obj = new JSONObject();
                            obj.put("deviceSn",deviceList.get(j).getDeviceSn());
                            obj.put("deviceName",deviceList.get(j).getDeviceName());
                            obj.put("categoryCode",deviceList.get(j).getCategoryCode());
                            array.add(obj);
                        }
                        userObj.put("deviceCount",deviceList.size());
                        userObj.put("deviceInfo",array);
                        arrayAll.add(userObj);
                    }
                    jsonArray.add(arrayAll);
                }
            }
        } else {
            return jsonArray;
        }
        return jsonArray;
    }
    public JSONObject getDeviceInfo(String deviceSn) throws Exception{
        String categoryCode = "";
        JSONObject object = new JSONObject();
        String deviceInfoSql = "SELECT device_name deviceName,device_type deviceType,device_code deviceSn,manufacturer FROM wlyy_devices WHERE  device_code = '"+deviceSn+"' ";
        List<Map<String , Object>> deviceInfoList = jdbcTemplate.queryForList(deviceInfoSql);
        if (deviceInfoList.size() > 0){
            object.put("deviceName",deviceInfoList.get(0).get("deviceName"));
            object.put("deviceType",deviceInfoList.get(0).get("deviceType"));
            object.put("deviceSn",deviceInfoList.get(0).get("deviceSn"));
            object.put("manufacturer",deviceInfoList.get(0).get("manufacturer"));
            String patientInfoSql = "SELECT p.`name` patientName,p.id patient,p.mobile,p.idcard,p.address,pd.category_code categoryCode " +
                    "FROM wlyy_patient_device pd,base_patient p WHERE p.id = pd.`user` AND p.del = 1 AND pd.del = 0 AND pd.device_sn = '"+deviceSn+"'";
            List<Map<String , Object>> patientInfoList = jdbcTemplate.queryForList(patientInfoSql);
            if (patientInfoList.size() > 0) {
                categoryCode = patientInfoList.get(0).get("categoryCode").toString();
                object.put("patientName",patientInfoList.get(0).get("patientName"));
                object.put("patient",patientInfoList.get(0).get("patient"));
                object.put("mobile",patientInfoList.get(0).get("mobile"));
                object.put("idcard",patientInfoList.get(0).get("idcard"));
                object.put("address",patientInfoList.get(0).get("address"));
                String dataSql= "";
                List<Map<String , Object>> dataList = new ArrayList<>();
                switch (categoryCode) {
                    // 1=血糖仪  2=血压计 14=燃气报警器  15=烟雾报警器
                    // 4=智能手表  7=居家安全报警器  16=智能拐杖  13=智能床带/睡眠带
                    case "1" :
                        dataSql = "SELECT record_date recordDate,value1,value2,value3,value4,value5,value6,value7,type FROM wlyy_patient_health_index WHERE device_sn = '"+deviceSn+"' AND del = 1 ORDER BY sort_date DESC LIMIT 10";
                        dataList = jdbcTemplate.queryForList(dataSql);
                        object.put("data",dataList);
                        break;
                    case "2" :
                        dataSql = "SELECT record_date recordDate,value1,value2,value3,value4,value5,value6,value7,type FROM wlyy_patient_health_index WHERE device_sn = '"+deviceSn+"' AND del = 1 ORDER BY sort_date DESC LIMIT 10";
                        dataList = jdbcTemplate.queryForList(dataSql);
                        object.put("data",dataList);
                        break;
                    case "14" :
                        dataSql = "SELECT record_time recordDate,`value`,unit,device_type FROM base_device_health_index WHERE device_sn = '"+deviceSn+"' ORDER BY record_time DESC LIMIT 10 ";
                        dataList = jdbcTemplate.queryForList(dataSql);
                        object.put("data",dataList);
                        break;
                    case "15" :
                        dataSql = "SELECT record_time recordDate,`value`,unit,device_type FROM base_device_health_index WHERE device_sn = '"+deviceSn+"' ORDER BY record_time DESC LIMIT 10 ";
                        dataList = jdbcTemplate.queryForList(dataSql);
                        object.put("data",dataList);
                        break;
                }
            } else {
                throw new Exception("无法找到该设备对应使用人");
            }
        }else {
            throw new Exception("设备SN码对应的设备不存在!");
        }
        return object;
    }
}

+ 68 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java

@ -9,10 +9,13 @@ import com.yihu.jw.dict.dao.DictHospitalDeptDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.patient.Patient;
import com.yihu.jw.es.util.ElasticsearchUtil;
import com.yihu.jw.es.util.SaveModel;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.collections.map.HashedMap;
@ -52,6 +55,8 @@ public class StatisticsService {
    private StatisticsUtilService statisticsUtilService;
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private BasePatientDao patientDao;
    private static final String defalutArea = "330100";
@ -111,7 +116,7 @@ public class StatisticsService {
        JSONObject res = new JSONObject();
        Integer olderTotal = 0;
        Integer childTotal = 0;
        String sql1 = "SELECT COUNT(*) c,archive_type from base_patient WHERE archive_type is  not null and del='1' GROUP BY archive_type";
        String sql1 = "SELECT COUNT(*) c,archive_type*1 as archive_type from base_patient WHERE archive_type is not null and del='1' GROUP BY archive_type";
        List<Map<String,Object>> list1 = jdbcTemplate.queryForList(sql1);
        for(Map<String,Object> map:list1){
            String archive_type = map.get("archive_type").toString();
@ -141,6 +146,61 @@ public class StatisticsService {
        return  res;
    }
    public PageEnvelop getAllDynamics(Integer page,Integer size){
        List result = new ArrayList<>();
        Date date = DateUtil.getPreDays(new Date(),-7);
        String dateStr = DateUtil.dateToStrLong(date);
        String sql = "select * from base_login_log where create_time>='"+dateStr+"' order by create_time desc limit "+ (page-1)*size+","+size;
        String sqlCount = "select count(id) from base_login_log where create_time>='"+dateStr+"' ";
        Long count = jdbcTemplate.queryForObject(sqlCount,Long.class);
        List<BaseLoginLogDO> loginLogDOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(BaseLoginLogDO.class));
        for (BaseLoginLogDO log:loginLogDOs) {
            JSONObject object = new JSONObject();
            object.put("patient",log.getUserId());
            BasePatientDO patient = patientDao.findById(log.getUserId());
            if (patient != null){
                String archive_type = null;
                Integer onLineFlag =0;
                if (patient.getArchiveType() == null){
                    continue;
                }
                switch (patient.getArchiveType().toString()){
                    case "1":
                        archive_type = "older";//老人
                        break;
                    case "2":
                        archive_type = "child";//新生儿
                        break;
                }
                object.put("archiveType",patient.getArchiveType());
                String onLineStr = imUtil.findByUserIdAndType(log.getUserId().toString(),archive_type);
                JSONObject oneLineObj = JSONObject.parseObject(onLineStr);
                if (200 == oneLineObj.getInteger("status")){
                    if (oneLineObj.getInteger("data")>0){
                        onLineFlag=1;
                    }
                }
                object.put("onLineFlag", onLineFlag);
            } else {
                Integer onLineFlag =0;
                String onLineStr = imUtil.findByUserIdAndType(log.getUserId().toString(),"helper");
                JSONObject oneLineObj = JSONObject.parseObject(onLineStr);
                if (200 == oneLineObj.getInteger("status")){
                    if (oneLineObj.getInteger("data")>0){
                        onLineFlag=1;
                    }
                }
                object.put("onLineFlag", onLineFlag);
                object.put("archiveType","0");
            }
            object.put("name",log.getName());
            object.put("createTime", DateUtil.dateToStrLong(log.getCreateTime()) );
            object.put("clientType", log.getClientType());
            result.add(object);
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",result,page,size,count);
    }
    /**
     * 服务排名分析
     * @param endDate
@ -231,8 +291,10 @@ public class StatisticsService {
     */
    public PageEnvelop fingLoginLog(Integer page,Integer size){
        List<String> result = new ArrayList<>();
        String sql = "select * from base_login_log order by create_time desc limit "+ (page-1)*size+","+size;
        String sqlCount = "select count(id) from base_login_log";
        Date date = DateUtil.getPreDays(new Date(),-7);
        String dateStr = DateUtil.dateToStrLong(date);
        String sql = "select * from base_login_log where create_time>='"+dateStr+"'  order by create_time desc limit "+ (page-1)*size+","+size;
        String sqlCount = "select count(id) from base_login_log where create_time>='"+dateStr+"' ";
        Long count = jdbcTemplate.queryForObject(sqlCount,Long.class);
        List<BaseLoginLogDO> loginLogDOs = jdbcTemplate.query(sql,new BeanPropertyRowMapper(BaseLoginLogDO.class));
        for (BaseLoginLogDO log:loginLogDOs) {
@ -618,6 +680,9 @@ public class StatisticsService {
        for(int i=0;i<list.size();i++){
            SaveModel saveModel = list.get(i);
            JSONObject json = new JSONObject();
            if (saveModel.getResult2().longValue()==0&&StringUtils.isBlank(saveModel.getSlaveKey1())){
                continue;
            }
            json.put("num",saveModel.getResult2().longValue());
            json.put("code",saveModel.getSlaveKey1());
            json.put("name",saveModel.getSlaveKey1Name());

+ 4 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/team/BaseTeamService.java

@ -80,6 +80,10 @@ public class BaseTeamService extends BaseJpaService<BaseTeamDO, BaseTeamDao> {
        }
    }
    public Integer findMemCount(String teamCode){
        return memberDao.findMemCount(teamCode);
    }
    /**
     * 删除团队
     * @param teamCode

+ 3 - 4
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/patient/PatientNoLoginService.java

@ -29,12 +29,11 @@ public class PatientNoLoginService {
                " DISTINCT o.* " +
                "FROM " +
                " base_service_package_record r, " +
                " base_service_package_item i, " +
                "  base_service_package pack  " +
                " base_org o " +
                "WHERE " +
                " r.service_package_id = i.service_package_id " +
                "AND i.del = 1 " +
                "and i.org_code = o.code " ;
                "  and r.service_package_id = pack.id " +
                "and r.org_code = o.code " ;
        if("1".equals(type)){
            sql += " and (o.type =1 or o.type = 2) ";
        }else if("3".equals(type)){

+ 250 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/ArtemisPostTest.java

@ -0,0 +1,250 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
public class ArtemisPostTest {
	/**
	 * 请根据自己的appKey和appSecret更换static静态块中的三个参数. [1 host]
	 * 如果你选择的是和现场环境对接,host要修改为现场环境的ip,https端口默认为443,http端口默认为80.例如10.33.25.22:443 或者10.33.25.22:80
	 * appKey和appSecret请按照或得到的appKey和appSecret更改.
	 * TODO 调用前先要清楚接口传入的是什么,是传入json就用doPostStringArtemis方法,下载图片doPostStringImgArtemis方法
	 */
	static {
		ArtemisConfig.host = "open.hikfirecloud.com";// 代理API网关nginx服务器ip端口
		ArtemisConfig.appKey = "23553385";// 秘钥appkey
		ArtemisConfig.appSecret = "HfjuKlQnzTbn0mfxm5Vk";// 秘钥appSecret
	}
	/**
	 * 能力开放平台的网站路径
	 * TODO 路径不用修改,就是/artemis
	 */
	private static final String ARTEMIS_PATH = "/artemis";
	/**
	 * 调用POST请求类型(application/json)接口,这里以入侵报警事件日志为例
	 * https://open.hikvision.com/docs/918519baf9904844a2b608e558b21bb6#e6798840
	 *
	 * @return
	 */
	public static String callPostStringApi(String url,String body){
		/**
		 * http://10.33.47.50/artemis/api/scpms/v1/eventLogs/searches
		 * 根据API文档可以看出来,这是一个POST请求的Rest接口,而且传入的参数值为一个json
		 * ArtemisHttpUtil工具类提供了doPostStringArtemis这个函数,一共六个参数在文档里写明其中的意思,因为接口是https,
		 * 所以第一个参数path是一个hashmap类型,请put一个key-value,query为传入的参数,body为传入的json数据
		 * 传入的contentType为application/json,accept不指定为null
		 * header没有额外参数可不传,指定为null
		 *
		 */
		final String getCamsApi = ARTEMIS_PATH + url;
		Map<String, String> path = new HashMap<String, String>(2) {
			{
				put("https://", getCamsApi);//根据现场环境部署确认是http还是https
			}
		};
		String result = ArtemisHttpUtil.doPostStringArtemis(path,body,null,null,"application/json",null);// post请求application/json类型参数
		return result;
	}
	/**
	 * 调用POST请求下载图片类型接口,这里以获取访客记录中的图片接口为例
	 * https://open.hikvision.com/docs/a0a1a0a24701a00aa904f7b151f97410#f11f3208
	 *
	 * @return
	 */
	public static void callPostImgStringApi(){
		/**
		 * http://10.33.47.50/api/visitor/v1/record/pictures
		 * 根据API文档可以看出来,这是一个POST请求的Rest接口,而且传入的参数值为一个json
		 * ArtemisHttpUtil工具类提供了doPostStringImgArtemis这个函数,一共六个参数在文档里写明其中的意思,因为接口是https,
		 * 所以第一个参数path是一个hashmap类型,请put一个key-value,query为传入的参数,body为传入的json数据
		 * 传入的contentType为application/json,accept不指定为null
		 * header没有额外参数可不传,指定为null
		 *
		 */
		final String VechicleDataApi = ARTEMIS_PATH +"/api/visitor/v1/record/pictures";
		Map<String,String> path = new HashMap<String,String>(2){
			{
				put("http://",VechicleDataApi);
			}
		};
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("svrIndexCode", "8907fd9d-d090-43d3-bb3a-3a4b10dd7219");
		jsonBody.put("picUri", "/pic?0dd453i3c-e*046456451175m6ep=t=i2p*i=d1s*i3d0d*=*1b8i81f4747059503--bdf90a-855s5721z3b9i=1=");
		String body = jsonBody.toJSONString();
		System.out.println("body: "+body);
		HttpResponse result = ArtemisHttpUtil.doPostStringImgArtemis(path,body,null,null,"application/json",null);
		try {
			HttpResponse resp = result;
			if (200==resp.getStatusLine().getStatusCode()) {
				HttpEntity entity = resp.getEntity();
				InputStream in = entity.getContent();
				Tools.savePicToDisk(in, "d:/", "test4.jpg");
				System.out.println("下载成功");
			}else{
				System.out.println("下载出错");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	/**
	 * 消息订阅
	 *
	 * 980001	资源信息变更通知	1
		 980002	报警实时信息	2
		 980003	报警处理信息	3
		 980004	故障实时信息	4
		 980005	故障处理信息	5
		 980006	设备在离线消息	6
		 980007	监控点在离线消息	7
		 980008	监测实时信息	8
     */
	public static void subscription_info(String msgType){
		String url = "/api/firepro/v1/subscription/info";
		//消息类型	msgType	String	是
		//回调URL	postUrl	String	是
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("msgType", msgType);
		jsonBody.put("postUrl", "http://ehr.yihu.com/wlyy/aqg/hvdevice/messageNotification");
		//http://ehr.yihu.com/wlyy/aqg/device/byOnlineStatus
		//http://ehr.yihu.com/wlyy/aqg
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * 修改订阅
	 */
	public void subscription_update(){
		String url = "/api/firepro/v1/subscription/update";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 3);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * 删除订阅
	 */
	public void subscription_deletion(){
		String url = "/api/firepro/v1/subscription/deletion";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 3);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * 设备监测信息查询
	 */
	public static String getMonitor(String deviceID){
		String url = "/api/firepro/v1/getMonitor";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("deviceID", deviceID);
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 1);
		jsonBody.put("flagId", "");
		jsonBody.put("offset", 0);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		return StringeResult;
	}
	/**
	 * 获取消防设备信息
	 */
	public static String getDevice(){
		String url = "/api/firepro/v1/getDevice";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 500);
		jsonBody.put("flagId", "");
		jsonBody.put("offset", 0);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		return StringeResult;
	}
	/**
	 * 消防设备添加
	 *
	 * 设备名称	deviceName	String	true	设备名称
	 设备序列号	deviceSerial	String	true	设备序列号
	 设备型号	deviceModel	String	true	设备型号,详见字典表
	 800022	NP-FY200-N 烟
	 800056 JT-HK400-N 气
	 设备类型	deviceType	Number	true	设备类型,详见字典表
	 600002	独立式光电感烟探测器(NB)
	 600006	独立式可燃气体探测器(NB)
	 通讯类型	communicationType	Number	true	通讯类型,详见字典表
	 900004	NB移动
	 */
	public static void addDevice(String deviceName,String deviceSerial,String deviceModel,String deviceType){
		String url = "/api/bws/device/v1/add";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("deviceName", deviceName);
		jsonBody.put("deviceSerial", deviceSerial);
		jsonBody.put("deviceModel", deviceModel);
		jsonBody.put("deviceType", deviceType);
		jsonBody.put("communicationType", "900004");
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	/**
	 * 查询订阅
	 */
	public void subscription_list(){
		String url = "/api/firepro/v1/subscription/list";
		JSONObject jsonBody = new JSONObject();
		jsonBody.put("pageNo", 1);
		jsonBody.put("pageSize", 3);
		String body = jsonBody.toJSONString();
		String StringeResult = callPostStringApi(url,body);
		System.out.println("StringeResult结果示例: "+StringeResult);
	}
	public static void main(String[] args) {
//		String url = "/api/firepro/v1/getCompany";
//		JSONObject jsonBody = new JSONObject();
//		jsonBody.put("pageNo", 1);
//		jsonBody.put("pageSize", 3);
//		String body = jsonBody.toJSONString();
//		String StringeResult = callPostStringApi(url,body);
//		System.out.println("StringeResult结果示例: "+StringeResult);
//		callPostImgStringApi();
//		getDevice();
		System.out.println(getMonitor("635486270136270848"));
//		subscription_info("980001");
//		subscription_info("980002");
//		subscription_info("980003");
//		subscription_info("980004");
//		subscription_info("980005");
//		subscription_info("980006");
//		subscription_info("980007");
//		subscription_info("980008");
	}
}

+ 60 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/Tools.java

@ -0,0 +1,60 @@
package com.yihu.jw.care.util;/**
 * Created by lifutao on 2019/1/11.
 */
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
/**
 * 工具类
 *
 * @author
 * @create 2019-01-11 17:06
 **/
public class Tools {
    /**
     * 将图片写到 硬盘指定目录下
     *
     * @param in
     * @param dirPath
     * @param filePath
     */
    public static void savePicToDisk(InputStream in, String dirPath,
                                      String filePath) {
        try {
            File dir = new File(dirPath);
            if (dir == null || !dir.exists()) {
                dir.mkdirs();
            }
            //文件真实路径
            String realPath = dirPath.concat(filePath);
            File file = new File(realPath);
            if (file == null || !file.exists()) {
                file.createNewFile();
            }
            FileOutputStream fos = new FileOutputStream(file);
            byte[] buf = new byte[1024];
            int len = 0;
            while ((len = in.read(buf)) != -1) {
                fos.write(buf, 0, len);
            }
            fos.flush();
            fos.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

+ 9 - 16
svr/svr-cloud-device/pom.xml

@ -16,27 +16,16 @@
    <version>${parent.version}</version>
    <dependencies>
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!-- 支持Tomcat启动 -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
@ -98,7 +87,11 @@
            <artifactId>HikariCP</artifactId>
            <!-- <scope>runtime</scope> -->
        </dependency>
        <dependency>
            <groupId>com.hikvision.ga</groupId>
            <artifactId>artemis-http-client</artifactId>
            <version>1.1.3</version>
        </dependency>
        <dependency>
            <groupId>io.github.swagger2markup</groupId>
            <artifactId>swagger2markup</artifactId>

+ 21 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/config/WebSocketConfig.java

@ -0,0 +1,21 @@
package com.yihu.jw.care.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/***
 * @ClassName: WebSocketConfig
 * @Description: 开启WebSocket支持
 * @Auther: shi kejing
 * @Date: 2021/8/20 14:17
 */
@Configuration
public class WebSocketConfig {
    @Bean
    public ServerEndpointExporter serverEndpointExporter() {
        return new ServerEndpointExporter();
    }
}

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

@ -0,0 +1,15 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BasePatientOutBed;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2021/8/18.
 */
public interface BasePatientOutBedDao extends PagingAndSortingRepository<BasePatientOutBed,Long>,
        JpaSpecificationExecutor<BasePatientOutBed> {
    BasePatientOutBed findByPatientAndDeviceSnAndStatus(String patient,String deviceSn,Integer status);
}

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

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

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

@ -0,0 +1,23 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BaseSleepNightRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
 * Created by Bing on 2021/8/17.
 */
public interface BaseSleepNightRecordDao extends PagingAndSortingRepository<BaseSleepNightRecord,Long>,
        JpaSpecificationExecutor<BaseSleepNightRecord> {
    @Query(value = "select r from BaseSleepNightRecord r where r.deviceSn=?1 and r.patient=?2 order by r.createTime desc")
    List<BaseSleepNightRecord> findByDeviceSnAndPatient(String deviceSn, String patient);
    @Query(value = "select r from BaseSleepNightRecord r where r.deviceSn=?1 and r.patient=?2 and r.status=?3 and r.createTime>?4 and r.day=?5 order by r.createTime desc")
    List<BaseSleepNightRecord> findBySnStaPaTime(String deviceSn,String patient,Integer status, Date benIn,String day);
}

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

@ -0,0 +1,19 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BaseSleepPlan;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/***
 * @ClassName: BaseSleepPlanDao
 * @Description:
 * @Auther: shi kejing
 * @Date: 2021/8/23 17:20
 */
public interface BaseSleepPlanDao extends PagingAndSortingRepository<BaseSleepPlan,Long>,
        JpaSpecificationExecutor<BaseSleepPlan> {
    List<BaseSleepPlan> findByPatientAndDeviceSn(String patient,String deviceSn);
}

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

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BaseSleepPlanDetail;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Bing on 2021/8/23.
 */
public interface BaseSleepPlanDetailDao extends PagingAndSortingRepository<BaseSleepPlanDetail,Long>,
        JpaSpecificationExecutor<BaseSleepPlanDetail> {
    List<BaseSleepPlanDetail> findByPatientAndDay(String patient, String day);
}

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

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.BaseYxDeviceIndex;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/26
 * @Description:
 */
public interface BaseYxDeviceIndexDao extends PagingAndSortingRepository<BaseYxDeviceIndex, String> {
}

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

@ -20,4 +20,7 @@ public interface DeviceDetailDao extends PagingAndSortingRepository<DeviceDetail
    @Query("select a from DeviceDetail a where a.deviceCode = ?1 and a.manufacturerCode = ?2")
    DeviceDetail findByDeviceCodeAndManufacturerCode(String deviceCode,String manufacturerCode);
    @Query("select a from DeviceDetail a where a.sim = ?2")
    List<DeviceDetail> findBySim(String sim);
}

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

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DeviceHealthIndex;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
public interface DeviceHealthIndexDao extends PagingAndSortingRepository<DeviceHealthIndex, String>, JpaSpecificationExecutor<DeviceHealthIndex> {
}

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

@ -0,0 +1,22 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.HvDeviceRecord;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
public interface HvDeviceRecordDao extends PagingAndSortingRepository<HvDeviceRecord, String>, JpaSpecificationExecutor<HvDeviceRecord> {
    @Query("select a from HvDeviceRecord a where a.deviceId = ?1")
    List<HvDeviceRecord> findByDeviceId(String deviceId);
}

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

@ -0,0 +1,16 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.HvDeviceSosLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/8/23
 * @Description:
 */
public interface HvDeviceSosLogDao extends PagingAndSortingRepository<HvDeviceSosLog, String>, JpaSpecificationExecutor<HvDeviceSosLog> {
}

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


برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است