LAPTOP-KB9HII50\70708 1 年間 前
コミット
48fb979f35

+ 20 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/DeviceCategoryDao.java

@ -0,0 +1,20 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.care.device.DeviceCategory;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface DeviceCategoryDao extends PagingAndSortingRepository<DeviceCategory, Long> {
	@Query("select a from DeviceCategory a where a.del = '1'")
	List<DeviceCategory> findAll();
	@Query("select a from DeviceCategory a where a.code = ?1 and  a.del = '1'")
	DeviceCategory findByCode(String code);
}

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/device/DeviceDao.java

@ -3,11 +3,11 @@
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.base.dao.device;
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.care.device.Device;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List;

+ 128 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/DevicePatientHealthIndexDao.java

@ -0,0 +1,128 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
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 java.util.Date;
import java.util.List;
public interface DevicePatientHealthIndexDao
		extends PagingAndSortingRepository<DevicePatientHealthIndex, Long>, JpaSpecificationExecutor<DevicePatientHealthIndex> {
	List<DevicePatientHealthIndex> findByIdcardAndType(String idcard, Integer type);
	/**
	 * 按录入时间和患者标识查询健康记录
	 *
	 * @param patientCode
	 * @param date
	 * @return
	 */
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and type = ?2 and a.recordDate = ?3 and a.del = '1'")
	Iterable<DevicePatientHealthIndex> findByPatienDate(String patientCode, int type, Date date);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate between ?3 and ?4 and a.del = '1' group by a.recordDate order by a.recordDate asc")
	Iterable<DevicePatientHealthIndex> findByPatient(String user, int type, Date begin, Date end);
	@Query("select a.value1 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value1 > '0' and a.del = '1' order by a.recordDate desc")
	Page<String> findValue1ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	@Query("select a.value2 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value2 > '0' and a.del = '1' order by a.recordDate desc")
	Page<String> findValue2ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	@Query("select a.value3 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value3 > '0' and a.del = '1' order by a.recordDate desc")
	Page<String> findValue3ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	@Query("select a.value4 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value4 > '0' and a.del = '1' order by a.recordDate desc")
	Page<String> findValue4ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	@Query("select a.value5 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value5 > '0' and a.del = '1' order by a.recordDate desc")
	Page<String> findValue5ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	@Query("select a.value6 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value6 > '0' and a.del = '1' order by a.recordDate desc")
	Page<String> findValue6ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	@Query("select a.value7 from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate < ?3 and a.value7 > '0' and a.del = '1' order by a.recordDate desc")
	Page<String> findValue7ByPatient(String user, int type, Date recordDate, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.recordDate >= ?3 and a.recordDate <= ?4 and a.del = '1'")
	Page<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Date start, Date end, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.value2 =?3 and a.recordDate >= ?4 and a.recordDate <= ?5 and a.del = '1'")
	Page<DevicePatientHealthIndex> findIndexByPatient(String patient, int type,String gi_type, Date start, Date end, Pageable pageRequest);
	@Query("select a from DevicePatientHealthIndex a where a.user = ?1 and a.type = ?2 and a.del = '1'")
	List<DevicePatientHealthIndex> findIndexByPatient(String patient, int type, Pageable pageRequest);
	@Query("SELECT a FROM DevicePatientHealthIndex a where a.user = ?1 and a.del = '1' order by a.recordDate desc ")
	List<DevicePatientHealthIndex> findRecentByPatient(String patient);
	@Query("select DATE_FORMAT(a.recordDate,'%Y-%m-%d') from DevicePatientHealthIndex a where a.user = ?1 and a.recordDate >= ?2 and a.recordDate <= ?3 and a.del = '1' group by DATE_FORMAT(a.recordDate,'%Y-%m-%d') order by DATE_FORMAT(a.recordDate,'%Y-%m-%d') desc")
	List<String> findDateList(String patient, Date start, Date end, Pageable pageRequest);
	/**
	 * 获取患者一天血糖值
	 */
	@Query("select a from DevicePatientHealthIndex a where a.type=1 and a.user = ?1 and DATE_FORMAT(a.recordDate,'%Y-%m-%d') = ?2 and a.del = '1' order by a.recordDate,a.id")
	List<DevicePatientHealthIndex> findByDate(String patient, String date);
	@Query(value = "select a.* from wlyy_patient_health_index a where a.user=?1 and a.type=?2 and a.del='1' order by a.record_date desc limit 0,1",nativeQuery = true)
	DevicePatientHealthIndex findLastData(String patient, Integer type);
	/**
	 * 获取患者一天的具体某个类型的数据
	 */
	@Query("select a from DevicePatientHealthIndex a where a.type=?1 and a.user = ?2 and DATE_FORMAT(a.recordDate,'%Y-%m-%d') = ?3 and a.deviceSn = ?4 and a.del = '1' order by a.recordDate,a.id")
	List<DevicePatientHealthIndex> findByDateAndType(int type,String patient, String date,String devicesn);
	
	/**
	 * 获取患者单月的具体某个类型的数据
	 */
	@Query(value = "SELECT a.* FROM wlyy_patient_health_index a WHERE a.type=?1 AND a.USER=?2 AND DATE_FORMAT(a.record_date,'%Y-%m')=?3 AND a.device_sn=?4 AND a.del='1' ORDER BY a.record_date,a.id",nativeQuery = true)
	List<DevicePatientHealthIndex> findByDateMonthAndType(int type,String patient, String date,String devicesn);
	
	
	/**
	 * 上次血糖值
	 */
	@Query(value = "select a.value1 from wlyy_patient_health_index a where a.type=1 and a.user = ?1 and a.id<?2 and a.value2 = ?3 and a.del = '1' order by a.sort_date desc ,record_date desc limit 0,1",nativeQuery = true)
	String getPreValue(String user,Long id,String value2);
	@Query(value = "select a.* from wlyy_patient_health_index a where a.user = ?1 and a.type = ?2 and a.value2 =?3 and a.record_date >= ?4 and a.record_date <= ?5 and a.del = '1' order by a.sort_date desc ,record_date desc limit ?6 ,?7",nativeQuery = true)
	List<DevicePatientHealthIndex> findIndexByPatientNative(String patient, int type,String gi_type, Date start, Date end,int currentSize,int pageSize);
	/**
	 * 获取患者某一天的血糖  普通sql写法
	 * @param patient
	 * @param date
	 * @return
	 */
	@Query(value = "select a.* from wlyy_patient_health_index a where a.type=1 and a.user = ?1 and DATE_FORMAT(a.record_date,'%Y-%m-%d') = ?2 and a.del = '1' order by a.record_date,a.id",nativeQuery = true)
	List<DevicePatientHealthIndex> findByDateNative(String patient, String date );
	@Query(value = "select a.* from wlyy_patient_health_index a where a.user = ?1 and a.type = ?2 and a.record_date >= ?3 and a.record_date <= ?4 and a.del = '1' order by a.sort_date desc ,record_date desc limit ?5 ,?6",nativeQuery = true)
	List<DevicePatientHealthIndex> findIndexByPatientNative(String patient, int type, Date start, Date end,int currentSize,int pageSize);
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from wlyy_patient_health_index a where a.user = ?1 and a.record_date >= ?2 and a.record_date <= ?3 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?4 ,?5",nativeQuery = true)
	List<String> findDateList(String patient,Date start ,Date end,Long currentSize,int pageSize);
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from wlyy_patient_health_index a where a.user = ?1 and a.type=?2 and a.record_date >= ?3 and a.record_date <= ?4 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?5 ,?6",nativeQuery = true)
	List<String> findDateList(String patient,int type,Date start ,Date end,Long currentSize,int pageSize);
	@Query(value = "select DATE_FORMAT(a.record_date,'%Y-%m-%d') from wlyy_patient_health_index a where a.user = ?1 and a.del = '1' group by DATE_FORMAT(a.record_date,'%Y-%m-%d') order by DATE_FORMAT(a.record_date,'%Y-%m-%d') desc limit ?2 ,?3",nativeQuery = true)
	List<String> findDateList1(String patient,int currentSize,int pageSize);
	@Query(value="select * from wlyy_patient_health_index where user = ?1 and type = ?2 ORDER BY record_date desc limit 0 ,5",nativeQuery = true)
	List<DevicePatientHealthIndex> findByPatientAndTypeByPage(String patientCode, int type);
	@Query("select count(a) from DevicePatientHealthIndex a where a.recordDate >= ?1 and a.recordDate <= ?2 and a.type in (1,2) and a.status = ?3 and a.del = '1' and a.user = ?4")
	int getCountByTimeAndStatus(Date start, Date end, int status, String patientCode);
}

+ 10 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/DeviceWxMessageDao.java

@ -0,0 +1,10 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.base.device.DeviceWxMessage;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
public interface DeviceWxMessageDao extends PagingAndSortingRepository<DeviceWxMessage, Long>, JpaSpecificationExecutor<DeviceWxMessage> {
}

+ 27 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/DoctorHealthStandardDao.java

@ -0,0 +1,27 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.base.device.DoctorHealthStandard;
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;
/**
 * @author huangwenjie
 * @date 2017/9/14 21:43
 */
public interface DoctorHealthStandardDao extends
		PagingAndSortingRepository<DoctorHealthStandard, Long>,
        JpaSpecificationExecutor<DoctorHealthStandard>{
    // 查询医生健康指标预警值方案
    Iterable<DoctorHealthStandard> findByDoctor(String code);
    @Modifying
    @Query("delete DoctorHealthStandard a where a.doctor = ?1")
    int deleteByDoctor(String doctorcode);
    @Query("select a from DoctorHealthStandard a where a.doctor = ?1 and a.type = ?2")
    DoctorHealthStandard findByDoctorType(String patient, int type);
}

+ 12 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/PatientAimBloodPressureDao.java

@ -0,0 +1,12 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.base.device.PatientAimBloodPressure;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/1/5.
 */
public interface PatientAimBloodPressureDao extends PagingAndSortingRepository<PatientAimBloodPressure, Integer>, JpaSpecificationExecutor<PatientAimBloodPressure> {
    public  PatientAimBloodPressure findByPatientcode(String patientcode);
}

+ 13 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/PatientAimBloodSuggerDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.base.device.PatientAimBloodSugger;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Trick on 2018/1/5.
 */
public interface PatientAimBloodSuggerDao extends PagingAndSortingRepository<PatientAimBloodSugger, Integer>, JpaSpecificationExecutor<PatientAimBloodSugger> {
    public PatientAimBloodSugger findByPatientcode(String patientcode);
}

+ 23 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/PatientAimSportsDao.java

@ -0,0 +1,23 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.base.device.PatientAimSports;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * 居民-运动目标
 * @author huangwenjie
 * @date 2017/9/12 16:07
 */
public interface PatientAimSportsDao extends
        PagingAndSortingRepository<PatientAimSports, Long>,
        JpaSpecificationExecutor<PatientAimSports> {
    @Query("from PatientAimSports p where p.code=?1")
    PatientAimSports findByCode(String code);
    @Query("from PatientAimSports p where p.patientcode =?1 and p.bmiMax is not null and p.bmiMin is not null")
    PatientAimSports getPatientAimSportsByPatientCode(String patientCode);
}

+ 14 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/PatientBloodSuggerDao.java

@ -0,0 +1,14 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.base.device.PatientBloodSugger;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Reece on 2017/5/11.
 */
public interface PatientBloodSuggerDao extends PagingAndSortingRepository<PatientBloodSugger,Long> {
//    按ID倒序查最近的有效默认时间段
    @Query(value = "select t.* from wlyy_patient_blood_sugger t where t.del = 1 order by t.id desc limit 0,1 ",nativeQuery = true)
    PatientBloodSugger findRecent();
}

+ 2 - 2
svr/svr-base/src/main/java/com/yihu/jw/base/dao/device/PatientDeviceDao.java

@ -1,11 +1,11 @@
package com.yihu.jw.base.dao.device;
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
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.jpa.repository.JpaRepository;
import java.util.List;

+ 20 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/PatientDeviceLogDao.java

@ -0,0 +1,20 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.patient.PatientDeviceLog;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientDeviceLogDao extends PagingAndSortingRepository<PatientDeviceLog, Long>, JpaSpecificationExecutor<PatientDeviceLog> {
    @Query("select pdl from PatientDeviceLog pdl where pdl.patient=?1 and pdl.categoryCode=?2")
    List<PatientDeviceLog> findByPatientAndCategoryCode(String patient,String categoryCode);
    
    @Query("select pdl from PatientDeviceLog pdl where pdl.patient=?1 group by pdl.deviceSn ")
    List<PatientDeviceLog> findByPatientGroupByDeviceSn(String patient);
    @Query("select a from PatientDeviceLog a")
    List<PatientDeviceLog> findAllList();
}

+ 27 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/PatientHealthStandardDao.java

@ -0,0 +1,27 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.base.device.PatientHealthStandard;
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;
public interface PatientHealthStandardDao extends
		PagingAndSortingRepository<PatientHealthStandard, Long>,
		JpaSpecificationExecutor<PatientHealthStandard> {
	// 查询患者健康指标预警值
	Iterable<PatientHealthStandard> findByPatient(String patient);
	@Modifying
	@Query("delete PatientHealthStandard a where a.patient = ?1")
	int deleteByPatient(String patient);
	@Query("select a from PatientHealthStandard a where a.patient = ?1 and a.type = ?2")
	PatientHealthStandard findByPatientType(String patient, int type);
}

+ 35 - 0
business/base-service/src/main/java/com/yihu/jw/device/dao/PatientHealthTimeDao.java

@ -0,0 +1,35 @@
package com.yihu.jw.device.dao;
import com.yihu.jw.entity.base.device.PatientHealthTime;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Reece on 2017/5/11.
 */
public interface PatientHealthTimeDao extends PagingAndSortingRepository<PatientHealthTime, Long> {
    //    根据居民和设备sn码查询自定义的血糖时间段
    @Query(value = "select t.* from wlyy_patient_health_time t where t.del = 1 and t.user = ?1 and t.device_sn = ?2 ", nativeQuery = true)
    PatientHealthTime findByUserAndSN(String user, String deviceSN);
    //    根据居民和设备sn码修改自定义的血糖时间段
    @Modifying
    @Query("update PatientHealthTime t set t.fastingStart = ?1,t.fastingEnd = ?2,t.afterBreakfastStart = ?3,t.afterBreakfastEnd = ?4," +
            "t.beforeLunchStart = ?5 ,t.beforeLunchEnd = ?6 ,t.afterLunchStart = ?7,t.afterLunchEnd = ?8 ,t.beforeDinnerStart = ?9,t.beforeDinnerEnd = ?10," +
            "t.afterDinnerStart = ?11,t.afterDinnerEnd = ?12,t.beforeSleepStart = ?13,t.beforeSleepEnd = ?14 where t.del = 1 and t.user = ?15 and t.deviceSN = ?16 ")
    int modifyByUserAndSN(String fastingStart, String fastingEnd, String afterBreakfastStart, String afterBreakfastEnd, String beforeLunchStart, String beforeLunchEnd,
                          String afterLunchStart, String afterLunchEnd, String beforeDinnerStart, String beforeDinnerEnd, String afterDinnerStart, String afterDinnerEnd,
                          String beforeSleepStart, String beforeSleepEnd, String user, String deviceSN);
    //    根据居民和设备sn码删除自定义的血糖时间段
    @Modifying
    @Query("update PatientHealthTime t set t.del = 0 where t.user = ?1 and t.deviceSN = ?2 ")
    int deleteByUserAndSN(String user, String deviceSN);
    //    更换个人sv码
    @Modifying
    @Query("update PatientHealthTime t set t.deviceSN = ?3 where t.user = ?1 and t.deviceSN = ?2 ")
    int updateDeviceSN(String user, String deviceSN,String newDeviceSN );
}