liubing hace 4 años
padre
commit
36c8ff65db

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

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

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

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

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

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

+ 29 - 0
svr/svr-iot/src/main/java/com/yihu/iot/controller/monitorPlatform/MonitorPlatformController.java

@ -6,6 +6,7 @@ import com.yihu.iot.service.company.IotCompanyService;
import com.yihu.iot.service.device.IotPatientDeviceService;
import com.yihu.iot.service.dict.IotSystemDictService;
import com.yihu.iot.service.equipment.IotEqtDetailService;
import com.yihu.iot.service.monitorPlatform.CopdXeekDeviceService;
import com.yihu.iot.service.monitorPlatform.MonitorPlatformService;
import com.yihu.iot.service.product.IotProductBaseInfoService;
import com.yihu.jw.entity.iot.device.IotPatientDeviceDO;
@ -13,6 +14,7 @@ import com.yihu.jw.entity.iot.dict.IotSystemDictDO;
import com.yihu.jw.restmodel.iot.device.IotPatientDeviceVO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.iot.IotRequestMapping;
import io.swagger.annotations.Api;
@ -48,6 +50,8 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
    private IotEqtDetailService iotEqtDetailService;
    @Autowired
    private IotCompanyService iotCompanyService;
    @Autowired
    private CopdXeekDeviceService copdXeekDeviceService;
    @PostMapping(value = IotRequestMapping.PatientDevice.addPatientDevice)
@ -627,6 +631,31 @@ public class MonitorPlatformController extends EnvelopRestEndpoint {
        }
    }
    @RequestMapping(value = "getXeekDeviceData",method = RequestMethod.GET)
    @ApiOperation(value = "塞克设备数据获取")
    public ObjEnvelop getXeekDeviceData(@ApiParam(name="deviceSN",value = "设备sn码")
                                    @RequestParam(value = "deviceSN")String deviceSN,
                                    @ApiParam(name="reportType",value = "测试项目 1=吸气测试;2=呼气测试;6=MVV 测试;7=慢通气测试")
                                    @RequestParam(value = "reportType")String reportType,
                                    @ApiParam(name="patient",value = "patient")
                                    @RequestParam(value = "patient",required = false)String patient,
                                    @ApiParam(name="parameter",value = "数据指标 inCount,outCount")
                                    @RequestParam(value = "parameter",required = false)String parameter,
                                    @ApiParam(name="time",value = "7 30 90")
                                    @RequestParam(value = "time",required = false)String time,
                                    @ApiParam(name="begin",value = "开始时间 YYYY-MM-DD HH:MM:SS" ,defaultValue = "2021-04-14 00:00:00")
                                    @RequestParam(value = "begin")String begin,
                                    @ApiParam(name="end",value = "结束时间 YYYY-MM-DD HH:MM:SS" ,defaultValue = "2021-04-14 23:59:59" )
                                    @RequestParam(value = "end")String end)
    {
        try {
            return ObjEnvelop.getSuccess("查询成功",copdXeekDeviceService.getDeviceData(patient,deviceSN,reportType,parameter,time,begin,end));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败"+e.getMessage());
        }
    }
    @ApiOperation("获取门诊记录/住院记录(基卫+APP)")
    @RequestMapping(value = "/event", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    public String getAllEvent(@ApiParam(name = "patient", value = "患者代码", defaultValue = "")

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -0,0 +1,20 @@
package com.yihu.iot.dao.platform;
import com.yihu.jw.entity.iot.copdDevice.WlyyXeekPatientDeviceDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by yeshijie on 2021/4/15.
 */
public interface WlyyXeekPatientDeviceDao extends PagingAndSortingRepository<WlyyXeekPatientDeviceDO, Long>, JpaSpecificationExecutor<WlyyXeekPatientDeviceDO> {
    WlyyXeekPatientDeviceDO findByDeviceSnAndNameAndSexAndBirthday(String deviceSn,String name,Integer sex,String birthday);
    @Query("from WlyyXeekPatientDeviceDO c where c.patient is null)")
    List<WlyyXeekPatientDeviceDO> findNoPatient();
}

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

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