Jelajahi Sumber

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

# Conflicts:
#	svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java
yeshijie 3 tahun lalu
induk
melakukan
ff5fccd077
17 mengubah file dengan 549 tambahan dan 16 penghapusan
  1. 26 0
      common/common-entity/sql记录
  2. 199 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/BaseSleepDeviceReport.java
  3. 11 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/DevicePatientDevice.java
  4. 10 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java
  5. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/BaseSleepDeviceReportDao.java
  6. 44 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  7. 12 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/YsDeviceController.java
  8. 11 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  9. 3 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  10. 46 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  11. 13 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  12. 9 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/OnlineContactService.java
  13. 3 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  14. 59 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  15. 12 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/dao/device/BaseSleepDeviceReportDao.java
  16. 29 4
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java
  17. 50 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

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

@ -1244,3 +1244,29 @@ 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='爱牵挂睡眠带数据';

+ 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;
    }
}

+ 11 - 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 睡眠带
    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;
@ -318,4 +320,12 @@ 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;
    }
}

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

@ -38,6 +38,16 @@ 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}";
    /**
     * 睡眠带 修改心率呼吸率报警阈值
     */
    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";

+ 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> {
}

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

@ -305,6 +305,50 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @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")

+ 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);
        }

+ 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(

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

@ -164,7 +164,7 @@ 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" +
        String sql ="SELECT i.code,r.team_code,i.org_code,i.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+assistanceDO.getPatient()+"' and i.code='emergencyAssistance' ";
        List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
@ -966,10 +966,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);

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

@ -1065,6 +1065,52 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return response.getBody();
    }
    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.GET, getCookie());
        return response.getBody();
    }
    /******************************************* 爱牵挂设备end *****************************************************/
}

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

@ -9,6 +9,8 @@ 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;
@ -63,6 +65,8 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    private PatientFamilyMemberService familyMemberService;
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    /**
     * 签约记录
@ -562,6 +566,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);

+ 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;
    }

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

@ -165,7 +165,7 @@ 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" +
        String sql ="SELECT i.code,r.team_code,i.org_code,i.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+orderDO.getPatient()+"' and i.code='preventLost' ";
        List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
@ -377,7 +377,7 @@ 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" +
        String sql ="SELECT i.code,r.team_code,i.org_code,i.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id   and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = '"+orderDO.getPatient()+"' and i.code='preventLost' ";
        List<Map<String,Object>> items = jdbcTemplate.queryForList(sql);
@ -1157,7 +1157,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);

+ 59 - 0
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";
@ -141,6 +146,60 @@ public class StatisticsService {
        return  res;
    }
    public PageEnvelop getAllDynamics(Integer page,Integer size){
        List 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";
        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){
                    System.out.println(patient.getId());
                    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", log.getCreateTime());
            object.put("clientType", log.getClientType());
            result.add(object);
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",result,page,size,count);
    }
    /**
     * 服务排名分析
     * @param endDate

+ 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> {
}

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

@ -248,7 +248,8 @@ public class DeviceController {
        }
    }
    @ApiOperation("爱牵挂设备睡眠接收")
    /*******************************************睡眠带begin****************************************************************/
    @ApiOperation("爱牵挂-睡眠带睡眠接收")
    @RequestMapping(value = "bySleep", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String bySleep(
            @ApiParam(name="device",required = false,value="睡眠带MAC地址",defaultValue = "")
@ -269,7 +270,7 @@ public class DeviceController {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("爱牵挂睡眠接收,请求参数:"+paraString);
            logger.info("爱牵挂-睡眠带接收,请求参数:"+paraString);
            deviceService.bySleep(device,time_begin,heartrate,breath,turn_over,is_warn);
            return success();
@ -279,7 +280,7 @@ public class DeviceController {
        }
    }
    @ApiOperation("爱牵挂设备睡眠报告接收")
    @ApiOperation("爱牵挂-睡眠带睡眠报告接收")
    @RequestMapping(value = "bySleepReport", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String bySleep(
            @ApiParam(name="device",required = false,value="睡眠带MAC地址",defaultValue = "")
@ -325,7 +326,7 @@ public class DeviceController {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("爱牵挂睡眠接收,请求参数:"+paraString);
            logger.info("爱牵挂-睡眠带睡眠报考,请求参数:"+paraString);
            deviceService.bySleepReport(device,date,fallasleep,sleepTime,restTime,awakeTime,lightTime,remTime,deepTime,bucket,
                    avghr,avgbr,awakePer,remPer,lightPer,efficiency,score);
@ -336,7 +337,31 @@ public class DeviceController {
        }
    }
    @ApiOperation("爱牵挂-睡眠带wifi在线状态接收")
    @RequestMapping(value = "byOnlineStatus", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String byOnlineStatus(
            @ApiParam(name="device",required = false,value="睡眠带MAC地址",defaultValue = "")
            @RequestParam(value = "device",required = true) String device,
            @ApiParam(name="onlinestatu",required = false,value="在线状态(0不在线,1在线)")
            @RequestParam(value = "onlinestatu",required = false) String onlinestatu,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            HttpServletRequest request) {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("爱牵挂-睡眠带wifi在线状态接收:"+paraString);
            deviceService.byOnlineStatus(device,onlinestatu,time_begin);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /*******************************************睡眠带end****************************************************************/
    /**
     * 返回接口处理结果
     *

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

@ -5,10 +5,12 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.BaseSleepDeviceReportDao;
import com.yihu.jw.care.dao.device.DevicePatientHealthIndexDao;
import com.yihu.jw.care.dao.device.DeviceSosLogDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.BaseSleepDeviceReport;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.DeviceSosLogDO;
@ -76,6 +78,8 @@ public class DeviceService {
    private HealthIndexUtil healthIndexUtil;
    @Autowired
    private ImUtil imUtil;
    @Autowired
    private BaseSleepDeviceReportDao sleepDeviceReportDao;
    /**
     * 获取爱牵挂管理员cookie
@ -551,7 +555,12 @@ public class DeviceService {
    public void bySleep(String device,String time_begin,String heartrate,String breath,String turn_over,String is_warn) {
        try {
            if(StringUtils.isNotBlank(device)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
                if (devicePatientDeviceDos.size()>0){
                    if ("1".equals(is_warn)){//触发工单
                    }
                }
            }
        } catch (Exception e) {
@ -561,12 +570,52 @@ public class DeviceService {
    @Async
    public void bySleepReport(String device,String date,String fallasleep,String sleepTime,String restTime,String awakeTime,String lightTime,
    public void bySleepReport(String device,String dateStr,String fallasleep,String sleepTime,String restTime,String awakeTime,String lightTime,
                              String remTime,String deepTime,String[] bucket,String avghr,String avgbr,String awakePer,String remPer,String lightPer,
                              String efficiency,String score) {
        try {
            if(StringUtils.isNotBlank(device)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
                if (devicePatientDeviceDos.size()>0){
                    String patient = devicePatientDeviceDos.get(0).getUser();
                    BaseSleepDeviceReport report = new BaseSleepDeviceReport();
                    report.setPatient(patient);
                    Date date = DateUtil.strToDate(dateStr,DateUtil.YYYYMMDD);
                    report.setCreateTime(date);
                    report.setFallaSleep(fallasleep);
                    report.setSleepTime(sleepTime);
                    report.setRestTime(restTime);
                    report.setAwakeTime(awakeTime);
                    report.setLightTime(lightTime);
                    report.setRemTime(remTime);
                    report.setDeepTime(deepTime);
                    String buckets =JSON.toJSONString(bucket);
                    report.setBucket(buckets);
                    report.setAvghr(avghr);
                    report.setAvgbr(avgbr);
                    report.setAwakePer(awakePer);
                    report.setRemPer(remPer);
                    report.setLightPer(lightPer);
                    report.setEfficiency(efficiency);
                    report.setScore(score);
                    sleepDeviceReportDao.save(report);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Async
    public void byOnlineStatus(String device,String onlinestatu,String time_begin){
        try {
            if(StringUtils.isNotBlank(device)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice tmp = devicePatientDeviceDos.get(0);
                    tmp.setOnlineStatus(Integer.parseInt(onlinestatu));
                    patientDeviceDao.save(tmp);
                }
            }
        } catch (Exception e) {