feat(watch): 支持Oracle数据库兼容性改进
- 将MyBatis查询中的"LIMIT 1"替换为"FETCH FIRST 1 ROWS ONLY" - 在XML映射文件中将ROWNUM用于分页查询以提高Oracle兼容性 - 将MySQL特定函数转换为Oracle兼容语法: - YEAR()替换为EXTRACT(YEAR FROM) - TIMESTAMPDIFF()替换为EXTRACT(HOUR/MINUTE/SECOND FROM) - IFNULL()替换为NVL() - CURDATE()替换为SYSDATE - 更新复杂查询语句使用ROW_NUMBER()窗口函数替代LEFT JOIN - 修改表名引用从反引号到双引号以提高数据库兼容性
This commit is contained in:
+3
-3
@@ -894,7 +894,7 @@ public class WatchDataApiServiceImpl implements WatchDataApiService {
|
|||||||
WatchStatUserInfoDaySleep::getDataDate)
|
WatchStatUserInfoDaySleep::getDataDate)
|
||||||
.eq(WatchStatUserInfoDaySleep::getUserId, userId)
|
.eq(WatchStatUserInfoDaySleep::getUserId, userId)
|
||||||
.orderByDesc(WatchStatUserInfoDaySleep::getDataDate)
|
.orderByDesc(WatchStatUserInfoDaySleep::getDataDate)
|
||||||
.last("limit 1");
|
.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
|
|
||||||
WatchStatUserInfoDaySleep data = watchStatUserInfoDaySleepMapper.selectOne(queryWrapper);
|
WatchStatUserInfoDaySleep data = watchStatUserInfoDaySleepMapper.selectOne(queryWrapper);
|
||||||
|
|
||||||
@@ -1016,7 +1016,7 @@ public class WatchDataApiServiceImpl implements WatchDataApiService {
|
|||||||
queryWrapper.eq(WatchData::getUserid, userId)
|
queryWrapper.eq(WatchData::getUserid, userId)
|
||||||
.orderByDesc(WatchData::getLastUpdateTime)
|
.orderByDesc(WatchData::getLastUpdateTime)
|
||||||
.eq(WatchData::getType, type)
|
.eq(WatchData::getType, type)
|
||||||
.last("limit 1");
|
.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
WatchData watchData = watchDataMapper.selectOne(queryWrapper);
|
WatchData watchData = watchDataMapper.selectOne(queryWrapper);
|
||||||
if (watchData == null) {
|
if (watchData == null) {
|
||||||
return null;
|
return null;
|
||||||
@@ -1033,7 +1033,7 @@ public class WatchDataApiServiceImpl implements WatchDataApiService {
|
|||||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("user_id", userId)
|
queryWrapper.eq("user_id", userId)
|
||||||
.orderByDesc("data_date")
|
.orderByDesc("data_date")
|
||||||
.last("limit 1");
|
.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
return queryWrapper.lambda();
|
return queryWrapper.lambda();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -32,6 +32,6 @@ public interface WatchDataHeartRateMapper extends MPJBaseMapper<WatchDataHeartRa
|
|||||||
* @param bindUserId
|
* @param bindUserId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Select("select * from watch_data_heart_rate where bind_user_id = #{bindUserId} and data_date = (select MAX(data_date) from watch_data_heart_rate where bind_user_id = #{bindUserId})")
|
@Select("SELECT * FROM watch_data_heart_rate WHERE bind_user_id = #{bindUserId} AND data_date = (SELECT MAX(data_date) FROM watch_data_heart_rate WHERE bind_user_id = #{bindUserId})")
|
||||||
List<WatchDataHeartRate> latestDataTempByUserId(@Param("bindUserId") String bindUserId);
|
List<WatchDataHeartRate> latestDataTempByUserId(@Param("bindUserId") String bindUserId);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ public interface WatchDataSpo2Mapper extends MPJBaseMapper<WatchDataSpo2> {
|
|||||||
* @param bindUserId
|
* @param bindUserId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Select("select * from watch_data_spo2 where bind_user_id = #{bindUserId} and data_date = (select MAX(data_date) from watch_data_spo2 where bind_user_id = #{bindUserId})")
|
@Select("SELECT * FROM watch_data_spo2 WHERE bind_user_id = #{bindUserId} AND data_date = (SELECT MAX(data_date) FROM watch_data_spo2 WHERE bind_user_id = #{bindUserId})")
|
||||||
List<WatchDataSpo2> latestDataTempByUserId(@Param("bindUserId") String bindUserId);
|
List<WatchDataSpo2> latestDataTempByUserId(@Param("bindUserId") String bindUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -21,7 +21,7 @@ public interface WatchDataStressMapper extends MPJBaseMapper<WatchDataStress> {
|
|||||||
|
|
||||||
IPage<WatchDataStress> selectStressByYear(IPage<WatchDataStress> page, StatisticsReq req);
|
IPage<WatchDataStress> selectStressByYear(IPage<WatchDataStress> page, StatisticsReq req);
|
||||||
|
|
||||||
@Select("select * from watch_data_stress where bind_user_id = #{bindUserId} order by start_time_stamp desc limit 1")
|
@Select("SELECT * FROM (SELECT * FROM watch_data_stress WHERE bind_user_id = #{bindUserId} ORDER BY start_time_stamp DESC) WHERE ROWNUM = 1")
|
||||||
WatchDataStress selectWatchDataStressByUserId(@Param("bindUserId") String bindUserId);
|
WatchDataStress selectWatchDataStressByUserId(@Param("bindUserId") String bindUserId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -29,7 +29,7 @@ public interface WatchDataStressMapper extends MPJBaseMapper<WatchDataStress> {
|
|||||||
* @param bindUserId
|
* @param bindUserId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Select("select * from watch_data_stress where bind_user_id = #{bindUserId} and data_date = (select MAX(data_date) from watch_data_stress where bind_user_id = #{bindUserId})")
|
@Select("SELECT * FROM watch_data_stress WHERE bind_user_id = #{bindUserId} AND data_date = (SELECT MAX(data_date) FROM watch_data_stress WHERE bind_user_id = #{bindUserId})")
|
||||||
List<WatchDataStress> latestDataTempByUserId(@Param("bindUserId") String bindUserId);
|
List<WatchDataStress> latestDataTempByUserId(@Param("bindUserId") String bindUserId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -23,7 +23,7 @@ public interface WatchDataTemperatureMapper extends MPJBaseMapper<WatchDataTempe
|
|||||||
|
|
||||||
IPage<WatchDataTemperature> selectTempByYear(@Param("page") IPage<WatchDataTemperature> page, @Param("req") StatisticsReq req);
|
IPage<WatchDataTemperature> selectTempByYear(@Param("page") IPage<WatchDataTemperature> page, @Param("req") StatisticsReq req);
|
||||||
|
|
||||||
@Select("select * from watch_data_temperature where bind_user_id = #{bindUserId} and Date(data_date) = Date(#{dateTime}) order by time_stamp")
|
@Select("SELECT * FROM watch_data_temperature WHERE bind_user_id = #{bindUserId} AND data_date = #{dateTime} ORDER BY time_stamp")
|
||||||
List<WatchDataTemperature> selectTempByUserId(@Param("bindUserId") String bindUserId,@Param("dateTime") Date dateTime);
|
List<WatchDataTemperature> selectTempByUserId(@Param("bindUserId") String bindUserId,@Param("dateTime") Date dateTime);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -31,6 +31,6 @@ public interface WatchDataTemperatureMapper extends MPJBaseMapper<WatchDataTempe
|
|||||||
* @param bindUserId
|
* @param bindUserId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Select("select * from watch_data_temperature where bind_user_id = #{bindUserId} and data_date = (select MAX(data_date) from watch_data_temperature where bind_user_id = #{bindUserId})")
|
@Select("SELECT * FROM watch_data_temperature WHERE bind_user_id = #{bindUserId} AND data_date = (SELECT MAX(data_date) FROM watch_data_temperature WHERE bind_user_id = #{bindUserId})")
|
||||||
List<WatchDataTemperature> latestDataTempByUserId(@Param("bindUserId") String bindUserId);
|
List<WatchDataTemperature> latestDataTempByUserId(@Param("bindUserId") String bindUserId);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -66,7 +66,7 @@ public interface WatchDeviceMapper extends MPJBaseMapper<WatchDevice> {
|
|||||||
|
|
||||||
List<String> selectDeviceUserId(@Param("deptId") String deptId);
|
List<String> selectDeviceUserId(@Param("deptId") String deptId);
|
||||||
|
|
||||||
@Select(value = "SELECT LEFT(org_code,6) as orgCode, count(1) as medicalCount FROM watch_device GROUP BY LEFT(org_code,6)")
|
@Select(value = "SELECT SUBSTR(org_code, 1, 6) as orgCode, COUNT(1) as medicalCount FROM watch_device GROUP BY SUBSTR(org_code, 1, 6)")
|
||||||
List<JSONObject> getWatchSum();
|
List<JSONObject> getWatchSum();
|
||||||
|
|
||||||
List<WearCount> selectWearCount(@Param("orgCodeList") List<String> orgCodeList);
|
List<WearCount> selectWearCount(@Param("orgCodeList") List<String> orgCodeList);
|
||||||
|
|||||||
+10
-10
@@ -16,10 +16,10 @@ import java.util.Map;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface WatchMapper {
|
public interface WatchMapper {
|
||||||
|
|
||||||
@Select("SELECT ROUND(SYSDATE - (SELECT CAST(bind_date AS DATE) FROM watch_bind_his WHERE bind_user_id = #{id} ORDER BY bind_date DESC limit 1)) AS days")
|
@Select("SELECT TRUNC(SYSDATE - CAST(bind_date AS DATE)) AS days FROM (SELECT bind_date FROM watch_bind_his WHERE bind_user_id = #{id} ORDER BY bind_date DESC FETCH FIRST 1 ROWS ONLY)")
|
||||||
Integer getUseDays(@Param("id") String id);
|
Integer getUseDays(@Param("id") String id);
|
||||||
|
|
||||||
@Select("select length(nm.status) minutes,TO_CHAR(n.data_date,'YYYY-MM-DD') dataDate from watch_data_sleep_new_minute nm left join watch_data_sleep_new n on nm.sleep_id = n.id where n.id = ( select id from watch_data_sleep_new WHERE bind_user_id = #{id} order by data_date desc limit 1) and nm.STATUS not like '%55%' limit 1")
|
@Select("SELECT LENGTH(nm.status) minutes, TO_CHAR(n.data_date,'YYYY-MM-DD') dataDate FROM watch_data_sleep_new_minute nm LEFT JOIN watch_data_sleep_new n ON nm.sleep_id = n.id WHERE n.id = (SELECT id FROM watch_data_sleep_new WHERE bind_user_id = #{id} ORDER BY data_date DESC FETCH FIRST 1 ROWS ONLY) AND nm.STATUS NOT LIKE '%55%' AND ROWNUM = 1")
|
||||||
WatchDataDTO getDataSleep(@Param("id") String id);
|
WatchDataDTO getDataSleep(@Param("id") String id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -27,28 +27,28 @@ public interface WatchMapper {
|
|||||||
* @param id 用户 ID
|
* @param id 用户 ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Select("SELECT long_duration_total minutes, data_date dataDate FROM watch_stat_user_info_day_sleep WHERE user_id = #{id} and long_duration_total > 0 ORDER BY data_date DESC LIMIT 1;")
|
@Select("SELECT long_duration_total minutes, data_date dataDate FROM watch_stat_user_info_day_sleep WHERE user_id = #{id} AND long_duration_total > 0 ORDER BY data_date DESC FETCH FIRST 1 ROWS ONLY")
|
||||||
WatchDataDTO getDataSleepNew(@Param("id") String id);
|
WatchDataDTO getDataSleepNew(@Param("id") String id);
|
||||||
|
|
||||||
@Select("SELECT AVG(ROUND((CAST(d.wake_up_time AS DATE) - CAST(d.fall_asleep_time AS DATE)) * 24 * 60)) AS aveMinute FROM watch_data_sleep_new_day d LEFT JOIN watch_data_sleep_new n ON d.sleep_id = n.id WHERE n.id IN (SELECT id FROM watch_data_sleep_new WHERE bind_user_id = #{id})")
|
@Select("SELECT AVG(ROUND((CAST(d.wake_up_time AS DATE) - CAST(d.fall_asleep_time AS DATE)) * 24 * 60)) AS aveMinute FROM watch_data_sleep_new_day d LEFT JOIN watch_data_sleep_new n ON d.sleep_id = n.id WHERE n.id IN (SELECT id FROM watch_data_sleep_new WHERE bind_user_id = #{id})")
|
||||||
Double getAverageSleep(@Param("id") String id);
|
Double getAverageSleep(@Param("id") String id);
|
||||||
|
|
||||||
@Select("select MAX(data_value) dataValue,data_date dataDate from watch_data_steps where bind_user_id = #{id} group by data_date order by data_date desc limit 1")
|
@Select("SELECT MAX(data_value) dataValue, data_date dataDate FROM watch_data_steps WHERE bind_user_id = #{id} ORDER BY data_date DESC FETCH FIRST 1 ROWS ONLY")
|
||||||
WatchDataDTO getDataSteps(@Param("id") String id);
|
WatchDataDTO getDataSteps(@Param("id") String id);
|
||||||
|
|
||||||
@Select("SELECT SUM(data_value) FROM watch_data_distance WHERE bind_user_id = #{id}")
|
@Select("SELECT SUM(data_value) FROM watch_data_distance WHERE bind_user_id = #{id}")
|
||||||
Integer getDataDistance(@Param("id") String id);
|
Integer getDataDistance(@Param("id") String id);
|
||||||
|
|
||||||
@Select("SELECT CAST(data_value as INTEGER) dataValue,data_date dataDate from watch_data_heart_rate where bind_user_id = #{id} order by time_stamp desc limit 1")
|
@Select("SELECT CAST(data_value AS INTEGER) dataValue, data_date dataDate FROM watch_data_heart_rate WHERE bind_user_id = #{id} ORDER BY time_stamp DESC FETCH FIRST 1 ROWS ONLY")
|
||||||
WatchDataDTO getHeartRate(@Param("id") String id);
|
WatchDataDTO getHeartRate(@Param("id") String id);
|
||||||
|
|
||||||
@Select("SELECT CAST(data_value as INTEGER) dataValue,data_date dataDate from watch_data_spo2 where bind_user_id = #{id} order by time_stamp desc limit 1")
|
@Select("SELECT CAST(data_value AS INTEGER) dataValue, data_date dataDate FROM watch_data_spo2 WHERE bind_user_id = #{id} ORDER BY time_stamp DESC FETCH FIRST 1 ROWS ONLY")
|
||||||
WatchDataDTO getDataSpo2(@Param("id") String id);
|
WatchDataDTO getDataSpo2(@Param("id") String id);
|
||||||
|
|
||||||
@Select("select cast(data_value as INTEGER) dataValue,data_date dataDate from watch_data_stress where bind_user_id = #{id} order by end_time_stamp desc limit 1")
|
@Select("SELECT CAST(data_value AS INTEGER) dataValue, data_date dataDate FROM watch_data_stress WHERE bind_user_id = #{id} ORDER BY end_time_stamp DESC FETCH FIRST 1 ROWS ONLY")
|
||||||
WatchDataDTO getStress(@Param("id") String id);
|
WatchDataDTO getStress(@Param("id") String id);
|
||||||
|
|
||||||
@Select("select data_value dataValue,data_date dataDate from watch_data_temperature where bind_user_id = #{id} order by time_stamp desc limit 1")
|
@Select("SELECT data_value dataValue, data_date dataDate FROM watch_data_temperature WHERE bind_user_id = #{id} ORDER BY time_stamp DESC FETCH FIRST 1 ROWS ONLY")
|
||||||
WatchDataDTO getTemp(@Param("id") String id);
|
WatchDataDTO getTemp(@Param("id") String id);
|
||||||
|
|
||||||
@Select("SELECT * FROM watch_data_sleep_new_minute WHERE sleep_id IN (SELECT id FROM watch_data_sleep_new WHERE sleep_flag= '1' AND bind_user_id = #{id} AND data_date = #{date})")
|
@Select("SELECT * FROM watch_data_sleep_new_minute WHERE sleep_id IN (SELECT id FROM watch_data_sleep_new WHERE sleep_flag= '1' AND bind_user_id = #{id} AND data_date = #{date})")
|
||||||
@@ -81,7 +81,7 @@ public interface WatchMapper {
|
|||||||
@Select("select max(data_value) maxValue,min(data_value) minValue from watch_data_spo2 where bind_user_id = #{id} and data_date = #{date}")
|
@Select("select max(data_value) maxValue,min(data_value) minValue from watch_data_spo2 where bind_user_id = #{id} and data_date = #{date}")
|
||||||
Map<String, Object> getMapSpo2(@Param("id") String id, @Param("date") Date date);
|
Map<String, Object> getMapSpo2(@Param("id") String id, @Param("date") Date date);
|
||||||
|
|
||||||
@Select("select data_value lastValue from watch_data_spo2 where bind_user_id = #{id} and data_date = #{date} order by time_stamp desc limit 1")
|
@Select("SELECT data_value lastValue FROM watch_data_spo2 WHERE bind_user_id = #{id} AND data_date = #{date} ORDER BY time_stamp DESC FETCH FIRST 1 ROWS ONLY")
|
||||||
Map<String, Object> getMapNewSpo2(@Param("id") String id, @Param("date") Date date);
|
Map<String, Object> getMapNewSpo2(@Param("id") String id, @Param("date") Date date);
|
||||||
|
|
||||||
List<Map<String, Object>> getMapSpo2Format(@Param("id") String id, @Param("date") String date, @Param("format") String format);
|
List<Map<String, Object>> getMapSpo2Format(@Param("id") String id, @Param("date") String date, @Param("format") String format);
|
||||||
@@ -95,6 +95,6 @@ public interface WatchMapper {
|
|||||||
|
|
||||||
Map<String, Object> getAverageDay(@Param("id") String id);
|
Map<String, Object> getAverageDay(@Param("id") String id);
|
||||||
|
|
||||||
@Select("SELECT watch_no FROM watch_bind_his WHERE bind_user_id = #{id} AND bind_date <= #{date} ORDER BY bind_date DESC limit 1")
|
@Select("SELECT watch_no FROM watch_bind_his WHERE bind_user_id = #{id} AND bind_date <= #{date} ORDER BY bind_date DESC FETCH FIRST 1 ROWS ONLY")
|
||||||
String getWatchNo(@Param("id") String id, @Param("date") String date);
|
String getWatchNo(@Param("id") String id, @Param("date") String date);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@ public interface WatchMonitorDataMapper extends BaseMapper<WatchMonitorData>, MP
|
|||||||
|
|
||||||
List<WatchMonitorData> getMonitorErrorNumsNew(@Param("orgCodes")List<String> orgCodes, @Param("start") Date start, @Param("end") Date end);
|
List<WatchMonitorData> getMonitorErrorNumsNew(@Param("orgCodes")List<String> orgCodes, @Param("start") Date start, @Param("end") Date end);
|
||||||
|
|
||||||
@Select("select count(1) from watch_monitor_data where bind_user_id = #{userId} and YEAR(warn_time) = #{year} and event_type = 'fall_down'")
|
@Select("SELECT COUNT(1) FROM watch_monitor_data WHERE bind_user_id = #{userId} AND EXTRACT(YEAR FROM warn_time) = #{year} AND event_type = 'fall_down'")
|
||||||
int selectUserFallNum(String userId,String year);
|
int selectUserFallNum(String userId,String year);
|
||||||
|
|
||||||
List<WatchMonitorData> selectParams(@Param("req") AloneReq req);
|
List<WatchMonitorData> selectParams(@Param("req") AloneReq req);
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ public interface WatchStatUserInfoDayStressMapper extends MPJBaseMapper<WatchSta
|
|||||||
List<WatchDataStressRes> selectStressByYear(@Param("dateYear") Date dateYear, @Param("userId")String userId);
|
List<WatchDataStressRes> selectStressByYear(@Param("dateYear") Date dateYear, @Param("userId")String userId);
|
||||||
|
|
||||||
|
|
||||||
@Select("select * from watch_stat_user_info_day_stress where user_id = #{userId} DATE(data_date) = DATE(#{dataDate}) limit 1")
|
@Select("SELECT * FROM watch_stat_user_info_day_stress WHERE user_id = #{userId} AND data_date = #{dataDate} AND ROWNUM = 1")
|
||||||
WatchDataStressRes selectStressByUserIdAndDate(@Param("dateTime") Date dateTime, @Param("userId")String userId);
|
WatchDataStressRes selectStressByUserIdAndDate(@Param("dateTime") Date dateTime, @Param("userId")String userId);
|
||||||
|
|
||||||
void insertStat(WatchStatUserInfoDayStress watchStatUserInfoDayStress);
|
void insertStat(WatchStatUserInfoDayStress watchStatUserInfoDayStress);
|
||||||
|
|||||||
+5
-3
@@ -3,6 +3,7 @@
|
|||||||
<mapper namespace="com.renkang.watch.mapper.ArchivesBodyTypeMapper">
|
<mapper namespace="com.renkang.watch.mapper.ArchivesBodyTypeMapper">
|
||||||
|
|
||||||
<select id="selectHeartRateData" resultType="com.renkang.watch.entity.ArchivesBodyType">
|
<select id="selectHeartRateData" resultType="com.renkang.watch.entity.ArchivesBodyType">
|
||||||
|
SELECT * FROM (
|
||||||
SELECT
|
SELECT
|
||||||
temp.*
|
temp.*
|
||||||
FROM
|
FROM
|
||||||
@@ -17,7 +18,8 @@
|
|||||||
watch_data
|
watch_data
|
||||||
WHERE
|
WHERE
|
||||||
userid = #{userId}
|
userid = #{userId}
|
||||||
AND type = 1 UNION ALL
|
AND type = 1
|
||||||
|
UNION ALL
|
||||||
SELECT
|
SELECT
|
||||||
user_id AS userId,
|
user_id AS userId,
|
||||||
data_value AS dataValue,
|
data_value AS dataValue,
|
||||||
@@ -32,7 +34,7 @@
|
|||||||
) temp
|
) temp
|
||||||
ORDER BY
|
ORDER BY
|
||||||
temp.createDate DESC
|
temp.createDate DESC
|
||||||
LIMIT 1;
|
) WHERE ROWNUM = 1
|
||||||
</select>
|
</select>
|
||||||
<select id="selectTemperatureData" resultType="com.renkang.watch.entity.ArchivesBodyType">
|
<select id="selectTemperatureData" resultType="com.renkang.watch.entity.ArchivesBodyType">
|
||||||
SELECT
|
SELECT
|
||||||
@@ -62,9 +64,9 @@
|
|||||||
user_id = #{userId}
|
user_id = #{userId}
|
||||||
AND type = 5
|
AND type = 5
|
||||||
) temp
|
) temp
|
||||||
|
WHERE ROWNUM = 1
|
||||||
ORDER BY
|
ORDER BY
|
||||||
temp.createDate DESC
|
temp.createDate DESC
|
||||||
LIMIT 1;
|
|
||||||
</select>
|
</select>
|
||||||
<select id="analysisHeartRateListData" resultType="com.renkang.watch.entity.ArchivesBodyType">
|
<select id="analysisHeartRateListData" resultType="com.renkang.watch.entity.ArchivesBodyType">
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
+2
-2
@@ -5,9 +5,9 @@
|
|||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
`watch_data_heart_rate`
|
"watch_data_heart_rate"
|
||||||
WHERE
|
WHERE
|
||||||
YEAR ( data_date )= #{req.dateYear}
|
EXTRACT(YEAR FROM data_date) = #{req.dateYear}
|
||||||
AND
|
AND
|
||||||
bind_user_id=#{req.userId}
|
bind_user_id=#{req.userId}
|
||||||
order by data_date desc,time_stamp desc
|
order by data_date desc,time_stamp desc
|
||||||
|
|||||||
+163
-99
@@ -88,18 +88,18 @@
|
|||||||
|
|
||||||
<select id="selectSevenActiveList" resultType="com.renkang.watch.entity.WatchData">
|
<select id="selectSevenActiveList" resultType="com.renkang.watch.entity.WatchData">
|
||||||
select
|
select
|
||||||
orgcode, IFNULL(COUNT(DISTINCT userid),0) AS "type"
|
orgcode, NVL(COUNT(DISTINCT userid),0) AS "type"
|
||||||
from watch_data
|
from watch_data
|
||||||
WHERE last_update_time >= CURDATE() - INTERVAL 6 DAY
|
WHERE last_update_time >= SYSDATE - 6
|
||||||
GROUP BY orgcode
|
GROUP BY orgcode
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectThirtyActiveList" resultType="com.renkang.watch.entity.WatchData">
|
<select id="selectThirtyActiveList" resultType="com.renkang.watch.entity.WatchData">
|
||||||
select
|
select
|
||||||
orgcode, IFNULL(COUNT(DISTINCT userid),0) AS "type"
|
orgcode, NVL(COUNT(DISTINCT userid),0) AS "type"
|
||||||
from watch_data
|
from watch_data
|
||||||
WHERE last_update_time >= CURDATE() - INTERVAL 29 DAY
|
WHERE last_update_time >= SYSDATE - 29
|
||||||
GROUP BY orgcode
|
GROUP BY orgcode
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -127,89 +127,113 @@
|
|||||||
SELECT count(1)
|
SELECT count(1)
|
||||||
FROM watch_data
|
FROM watch_data
|
||||||
WHERE watch_no = #{watchNo}
|
WHERE watch_no = #{watchNo}
|
||||||
AND last_update_time >= CURDATE() - INTERVAL 7 DAY
|
AND last_update_time >= SYSDATE - 7
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertHeartRate">
|
<insert id="insertHeartRate">
|
||||||
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
||||||
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 1, data_value, data_date
|
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 1, data_value, data_date
|
||||||
from watch_data_heart_rate force index (bind_user_id)
|
from (select bind_user_id, watch_no, data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY time_stamp desc) as rn
|
||||||
|
from watch_data_heart_rate
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR})
|
||||||
order by time_stamp desc
|
where rn = 1);
|
||||||
limit 1);
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateHeartRate">
|
<update id="updateHeartRate">
|
||||||
update watch_data wd left join (select bind_user_id, data_value, data_date
|
update watch_data wd
|
||||||
from watch_data_heart_rate force index (bind_user_id)
|
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
||||||
|
wd.data_value = (select data_value from (
|
||||||
|
select bind_user_id, data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY time_stamp desc) as rn
|
||||||
|
from watch_data_heart_rate
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
order by time_stamp desc
|
) where rn = 1),
|
||||||
limit 1) d on d.bind_user_id = wd.userid
|
wd.last_update_time = (select data_date from (
|
||||||
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
select bind_user_id, data_date,
|
||||||
wd.data_value = d.data_value,
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY time_stamp desc) as rn
|
||||||
wd.last_update_time = d.data_date
|
from watch_data_heart_rate
|
||||||
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
|
) where rn = 1)
|
||||||
where wd.userid = #{userid,jdbcType=VARCHAR}
|
where wd.userid = #{userid,jdbcType=VARCHAR}
|
||||||
and wd.watch_no = #{watchNo,jdbcType=VARCHAR}
|
and wd.watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
and wd.`type` = 1;
|
and wd."type" = 1;
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<insert id="insertSpo2">
|
<insert id="insertSpo2">
|
||||||
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
||||||
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 2, data_value, data_date
|
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 2, data_value, data_date
|
||||||
from watch_data_spo2 force index (bind_user_id_index)
|
from (select bind_user_id, watch_no, data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY time_stamp desc) as rn
|
||||||
|
from watch_data_spo2
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR})
|
||||||
order by time_stamp desc
|
where rn = 1);
|
||||||
limit 1);
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateSpo2">
|
<update id="updateSpo2">
|
||||||
update watch_data wd left join (select bind_user_id, data_value, data_date
|
update watch_data wd
|
||||||
from watch_data_spo2 force index (bind_user_id_index)
|
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
||||||
|
wd.data_value = (select data_value from (
|
||||||
|
select bind_user_id, data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY time_stamp desc) as rn
|
||||||
|
from watch_data_spo2
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
order by time_stamp desc
|
) where rn = 1),
|
||||||
limit 1) d on d.bind_user_id = wd.userid
|
wd.last_update_time = (select data_date from (
|
||||||
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
select bind_user_id, data_date,
|
||||||
wd.data_value = d.data_value,
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY time_stamp desc) as rn
|
||||||
wd.last_update_time = d.data_date
|
from watch_data_spo2
|
||||||
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
|
) where rn = 1)
|
||||||
where userid = #{userid,jdbcType=VARCHAR}
|
where userid = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
and `type` = 2;
|
and "type" = 2;
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<insert id="insertStress">
|
<insert id="insertStress">
|
||||||
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
||||||
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 3, data_value, data_date
|
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 3, data_value, data_date
|
||||||
from watch_data_stress force index (bind_user_id)
|
from (select bind_user_id, watch_no, data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY start_time_stamp desc) as rn
|
||||||
|
from watch_data_stress
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR})
|
||||||
order by start_time_stamp desc
|
where rn = 1);
|
||||||
limit 1);
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateStress">
|
<update id="updateStress">
|
||||||
update watch_data wd left join (select bind_user_id, data_value, data_date
|
update watch_data wd
|
||||||
from watch_data_stress force index (bind_user_id)
|
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
||||||
|
wd.data_value = (select data_value from (
|
||||||
|
select bind_user_id, data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY start_time_stamp desc) as rn
|
||||||
|
from watch_data_stress
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
order by start_time_stamp desc
|
) where rn = 1),
|
||||||
limit 1) d on d.bind_user_id = wd.userid
|
wd.last_update_time = (select data_date from (
|
||||||
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
select bind_user_id, data_date,
|
||||||
wd.data_value = d.data_value,
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY start_time_stamp desc) as rn
|
||||||
wd.last_update_time = d.data_date
|
from watch_data_stress
|
||||||
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
|
) where rn = 1)
|
||||||
where userid = #{userid,jdbcType=VARCHAR}
|
where userid = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
and `type` = 3;
|
and "type" = 3;
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<insert id="insertSleep">
|
<insert id="insertSleep">
|
||||||
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
||||||
(select #{id,jdbcType=VARCHAR}, bind_user_id,
|
(select #{id,jdbcType=VARCHAR}, bind_user_id,
|
||||||
#{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, #{watchNo,jdbcType=VARCHAR}, 4,
|
#{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, #{watchNo,jdbcType=VARCHAR}, 4,
|
||||||
sum(time_to_sec(timediff(sm.end_time, sm.start_time))) / 60 as deep_light_times, data_date
|
NVL(SUM(EXTRACT(HOUR FROM (sm.end_time - sm.start_time)) * 60 + EXTRACT(MINUTE FROM (sm.end_time - sm.start_time))), 0) as deep_light_times, data_date
|
||||||
from watch_data_sleep_new s
|
from watch_data_sleep_new s
|
||||||
left join watch_data_sleep_new_minute sm on s.id = sm.sleep_id
|
left join watch_data_sleep_new_minute sm on s.id = sm.sleep_id
|
||||||
where s.bind_user_id = #{userid,jdbcType=VARCHAR}
|
where s.bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
@@ -217,13 +241,13 @@
|
|||||||
and s.sleep_flag = '1'
|
and s.sleep_flag = '1'
|
||||||
group by s.bind_user_id, s.watch_no, s.data_date
|
group by s.bind_user_id, s.watch_no, s.data_date
|
||||||
order by data_date desc
|
order by data_date desc
|
||||||
limit 1);
|
FETCH FIRST 1 ROWS ONLY);
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateSleep">
|
<update id="updateSleep">
|
||||||
update watch_data wd left join (select s.bind_user_id,
|
update watch_data wd
|
||||||
sum(time_to_sec(timediff(sm.end_time, sm.start_time))) / 60 as deep_light_times,
|
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
||||||
data_date
|
wd.data_value = (select NVL(SUM(EXTRACT(HOUR FROM (sm.end_time - sm.start_time)) * 60 + EXTRACT(MINUTE FROM (sm.end_time - sm.start_time))), 0)
|
||||||
from watch_data_sleep_new s
|
from watch_data_sleep_new s
|
||||||
left join watch_data_sleep_new_minute sm on s.id = sm.sleep_id
|
left join watch_data_sleep_new_minute sm on s.id = sm.sleep_id
|
||||||
where s.bind_user_id = #{userid,jdbcType=VARCHAR}
|
where s.bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
@@ -231,118 +255,158 @@
|
|||||||
and s.sleep_flag = '1'
|
and s.sleep_flag = '1'
|
||||||
group by s.bind_user_id, s.watch_no, s.data_date
|
group by s.bind_user_id, s.watch_no, s.data_date
|
||||||
order by data_date desc
|
order by data_date desc
|
||||||
limit 1) d on d.bind_user_id = wd.userid
|
FETCH FIRST 1 ROWS ONLY),
|
||||||
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
wd.last_update_time = (select data_date from (
|
||||||
wd.data_value = d.deep_light_times,
|
select data_date
|
||||||
wd.last_update_time = d.data_date
|
from watch_data_sleep_new
|
||||||
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
|
and sleep_flag = '1'
|
||||||
|
order by data_date desc
|
||||||
|
) where ROWNUM = 1)
|
||||||
where userid = #{userid,jdbcType=VARCHAR}
|
where userid = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
and `type` = 4;
|
and "type" = 4;
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<insert id="insertTemperature">
|
<insert id="insertTemperature">
|
||||||
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
||||||
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 5, data_value, data_date
|
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 5, data_value, data_date
|
||||||
from watch_data_temperature force index (bind_user_id)
|
from (select bind_user_id, watch_no, data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY time_stamp desc) as rn
|
||||||
|
from watch_data_temperature
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR})
|
||||||
order by time_stamp desc
|
where rn = 1);
|
||||||
limit 1);
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateTemperature">
|
<update id="updateTemperature">
|
||||||
update watch_data wd left join (select bind_user_id, data_value, data_date
|
update watch_data wd
|
||||||
from watch_data_temperature force index (bind_user_id)
|
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
||||||
|
wd.data_value = (select data_value from (
|
||||||
|
select bind_user_id, data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY time_stamp desc) as rn
|
||||||
|
from watch_data_temperature
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
order by time_stamp desc
|
) where rn = 1),
|
||||||
limit 1) d on d.bind_user_id = wd.userid
|
wd.last_update_time = (select data_date from (
|
||||||
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
select bind_user_id, data_date,
|
||||||
wd.data_value = d.data_value,
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY time_stamp desc) as rn
|
||||||
wd.last_update_time = d.data_date
|
from watch_data_temperature
|
||||||
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
|
) where rn = 1)
|
||||||
where userid = #{userid,jdbcType=VARCHAR}
|
where userid = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
and `type` = 5;
|
and "type" = 5;
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<insert id="insertWorkout">
|
<insert id="insertWorkout">
|
||||||
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
||||||
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 6, sum(calorie), data_date
|
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 6, sum(calorie), data_date
|
||||||
from watch_data_workout force index (bind_user_id)
|
from (select bind_user_id, watch_no, sum(calorie) as calorie, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY data_date desc) as rn
|
||||||
|
from watch_data_workout
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
group by bind_user_id, watch_no, data_date
|
group by bind_user_id, watch_no, data_date)
|
||||||
order by data_date desc
|
where rn = 1);
|
||||||
limit 1);
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateWorkout">
|
<update id="updateWorkout">
|
||||||
update watch_data wd left join (select bind_user_id, sum(calorie) as data_value, data_date
|
update watch_data wd
|
||||||
from watch_data_workout force index (bind_user_id)
|
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
||||||
|
wd.data_value = (select sum(calorie) from (
|
||||||
|
select bind_user_id, watch_no, sum(calorie) as calorie, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY data_date desc) as rn
|
||||||
|
from watch_data_workout
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
group by bind_user_id, watch_no, data_date
|
group by bind_user_id, watch_no, data_date
|
||||||
order by data_date desc
|
) where rn = 1),
|
||||||
limit 1) d on d.bind_user_id = wd.userid
|
wd.last_update_time = (select data_date from (
|
||||||
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
select bind_user_id, data_date,
|
||||||
wd.data_value = d.data_value,
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY data_date desc) as rn
|
||||||
wd.last_update_time = d.data_date
|
from watch_data_workout
|
||||||
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
|
group by bind_user_id, watch_no, data_date
|
||||||
|
) where rn = 1)
|
||||||
where userid = #{userid,jdbcType=VARCHAR}
|
where userid = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
and `type` = 6;
|
and "type" = 6;
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<insert id="insertDistance">
|
<insert id="insertDistance">
|
||||||
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
||||||
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 7, max(data_value), data_date
|
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 7, max(data_value), data_date
|
||||||
from watch_data_distance force index (bind_user_id)
|
from (select bind_user_id, watch_no, max(data_value) as data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY data_date desc) as rn
|
||||||
|
from watch_data_distance
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
group by bind_user_id, watch_no, data_date
|
group by bind_user_id, watch_no, data_date)
|
||||||
order by data_date desc
|
where rn = 1);
|
||||||
limit 1);
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateDistance">
|
<update id="updateDistance">
|
||||||
update watch_data wd left join (select bind_user_id,max(data_value) as data_value, data_date
|
update watch_data wd
|
||||||
from watch_data_distance force index (bind_user_id)
|
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
||||||
|
wd.data_value = (select max(data_value) from (
|
||||||
|
select bind_user_id, watch_no, max(data_value) as data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY data_date desc) as rn
|
||||||
|
from watch_data_distance
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
group by bind_user_id, watch_no, data_date
|
group by bind_user_id, watch_no, data_date
|
||||||
order by data_date desc
|
) where rn = 1),
|
||||||
limit 1) d on d.bind_user_id = wd.userid
|
wd.last_update_time = (select data_date from (
|
||||||
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
select bind_user_id, data_date,
|
||||||
wd.data_value = d.data_value,
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY data_date desc) as rn
|
||||||
wd.last_update_time = d.data_date
|
from watch_data_distance
|
||||||
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
|
group by bind_user_id, watch_no, data_date
|
||||||
|
) where rn = 1)
|
||||||
where userid = #{userid,jdbcType=VARCHAR}
|
where userid = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
and `type` = 7;
|
and "type" = 7;
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
<insert id="insertSteps">
|
<insert id="insertSteps">
|
||||||
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
insert into watch_data(id, userid, username, orgcode, watch_no, type, data_value, last_update_time)
|
||||||
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 8, max(data_value), data_date
|
(select #{id,jdbcType=VARCHAR}, bind_user_id, #{username,jdbcType=VARCHAR}, #{orgcode,jdbcType=VARCHAR}, watch_no, 8, max(data_value), data_date
|
||||||
from watch_data_steps force index (bind_user_id)
|
from (select bind_user_id, watch_no, max(data_value) as data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY data_date desc) as rn
|
||||||
|
from watch_data_steps
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
group by bind_user_id, watch_no, data_date
|
group by bind_user_id, watch_no, data_date)
|
||||||
order by data_date desc
|
where rn = 1);
|
||||||
limit 1);
|
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updateSteps">
|
<update id="updateSteps">
|
||||||
update watch_data wd left join (select bind_user_id,max(data_value) as data_value, data_date
|
update watch_data wd
|
||||||
from watch_data_steps force index (bind_user_id)
|
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
||||||
|
wd.data_value = (select max(data_value) from (
|
||||||
|
select bind_user_id, watch_no, max(data_value) as data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY data_date desc) as rn
|
||||||
|
from watch_data_steps
|
||||||
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
group by bind_user_id, watch_no, data_date
|
group by bind_user_id, watch_no, data_date
|
||||||
order by data_date desc
|
) where rn = 1),
|
||||||
limit 1) d on d.bind_user_id = wd.userid
|
wd.last_update_time = (select data_date from (
|
||||||
set wd.orgcode = #{orgcode,jdbcType=VARCHAR},
|
select bind_user_id, data_date,
|
||||||
wd.data_value = d.data_value,
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id, watch_no ORDER BY data_date desc) as rn
|
||||||
wd.last_update_time = d.data_date
|
from watch_data_steps
|
||||||
|
where bind_user_id = #{userid,jdbcType=VARCHAR}
|
||||||
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
|
group by bind_user_id, watch_no, data_date
|
||||||
|
) where rn = 1)
|
||||||
where userid = #{userid,jdbcType=VARCHAR}
|
where userid = #{userid,jdbcType=VARCHAR}
|
||||||
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
and watch_no = #{watchNo,jdbcType=VARCHAR}
|
||||||
and `type` = 8;
|
and "type" = 8;
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@
|
|||||||
wdsnm.start_time as startTime,
|
wdsnm.start_time as startTime,
|
||||||
wdsnm.end_time as endTime,
|
wdsnm.end_time as endTime,
|
||||||
wdsnm.sleep_type as sleepType,
|
wdsnm.sleep_type as sleepType,
|
||||||
TIMESTAMPDIFF(MINUTE,wdsnm.start_time,wdsnm.end_time) as times
|
EXTRACT(MINUTE FROM (wdsnm.end_time - wdsnm.start_time)) as times
|
||||||
from
|
from
|
||||||
watch_data_sleep_new wdsn
|
watch_data_sleep_new wdsn
|
||||||
inner join watch_data_sleep_new_minute wdsnm on wdsnm.sleep_id=wdsn.id
|
inner join watch_data_sleep_new_minute wdsnm on wdsnm.sleep_id=wdsn.id
|
||||||
|
|||||||
+2
-2
@@ -5,9 +5,9 @@
|
|||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
`watch_data_spo2`
|
"watch_data_spo2"
|
||||||
WHERE
|
WHERE
|
||||||
YEAR ( data_date )= #{req.dateYear}
|
EXTRACT(YEAR FROM data_date) = #{req.dateYear}
|
||||||
AND
|
AND
|
||||||
bind_user_id=#{req.userId}
|
bind_user_id=#{req.userId}
|
||||||
order by data_date desc,time_stamp desc
|
order by data_date desc,time_stamp desc
|
||||||
|
|||||||
+2
-2
@@ -5,9 +5,9 @@
|
|||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
`watch_data_stress`
|
"watch_data_stress"
|
||||||
WHERE
|
WHERE
|
||||||
YEAR ( data_date )= #{req.dateYear}
|
EXTRACT(YEAR FROM data_date) = #{req.dateYear}
|
||||||
AND
|
AND
|
||||||
bind_user_id=#{req.userId}
|
bind_user_id=#{req.userId}
|
||||||
order by data_date desc,start_time_stamp asc ,end_time_stamp asc
|
order by data_date desc,start_time_stamp asc ,end_time_stamp asc
|
||||||
|
|||||||
+2
-2
@@ -5,9 +5,9 @@
|
|||||||
SELECT
|
SELECT
|
||||||
*
|
*
|
||||||
FROM
|
FROM
|
||||||
`watch_data_temperature`
|
"watch_data_temperature"
|
||||||
WHERE
|
WHERE
|
||||||
YEAR ( data_date )= #{req.dateYear}
|
EXTRACT(YEAR FROM data_date) = #{req.dateYear}
|
||||||
AND
|
AND
|
||||||
bind_user_id=#{req.userId}
|
bind_user_id=#{req.userId}
|
||||||
order by data_date desc,
|
order by data_date desc,
|
||||||
|
|||||||
+22
-16
@@ -5,7 +5,7 @@
|
|||||||
<select id="selectSportCostList" resultType="com.renkang.watch.entity.WatchDataWorkout">
|
<select id="selectSportCostList" resultType="com.renkang.watch.entity.WatchDataWorkout">
|
||||||
SELECT
|
SELECT
|
||||||
DATE(start_time_stamp) as "dataDate",
|
DATE(start_time_stamp) as "dataDate",
|
||||||
IFNULL(SUM(calorie),0) AS calorie,
|
NVL(SUM(calorie),0) AS calorie,
|
||||||
SUM(
|
SUM(
|
||||||
CASE
|
CASE
|
||||||
WHEN workout_type IN (1, 3, 11, 12, 13, 17, 18, 102, 103, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 122, 127, 129, 137, 138, 142, 143, 151, 153, 154, 155, 156, 157, 163, 164, 166, 167, 169, 177, 179, 180, 181, 182, 183) THEN calorie * 0.30
|
WHEN workout_type IN (1, 3, 11, 12, 13, 17, 18, 102, 103, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 122, 127, 129, 137, 138, 142, 143, 151, 153, 154, 155, 156, 157, 163, 164, 166, 167, 169, 177, 179, 180, 181, 182, 183) THEN calorie * 0.30
|
||||||
@@ -19,25 +19,25 @@
|
|||||||
WHEN workout_type IN (2, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16, 19, 20, 21, 101, 104, 105, 106, 111, 121, 123, 124, 125, 126, 128, 130, 131, 132, 133, 134, 135, 136, 139, 140, 141, 144, 145, 146, 147, 148, 149, 150, 158, 159, 160, 161, 162, 165, 168, 170, 171, 172, 173, 174, 175, 176, 178, 184, 185) THEN calorie-FLOOR(calorie * 0.50)
|
WHEN workout_type IN (2, 4, 5, 6, 7, 8, 9, 10, 14, 15, 16, 19, 20, 21, 101, 104, 105, 106, 111, 121, 123, 124, 125, 126, 128, 130, 131, 132, 133, 134, 135, 136, 139, 140, 141, 144, 145, 146, 147, 148, 149, 150, 158, 159, 160, 161, 162, 165, 168, 170, 171, 172, 173, 174, 175, 176, 178, 184, 185) THEN calorie-FLOOR(calorie * 0.50)
|
||||||
ELSE 0
|
ELSE 0
|
||||||
END
|
END
|
||||||
) AS sugarCalories
|
) AS sugarCalories,
|
||||||
|
SUM(NVL(EXTRACT(SECOND FROM (end_time_stamp - start_time_stamp)) +
|
||||||
|
EXTRACT(MINUTE FROM (end_time_stamp - start_time_stamp)) * 60 +
|
||||||
|
EXTRACT(HOUR FROM (end_time_stamp - start_time_stamp)) * 3600, 0)) as "totalTime"
|
||||||
FROM
|
FROM
|
||||||
watch_data_workout
|
watch_data_workout
|
||||||
WHERE
|
WHERE
|
||||||
FIND_IN_SET(workout_type,'1,2,3,109,144,6,7,101,113,145')
|
INSTR(',' || '1,2,3,109,144,6,7,101,113,145' || ',', ',' || workout_type || ',') > 0
|
||||||
and bind_user_id = #{watchDataWorkout.bindUserId}
|
|
||||||
<if test="watchDataWorkout.endTime != null and watchDataWorkout.startTime != null">
|
<if test="watchDataWorkout.endTime != null and watchDataWorkout.startTime != null">
|
||||||
and DATE(start_time_stamp) >= DATE(#{watchDataWorkout.startTime})
|
and DATE(start_time_stamp) >= DATE(#{watchDataWorkout.startTime})
|
||||||
and DATE(start_time_stamp) <= DATE(#{watchDataWorkout.endTime})
|
and DATE(start_time_stamp) <= DATE(#{watchDataWorkout.endTime})
|
||||||
</if>
|
</if>
|
||||||
GROUP BY
|
and bind_user_id = #{watchDataWorkout.bindUserId}
|
||||||
dataDate
|
|
||||||
order by dataDate
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectSportCostTotal" resultType="com.renkang.watch.entity.WatchDataWorkout">
|
<select id="selectSportCostTotal" resultType="com.renkang.watch.entity.WatchDataWorkout">
|
||||||
SELECT
|
SELECT
|
||||||
IFNULL(SUM(calorie),0) AS calorie,
|
NVL(SUM(calorie),0) AS calorie,
|
||||||
SUM(
|
SUM(
|
||||||
CASE
|
CASE
|
||||||
WHEN workout_type IN (1, 3, 11, 12, 13, 17, 18, 102, 103, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 122, 127, 129, 137, 138, 142, 143, 151, 153, 154, 155, 156, 157, 163, 164, 166, 167, 169, 177, 179, 180, 181, 182, 183) THEN calorie * 0.30
|
WHEN workout_type IN (1, 3, 11, 12, 13, 17, 18, 102, 103, 107, 108, 109, 110, 112, 113, 114, 115, 116, 117, 118, 119, 120, 122, 127, 129, 137, 138, 142, 143, 151, 153, 154, 155, 156, 157, 163, 164, 166, 167, 169, 177, 179, 180, 181, 182, 183) THEN calorie * 0.30
|
||||||
@@ -88,27 +88,31 @@
|
|||||||
ELSE 0
|
ELSE 0
|
||||||
END
|
END
|
||||||
AS sugarCalories,
|
AS sugarCalories,
|
||||||
IFNULL(TIMESTAMPDIFF(SECOND, start_time_stamp, end_time_stamp),0) as "totalTime"
|
NVL(EXTRACT(SECOND FROM (end_time_stamp - start_time_stamp)) +
|
||||||
|
EXTRACT(MINUTE FROM (end_time_stamp - start_time_stamp)) * 60 +
|
||||||
|
EXTRACT(HOUR FROM (end_time_stamp - start_time_stamp)) * 3600, 0) as "totalTime"
|
||||||
from
|
from
|
||||||
watch_data_workout
|
watch_data_workout
|
||||||
WHERE
|
WHERE
|
||||||
bind_user_id = #{watchDataWorkout.bindUserId}
|
bind_user_id = #{watchDataWorkout.bindUserId}
|
||||||
and DATE(start_time_stamp) = DATE(#{watchDataWorkout.dataDate})
|
and DATE(start_time_stamp) = DATE(#{watchDataWorkout.dataDate})
|
||||||
and FIND_IN_SET(workout_type,'1,2,3,109,144,6,7,101,113,145')
|
and INSTR(',' || '1,2,3,109,144,6,7,101,113,145' || ',', ',' || workout_type || ',') > 0
|
||||||
order by start_time_stamp desc
|
order by start_time_stamp desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<select id="selectselectSportTimingTotal" resultType="com.renkang.watch.entity.WatchDataWorkout">
|
<select id="selectselectSportTimingTotal" resultType="com.renkang.watch.entity.WatchDataWorkout">
|
||||||
select
|
select
|
||||||
IFNULL(SUM(calorie),0) as "calorie",
|
NVL(SUM(calorie),0) as "calorie",
|
||||||
IFNULL(SUM(TIMESTAMPDIFF(SECOND, start_time_stamp, end_time_stamp)),0) as "totalTime"
|
NVL(SUM(EXTRACT(SECOND FROM (end_time_stamp - start_time_stamp)) +
|
||||||
|
EXTRACT(MINUTE FROM (end_time_stamp - start_time_stamp)) * 60 +
|
||||||
|
EXTRACT(HOUR FROM (end_time_stamp - start_time_stamp)) * 3600),0) as "totalTime"
|
||||||
from
|
from
|
||||||
watch_data_workout
|
watch_data_workout
|
||||||
WHERE
|
WHERE
|
||||||
bind_user_id = #{watchDataWorkout.bindUserId}
|
bind_user_id = #{watchDataWorkout.bindUserId}
|
||||||
and DATE(start_time_stamp) = DATE(#{watchDataWorkout.dataDate})
|
and DATE(start_time_stamp) = DATE(#{watchDataWorkout.dataDate})
|
||||||
and FIND_IN_SET(workout_type,'1,2,3,109,144,6,7,101,113,145')
|
and INSTR(',' || '1,2,3,109,144,6,7,101,113,145' || ',', ',' || workout_type || ',') > 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
@@ -193,7 +197,7 @@
|
|||||||
bind_user_id = #{watchDataWorkout.bindUserId}
|
bind_user_id = #{watchDataWorkout.bindUserId}
|
||||||
and DATE(start_time_stamp) >= DATE(#{watchDataWorkout.startTime})
|
and DATE(start_time_stamp) >= DATE(#{watchDataWorkout.startTime})
|
||||||
and DATE(start_time_stamp) <= DATE(#{watchDataWorkout.endTime})
|
and DATE(start_time_stamp) <= DATE(#{watchDataWorkout.endTime})
|
||||||
and FIND_IN_SET(workout_type,'1,2,3,109,144,6,7,101,113,145')
|
and INSTR(',' || '1,2,3,109,144,6,7,101,113,145' || ',', ',' || workout_type || ',') > 0
|
||||||
order by start_time_stamp
|
order by start_time_stamp
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -240,8 +244,10 @@
|
|||||||
|
|
||||||
<select id="selectselectSportTimingTotalNew" resultType="com.renkang.watch.entity.WatchDataWorkout">
|
<select id="selectselectSportTimingTotalNew" resultType="com.renkang.watch.entity.WatchDataWorkout">
|
||||||
select
|
select
|
||||||
IFNULL(SUM(calorie),0) as "calorie",
|
NVL(SUM(calorie),0) as "calorie",
|
||||||
IFNULL(SUM(TIMESTAMPDIFF(SECOND, start_time_stamp, end_time_stamp)),0) as "totalTime",
|
NVL(SUM(EXTRACT(SECOND FROM (end_time_stamp - start_time_stamp)) +
|
||||||
|
EXTRACT(MINUTE FROM (end_time_stamp - start_time_stamp)) * 60 +
|
||||||
|
EXTRACT(HOUR FROM (end_time_stamp - start_time_stamp)) * 3600),0) as "totalTime",
|
||||||
MIN(start_time_stamp) AS "dataDate"
|
MIN(start_time_stamp) AS "dataDate"
|
||||||
from
|
from
|
||||||
watch_data_workout
|
watch_data_workout
|
||||||
|
|||||||
+12
-6
@@ -16,9 +16,9 @@
|
|||||||
END AS watch_status,
|
END AS watch_status,
|
||||||
wd.bind_date,
|
wd.bind_date,
|
||||||
wd.bind_user_id,
|
wd.bind_user_id,
|
||||||
GROUP_CONCAT(wds.wd_type) AS wd_types,
|
LISTAGG(wds.wd_type, ',') WITHIN GROUP (ORDER BY wds.wd_type) AS wd_types,
|
||||||
GROUP_CONCAT(wds.switch_flag) AS switch_flags,
|
LISTAGG(wds.switch_flag, ',') WITHIN GROUP (ORDER BY wds.switch_flag) AS switch_flags,
|
||||||
GROUP_CONCAT(IFNULL(wds.update_date, '') SEPARATOR ',') AS update_dates
|
LISTAGG(NVL(TO_CHAR(wds.update_date, 'YYYY-MM-DD HH24:MI:SS'), '') || ',') WITHIN GROUP (ORDER BY wds.update_date) AS update_dates
|
||||||
FROM
|
FROM
|
||||||
watch_device wd
|
watch_device wd
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
@@ -45,7 +45,13 @@
|
|||||||
${permissionSql}
|
${permissionSql}
|
||||||
</where>
|
</where>
|
||||||
GROUP BY
|
GROUP BY
|
||||||
wd.id,wd.watch_no, wd.dept_id, wd.create_date, watch_status, wd.bind_date, wd.bind_user_id
|
wd.id, wd.watch_no, wd.dept_id, wd.create_date,
|
||||||
|
CASE
|
||||||
|
WHEN wd.bind_user_id IS NULL THEN 0
|
||||||
|
WHEN wd.bind_user_id = '' THEN 0
|
||||||
|
ELSE 1
|
||||||
|
END,
|
||||||
|
wd.bind_date, wd.bind_user_id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
wd.create_date DESC;
|
wd.create_date DESC;
|
||||||
</select>
|
</select>
|
||||||
@@ -147,7 +153,7 @@
|
|||||||
count(1)
|
count(1)
|
||||||
from watch_device
|
from watch_device
|
||||||
where org_code = #{orgCode}
|
where org_code = #{orgCode}
|
||||||
and Date(create_date) <![CDATA[ <= ]]> #{endDate}
|
and TRUNC(create_date) <![CDATA[ <= ]]> #{endDate}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
@@ -425,7 +431,7 @@
|
|||||||
COALESCE(steps.step_value, 0) AS stepValue,
|
COALESCE(steps.step_value, 0) AS stepValue,
|
||||||
COALESCE(steps.last_upload_time, NULL) AS stepTime,
|
COALESCE(steps.last_upload_time, NULL) AS stepTime,
|
||||||
COALESCE(workout.start_time_stamp, NULL) AS durationTime,
|
COALESCE(workout.start_time_stamp, NULL) AS durationTime,
|
||||||
COALESCE(TIMESTAMPDIFF(MINUTE, workout.start_time_stamp, workout.end_time_stamp),0) AS durationTotalValue,
|
COALESCE(EXTRACT(MINUTE FROM (workout.end_time_stamp - workout.start_time_stamp)),0) AS durationTotalValue,
|
||||||
workout.workout_type AS workoutType,
|
workout.workout_type AS workoutType,
|
||||||
|
|
||||||
COALESCE(hr.errorNum, 0) AS rateAbnormalValue,
|
COALESCE(hr.errorNum, 0) AS rateAbnormalValue,
|
||||||
|
|||||||
+1
-1
@@ -109,7 +109,7 @@
|
|||||||
AND TO_CHAR(data_date, 'YYYY-MM') = #{date}
|
AND TO_CHAR(data_date, 'YYYY-MM') = #{date}
|
||||||
ORDER BY
|
ORDER BY
|
||||||
data_date DESC
|
data_date DESC
|
||||||
LIMIT #{pageSize} OFFSET #{startNo}
|
OFFSET #{startNo} ROWS FETCH NEXT #{pageSize} ROWS ONLY
|
||||||
</select>
|
</select>
|
||||||
<select id="getAverageDay" resultType="java.util.Map">
|
<select id="getAverageDay" resultType="java.util.Map">
|
||||||
SELECT
|
SELECT
|
||||||
|
|||||||
+3
-3
@@ -7,7 +7,7 @@
|
|||||||
bind_user_id,
|
bind_user_id,
|
||||||
count( DISTINCT bind_user_id )
|
count( DISTINCT bind_user_id )
|
||||||
FROM
|
FROM
|
||||||
`watch_monitor_data`
|
"watch_monitor_data"
|
||||||
<where>
|
<where>
|
||||||
<if test="startTime!=null">
|
<if test="startTime!=null">
|
||||||
and warn_time >= #{startTime}
|
and warn_time >= #{startTime}
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
SELECT
|
SELECT
|
||||||
count(*)
|
count(*)
|
||||||
FROM
|
FROM
|
||||||
`watch_monitor_data`
|
"watch_monitor_data"
|
||||||
<where>
|
<where>
|
||||||
and org_code like concat(#{orgCode},'%')
|
and org_code like concat(#{orgCode},'%')
|
||||||
<if test="type != null">
|
<if test="type != null">
|
||||||
@@ -215,6 +215,6 @@
|
|||||||
lon_gd IS NOT NULL
|
lon_gd IS NOT NULL
|
||||||
AND lat_gd IS NOT NULL
|
AND lat_gd IS NOT NULL
|
||||||
AND NVL(address_gd, '') = ''
|
AND NVL(address_gd, '') = ''
|
||||||
limit 100
|
WHERE ROWNUM <= 100
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
+39
-46
@@ -6,15 +6,15 @@
|
|||||||
SELECT
|
SELECT
|
||||||
id as id ,
|
id as id ,
|
||||||
user_id as userId,
|
user_id as userId,
|
||||||
step_value as `stepValue`,
|
step_value as "stepValue",
|
||||||
distance_value as distanceValue,
|
distance_value as distanceValue,
|
||||||
calorie_value as calorieValue,
|
calorie_value as calorieValue,
|
||||||
data_date as dataDate,
|
data_date as dataDate,
|
||||||
TO_CHAR( data_date, 'MM' ) AS dateStr
|
TO_CHAR( data_date, 'MM' ) AS dateStr
|
||||||
FROM
|
FROM
|
||||||
`watch_stat_user_info_day_sdc`
|
"watch_stat_user_info_day_sdc"
|
||||||
WHERE
|
WHERE
|
||||||
YEAR ( data_date )= #{dateYear}
|
EXTRACT(YEAR FROM data_date) = #{dateYear}
|
||||||
and
|
and
|
||||||
user_id=#{userId}
|
user_id=#{userId}
|
||||||
</select>
|
</select>
|
||||||
@@ -22,14 +22,14 @@
|
|||||||
SELECT
|
SELECT
|
||||||
id as id ,
|
id as id ,
|
||||||
user_id as userId,
|
user_id as userId,
|
||||||
step_value as `stepValue`,
|
step_value as "stepValue",
|
||||||
distance_value as distanceValue,
|
distance_value as distanceValue,
|
||||||
calorie_value as calorieValue,
|
calorie_value as calorieValue,
|
||||||
data_date as dataDate
|
data_date as dataDate
|
||||||
FROM
|
FROM
|
||||||
`watch_stat_user_info_day_sdc`
|
"watch_stat_user_info_day_sdc"
|
||||||
WHERE
|
WHERE
|
||||||
YEAR ( data_date )= #{req.dateYear}
|
EXTRACT(YEAR FROM data_date) = #{req.dateYear}
|
||||||
and
|
and
|
||||||
user_id=#{req.userId}
|
user_id=#{req.userId}
|
||||||
order by data_date desc
|
order by data_date desc
|
||||||
@@ -170,26 +170,26 @@
|
|||||||
(select #{id,jdbcType=VARCHAR},
|
(select #{id,jdbcType=VARCHAR},
|
||||||
#{userId,jdbcType=VARCHAR},
|
#{userId,jdbcType=VARCHAR},
|
||||||
(select max(data_value)
|
(select max(data_value)
|
||||||
from watch_data_steps force index (bind_user_id)
|
from (select data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id ORDER BY data_date desc) as rn
|
||||||
|
from watch_data_steps
|
||||||
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and data_date = #{dataDate,jdbcType=DATE}
|
and data_date = #{dataDate,jdbcType=DATE})
|
||||||
group by data_date
|
where rn = 1) as step_value,
|
||||||
order by data_date desc
|
|
||||||
limit 1) as step_value,
|
|
||||||
(select max(data_value)
|
(select max(data_value)
|
||||||
from watch_data_distance force index (bind_user_id)
|
from (select data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id ORDER BY data_date desc) as rn
|
||||||
|
from watch_data_distance
|
||||||
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and data_date = #{dataDate,jdbcType=DATE}
|
and data_date = #{dataDate,jdbcType=DATE})
|
||||||
group by data_date
|
where rn = 1) as distance_value,
|
||||||
order by data_date desc
|
|
||||||
limit 1) as distance_value,
|
|
||||||
(select max(data_value)
|
(select max(data_value)
|
||||||
from watch_data_calorie force index (bind_user_id)
|
from (select data_value, data_date,
|
||||||
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id ORDER BY data_date desc) as rn
|
||||||
|
from watch_data_calorie
|
||||||
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and data_date = #{dataDate,jdbcType=DATE}
|
and data_date = #{dataDate,jdbcType=DATE})
|
||||||
group by data_date
|
where rn = 1) as calorie_value,
|
||||||
order by data_date desc
|
|
||||||
limit 1) as calorie_value,
|
|
||||||
#{lastUploadTime,jdbcType=TIMESTAMP},
|
#{lastUploadTime,jdbcType=TIMESTAMP},
|
||||||
#{dataDate,jdbcType=DATE},
|
#{dataDate,jdbcType=DATE},
|
||||||
#{orgCode,jdbcType=VARCHAR}
|
#{orgCode,jdbcType=VARCHAR}
|
||||||
@@ -198,34 +198,27 @@
|
|||||||
|
|
||||||
<update id="updateStat">
|
<update id="updateStat">
|
||||||
update watch_stat_user_info_day_sdc stat
|
update watch_stat_user_info_day_sdc stat
|
||||||
left join (select #{userId,jdbcType=VARCHAR} as bind_user_id,
|
set stat.step_value = (select max(data_value)
|
||||||
(select max(data_value)
|
from (select data_value, data_date,
|
||||||
from watch_data_steps force index (bind_user_id)
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id ORDER BY data_date desc) as rn
|
||||||
|
from watch_data_steps
|
||||||
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and data_date = #{dataDate,jdbcType=DATE}
|
and data_date = #{dataDate,jdbcType=DATE})
|
||||||
group by data_date
|
where rn = 1),
|
||||||
order by data_date desc
|
stat.distance_value = (select max(data_value)
|
||||||
limit 1) as step_value,
|
from (select data_value, data_date,
|
||||||
(select max(data_value)
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id ORDER BY data_date desc) as rn
|
||||||
from watch_data_distance force index (bind_user_id)
|
from watch_data_distance
|
||||||
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and data_date = #{dataDate,jdbcType=DATE}
|
and data_date = #{dataDate,jdbcType=DATE})
|
||||||
group by data_date
|
where rn = 1),
|
||||||
order by data_date desc
|
stat.calorie_value = (select max(data_value)
|
||||||
limit 1) as distance_value,
|
from (select data_value, data_date,
|
||||||
(select max(data_value)
|
ROW_NUMBER() OVER (PARTITION BY bind_user_id ORDER BY data_date desc) as rn
|
||||||
from watch_data_calorie force index (bind_user_id)
|
from watch_data_calorie
|
||||||
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and data_date = #{dataDate,jdbcType=DATE}
|
and data_date = #{dataDate,jdbcType=DATE})
|
||||||
group by data_date
|
where rn = 1),
|
||||||
order by data_date desc
|
|
||||||
limit 1) as calorie_value,
|
|
||||||
#{lastUploadTime,jdbcType=TIMESTAMP} as last_upload_time,
|
|
||||||
#{dataDate,jdbcType=DATE} as data_date
|
|
||||||
from dual) data on stat.user_id = data.bind_user_id
|
|
||||||
set stat.step_value = data.step_value,
|
|
||||||
stat.distance_value = data.distance_value,
|
|
||||||
stat.calorie_value = data.calorie_value,
|
|
||||||
stat.last_upload_time = #{lastUploadTime,jdbcType=TIMESTAMP},
|
stat.last_upload_time = #{lastUploadTime,jdbcType=TIMESTAMP},
|
||||||
stat.org_code = #{orgCode,jdbcType=VARCHAR}
|
stat.org_code = #{orgCode,jdbcType=VARCHAR}
|
||||||
where stat.user_id = #{userId,jdbcType=VARCHAR}
|
where stat.user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
|||||||
+3
-3
@@ -6,7 +6,7 @@
|
|||||||
SELECT
|
SELECT
|
||||||
id as id ,
|
id as id ,
|
||||||
user_id as userId,
|
user_id as userId,
|
||||||
sleep_avg as `sleepAvg`,
|
sleep_avg as "sleepAvg",
|
||||||
long_duration_avg as longDurationAvg,
|
long_duration_avg as longDurationAvg,
|
||||||
short_duration_avg as shortDurationAvg,
|
short_duration_avg as shortDurationAvg,
|
||||||
long_duration_max as longDurationMax,
|
long_duration_max as longDurationMax,
|
||||||
@@ -18,9 +18,9 @@
|
|||||||
data_date as dataDate,
|
data_date as dataDate,
|
||||||
TO_CHAR( data_date, 'MM' ) AS dateStr
|
TO_CHAR( data_date, 'MM' ) AS dateStr
|
||||||
FROM
|
FROM
|
||||||
`watch_stat_user_info_day_sleep`
|
"watch_stat_user_info_day_sleep"
|
||||||
WHERE
|
WHERE
|
||||||
YEAR ( data_date )= #{dateYear}
|
EXTRACT(YEAR FROM data_date) = #{dateYear}
|
||||||
and
|
and
|
||||||
user_id=#{userId}
|
user_id=#{userId}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
+36
-28
@@ -6,15 +6,15 @@
|
|||||||
SELECT
|
SELECT
|
||||||
id as id ,
|
id as id ,
|
||||||
user_id as userId,
|
user_id as userId,
|
||||||
max_value as `maxValue`,
|
max_value as "maxValue",
|
||||||
min_value as minValue,
|
min_value as minValue,
|
||||||
avg_value as avgValue,
|
avg_value as avgValue,
|
||||||
data_date as dataDate,
|
data_date as dataDate,
|
||||||
TO_CHAR( data_date, 'MM' ) AS dateStr
|
TO_CHAR( data_date, 'MM' ) AS dateStr
|
||||||
FROM
|
FROM
|
||||||
`watch_stat_user_info_day_spo2`
|
"watch_stat_user_info_day_spo2"
|
||||||
WHERE
|
WHERE
|
||||||
YEAR ( data_date )= #{dateYear}
|
EXTRACT(YEAR FROM data_date) = #{dateYear}
|
||||||
and
|
and
|
||||||
user_id=#{userId}
|
user_id=#{userId}
|
||||||
|
|
||||||
@@ -42,10 +42,10 @@
|
|||||||
new_value, data_date, org_code)
|
new_value, data_date, org_code)
|
||||||
(SELECT #{id,jdbcType=VARCHAR},
|
(SELECT #{id,jdbcType=VARCHAR},
|
||||||
bind_user_id,
|
bind_user_id,
|
||||||
IFNULL(MAX(wd.data_value), 0),
|
NVL(MAX(wd.data_value), 0),
|
||||||
IFNULL(MIN(wd.data_value), 0),
|
NVL(MIN(wd.data_value), 0),
|
||||||
IFNULL(AVG(wd.data_value), 0),
|
NVL(AVG(wd.data_value), 0),
|
||||||
IFNULL(MAX(wd.time_stamp), 0),
|
NVL(MAX(wd.time_stamp), TO_TIMESTAMP('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS')),
|
||||||
MAX(CASE WHEN wd.rn = 1 THEN wd.data_value END),
|
MAX(CASE WHEN wd.rn = 1 THEN wd.data_value END),
|
||||||
data_date,
|
data_date,
|
||||||
#{orgCode,jdbcType=VARCHAR}
|
#{orgCode,jdbcType=VARCHAR}
|
||||||
@@ -60,28 +60,36 @@
|
|||||||
<!-- 切记 此代码不能直接平移至四合一项目 ,该 sql 只适用 mysql8.0 及以上版本 ,四合一项目开发测试环境的 mysql 版本过低 , 但不影响正式环境-->
|
<!-- 切记 此代码不能直接平移至四合一项目 ,该 sql 只适用 mysql8.0 及以上版本 ,四合一项目开发测试环境的 mysql 版本过低 , 但不影响正式环境-->
|
||||||
<update id="updateStat">
|
<update id="updateStat">
|
||||||
UPDATE watch_stat_user_info_day_spo2 stat
|
UPDATE watch_stat_user_info_day_spo2 stat
|
||||||
LEFT JOIN (
|
SET stat.max_value = (SELECT NVL(MAX(wd.data_value), 0) AS max_value
|
||||||
SELECT
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
wd.bind_user_id,
|
FROM watch_data_spo2
|
||||||
wd.data_date,
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
IFNULL( MAX( wd.data_value ), 0 ) AS max_value,
|
|
||||||
IFNULL( MIN( wd.data_value ), 0 ) AS min_value,
|
|
||||||
IFNULL( AVG( wd.data_value ), 0 ) AS avg_value,
|
|
||||||
IFNULL( MAX( wd.time_stamp ), 0 ) AS last_upload_time,
|
|
||||||
MAX( CASE WHEN wd.rn = 1 THEN wd.data_value END ) AS new_value
|
|
||||||
FROM
|
|
||||||
( SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn FROM watch_data_spo2 where bind_user_id = #{userId,jdbcType=VARCHAR}
|
|
||||||
and data_date = #{dataDate,jdbcType=DATE}) wd
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
GROUP BY
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
wd.bind_user_id,
|
stat.min_value = (SELECT NVL(MIN(wd.data_value), 0) AS min_value
|
||||||
wd.data_date
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
) DATA ON stat.user_id = DATA.bind_user_id
|
FROM watch_data_spo2
|
||||||
AND stat.data_date = DATA.data_date
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
SET stat.max_value = DATA.max_value,
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
stat.min_value = DATA.min_value,
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
stat.avg_value = DATA.avg_value,
|
stat.avg_value = (SELECT NVL(AVG(wd.data_value), 0) AS avg_value
|
||||||
stat.last_upload_time = DATA.last_upload_time,
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
stat.new_value = DATA.new_value,
|
FROM watch_data_spo2
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
|
stat.last_upload_time = (SELECT NVL(MAX(wd.time_stamp), TO_TIMESTAMP('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'))
|
||||||
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
|
FROM watch_data_spo2
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
|
stat.new_value = (SELECT MAX(CASE WHEN wd.rn = 1 THEN wd.data_value END)
|
||||||
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
|
FROM watch_data_spo2
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
stat.org_code = #{orgCode,jdbcType=VARCHAR}
|
stat.org_code = #{orgCode,jdbcType=VARCHAR}
|
||||||
where stat.user_id = #{userId,jdbcType=VARCHAR}
|
where stat.user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and stat.data_date = #{dataDate,jdbcType=DATE};
|
and stat.data_date = #{dataDate,jdbcType=DATE};
|
||||||
|
|||||||
+35
-28
@@ -6,15 +6,15 @@
|
|||||||
SELECT
|
SELECT
|
||||||
id as id ,
|
id as id ,
|
||||||
user_id as userId,
|
user_id as userId,
|
||||||
max_value as `maxValue`,
|
max_value as "maxValue",
|
||||||
min_value as minValue,
|
min_value as minValue,
|
||||||
avg_value as avgValue,
|
avg_value as avgValue,
|
||||||
data_date as dataDate,
|
data_date as dataDate,
|
||||||
TO_CHAR( data_date, 'MM' ) AS dateStr
|
TO_CHAR( data_date, 'MM' ) AS dateStr
|
||||||
FROM
|
FROM
|
||||||
`watch_stat_user_info_day_stress`
|
"watch_stat_user_info_day_stress"
|
||||||
WHERE
|
WHERE
|
||||||
YEAR ( data_date )= #{dateYear}
|
EXTRACT(YEAR FROM data_date) = #{dateYear}
|
||||||
and
|
and
|
||||||
user_id=#{userId}
|
user_id=#{userId}
|
||||||
</select>
|
</select>
|
||||||
@@ -26,11 +26,11 @@
|
|||||||
SELECT
|
SELECT
|
||||||
#{id,jdbcType=VARCHAR},
|
#{id,jdbcType=VARCHAR},
|
||||||
bind_user_id,
|
bind_user_id,
|
||||||
IFNULL( MAX( wd.data_value ), 0 ),
|
NVL(MAX(wd.data_value), 0),
|
||||||
IFNULL( MIN( wd.data_value ), 0 ),
|
NVL(MIN(wd.data_value), 0),
|
||||||
IFNULL( AVG( wd.data_value ), 0 ),
|
NVL(AVG(wd.data_value), 0),
|
||||||
data_date,
|
data_date,
|
||||||
IFNULL(MAX( wd.end_time_stamp ),NOW()),
|
NVL(MAX(wd.end_time_stamp), SYSDATE),
|
||||||
MAX(CASE WHEN wd.rn = 1 THEN wd.data_value END),
|
MAX(CASE WHEN wd.rn = 1 THEN wd.data_value END),
|
||||||
#{orgCode,jdbcType=VARCHAR}
|
#{orgCode,jdbcType=VARCHAR}
|
||||||
FROM
|
FROM
|
||||||
@@ -46,29 +46,36 @@
|
|||||||
<!-- 切记 此代码不能直接平移至四合一项目 ,该 sql 只适用 mysql8.0 及以上版本 ,四合一项目开发测试环境的 mysql 版本过低 , 但不影响正式环境-->
|
<!-- 切记 此代码不能直接平移至四合一项目 ,该 sql 只适用 mysql8.0 及以上版本 ,四合一项目开发测试环境的 mysql 版本过低 , 但不影响正式环境-->
|
||||||
<update id="updateStat">
|
<update id="updateStat">
|
||||||
UPDATE watch_stat_user_info_day_stress stat
|
UPDATE watch_stat_user_info_day_stress stat
|
||||||
LEFT JOIN (
|
SET stat.max_value = (SELECT NVL(MAX(wd.data_value), 0)
|
||||||
SELECT
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY end_time_stamp DESC ) AS rn
|
||||||
wd.bind_user_id,
|
FROM watch_data_stress
|
||||||
wd.data_date,
|
|
||||||
IFNULL( MAX( wd.data_value ), 0 ) AS max_value,
|
|
||||||
IFNULL( MIN( wd.data_value ), 0 ) AS min_value,
|
|
||||||
IFNULL( AVG( wd.data_value ), 0 ) AS avg_value,
|
|
||||||
IFNULL(MAX( wd.end_time_stamp ),NOW()) AS last_upload_time,
|
|
||||||
MAX( CASE WHEN wd.rn = 1 THEN wd.data_value END ) AS new_value
|
|
||||||
FROM
|
|
||||||
( SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY end_time_stamp DESC ) AS rn FROM watch_data_stress
|
|
||||||
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and data_date = #{dataDate,jdbcType=DATE}) wd
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
GROUP BY
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
wd.bind_user_id,
|
stat.min_value = (SELECT NVL(MIN(wd.data_value), 0)
|
||||||
wd.data_date
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY end_time_stamp DESC ) AS rn
|
||||||
) DATA ON stat.user_id = DATA.bind_user_id
|
FROM watch_data_stress
|
||||||
AND stat.data_date = DATA.data_date
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
SET stat.max_value = DATA.max_value,
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
stat.min_value = DATA.min_value,
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
stat.avg_value = DATA.avg_value,
|
stat.avg_value = (SELECT NVL(AVG(wd.data_value), 0)
|
||||||
stat.last_upload_time = DATA.last_upload_time,
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY end_time_stamp DESC ) AS rn
|
||||||
stat.new_value = DATA.new_value,
|
FROM watch_data_stress
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
|
stat.last_upload_time = (SELECT NVL(MAX(wd.end_time_stamp), SYSDATE)
|
||||||
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY end_time_stamp DESC ) AS rn
|
||||||
|
FROM watch_data_stress
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
|
stat.new_value = (SELECT MAX(CASE WHEN wd.rn = 1 THEN wd.data_value END)
|
||||||
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY end_time_stamp DESC ) AS rn
|
||||||
|
FROM watch_data_stress
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
stat.org_code = #{orgCode,jdbcType=VARCHAR}
|
stat.org_code = #{orgCode,jdbcType=VARCHAR}
|
||||||
where stat.user_id = #{userId,jdbcType=VARCHAR}
|
where stat.user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and stat.data_date = #{dataDate,jdbcType=DATE};
|
and stat.data_date = #{dataDate,jdbcType=DATE};
|
||||||
|
|||||||
+61
-41
@@ -36,18 +36,17 @@
|
|||||||
|
|
||||||
<!-- 切记 此代码不能直接平移至四合一项目 ,该 sql 只适用 mysql8.0 及以上版本 ,四合一项目开发测试环境的 mysql 版本过低 , 但不影响正式环境-->
|
<!-- 切记 此代码不能直接平移至四合一项目 ,该 sql 只适用 mysql8.0 及以上版本 ,四合一项目开发测试环境的 mysql 版本过低 , 但不影响正式环境-->
|
||||||
<insert id="insertStat">
|
<insert id="insertStat">
|
||||||
insert into watch_stat_user_info_day_temp(id, user_id, max_value, min_value, avg_value, skin_max_value,
|
insert into watch_stat_user_info_day_temp(id, user_id, max_value, min_value, avg_value, skin_max_value, skin_min_value,
|
||||||
skin_min_value, skin_avg_value, last_upload_time, new_value,
|
skin_avg_value, last_upload_time, new_value, skin_new_value, data_date, org_code)
|
||||||
skin_new_value, data_date, org_code)
|
|
||||||
(SELECT #{id,jdbcType=VARCHAR},
|
(SELECT #{id,jdbcType=VARCHAR},
|
||||||
bind_user_id,
|
bind_user_id,
|
||||||
IFNULL(MAX(wd.data_value), 0),
|
NVL(MAX(wd.data_value), 0),
|
||||||
IFNULL(MIN(wd.data_value), 0),
|
NVL(MIN(wd.data_value), 0),
|
||||||
IFNULL(AVG(wd.data_value), 0),
|
NVL(AVG(wd.data_value), 0),
|
||||||
IFNULL(MAX(wd.skin_tempera), 0),
|
NVL(MAX(wd.skin_tempera), 0),
|
||||||
IFNULL(MIN(wd.skin_tempera), 0),
|
NVL(MIN(wd.skin_tempera), 0),
|
||||||
IFNULL(AVG(wd.skin_tempera), 0),
|
NVL(AVG(wd.skin_tempera), 0),
|
||||||
IFNULL(MAX(wd.time_stamp), NOW()),
|
NVL(MAX(wd.time_stamp), SYSDATE),
|
||||||
MAX(CASE WHEN wd.rn = 1 THEN wd.data_value END),
|
MAX(CASE WHEN wd.rn = 1 THEN wd.data_value END),
|
||||||
MAX(CASE WHEN wd.rn = 1 THEN wd.skin_tempera END),
|
MAX(CASE WHEN wd.rn = 1 THEN wd.skin_tempera END),
|
||||||
data_date,
|
data_date,
|
||||||
@@ -63,39 +62,60 @@
|
|||||||
<!-- 切记 此代码不能直接平移至四合一项目 ,该 sql 只适用 mysql8.0 及以上版本 ,四合一项目开发测试环境的 mysql 版本过低 , 但不影响正式环境-->
|
<!-- 切记 此代码不能直接平移至四合一项目 ,该 sql 只适用 mysql8.0 及以上版本 ,四合一项目开发测试环境的 mysql 版本过低 , 但不影响正式环境-->
|
||||||
<update id="updateStat">
|
<update id="updateStat">
|
||||||
UPDATE watch_stat_user_info_day_temp stat
|
UPDATE watch_stat_user_info_day_temp stat
|
||||||
LEFT JOIN (
|
SET stat.max_value = (SELECT NVL(MAX(wd.data_value), 0)
|
||||||
SELECT
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
wd.bind_user_id,
|
FROM watch_data_temperature
|
||||||
wd.data_date,
|
|
||||||
IFNULL( MAX( wd.data_value ), 0 ) AS max_value,
|
|
||||||
IFNULL( MIN( wd.data_value ), 0 ) AS min_value,
|
|
||||||
IFNULL( AVG( wd.data_value ), 0 ) AS avg_value,
|
|
||||||
IFNULL( MAX( wd.skin_tempera ), 0 ) AS skin_max_value,
|
|
||||||
IFNULL( MIN( wd.skin_tempera ), 0 ) AS skin_min_value,
|
|
||||||
IFNULL( AVG( wd.skin_tempera ), 0 ) AS skin_avg_value,
|
|
||||||
IFNULL(
|
|
||||||
MAX( wd.time_stamp ),
|
|
||||||
NOW()) AS last_upload_time,
|
|
||||||
MAX( CASE WHEN wd.rn = 1 THEN wd.data_value END ) AS new_value,
|
|
||||||
MAX( CASE WHEN wd.rn = 1 THEN wd.skin_tempera END ) AS skin_new_value
|
|
||||||
FROM
|
|
||||||
( SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn FROM watch_data_temperature
|
|
||||||
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and data_date = #{dataDate,jdbcType=DATE}) wd
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
GROUP BY
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
wd.bind_user_id,
|
stat.min_value = (SELECT NVL(MIN(wd.data_value), 0)
|
||||||
wd.data_date
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
) DATA ON stat.user_id = DATA.bind_user_id
|
FROM watch_data_temperature
|
||||||
AND stat.data_date = DATA.data_date
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
SET stat.max_value = DATA.max_value,
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
stat.min_value = DATA.min_value,
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
stat.avg_value = DATA.avg_value,
|
stat.avg_value = (SELECT NVL(AVG(wd.data_value), 0)
|
||||||
stat.skin_max_value = DATA.skin_max_value,
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
stat.skin_min_value = DATA.skin_min_value,
|
FROM watch_data_temperature
|
||||||
stat.skin_avg_value = DATA.skin_avg_value,
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
stat.last_upload_time = DATA.last_upload_time,
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
stat.new_value = DATA.new_value,
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
stat.skin_new_value = COALESCE ( NULLIF( DATA.skin_new_value, 0 ), stat.skin_new_value ),
|
stat.skin_max_value = (SELECT NVL(MAX(wd.skin_tempera), 0)
|
||||||
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
|
FROM watch_data_temperature
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
|
stat.skin_min_value = (SELECT NVL(MIN(wd.skin_tempera), 0)
|
||||||
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
|
FROM watch_data_temperature
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
|
stat.skin_avg_value = (SELECT NVL(AVG(wd.skin_tempera), 0)
|
||||||
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
|
FROM watch_data_temperature
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
|
stat.last_upload_time = (SELECT NVL(MAX(wd.time_stamp), SYSDATE)
|
||||||
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
|
FROM watch_data_temperature
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
|
stat.new_value = (SELECT MAX(CASE WHEN wd.rn = 1 THEN wd.data_value END)
|
||||||
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
|
FROM watch_data_temperature
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
|
stat.skin_new_value = (SELECT NVL(MAX(CASE WHEN wd.rn = 1 THEN wd.skin_tempera END), stat.skin_new_value)
|
||||||
|
FROM (SELECT *, ROW_NUMBER() OVER ( PARTITION BY bind_user_id, data_date ORDER BY time_stamp DESC ) AS rn
|
||||||
|
FROM watch_data_temperature
|
||||||
|
where bind_user_id = #{userId,jdbcType=VARCHAR}
|
||||||
|
and data_date = #{dataDate,jdbcType=DATE}) wd
|
||||||
|
GROUP BY wd.bind_user_id, wd.data_date),
|
||||||
stat.org_code = #{orgCode,jdbcType=VARCHAR}
|
stat.org_code = #{orgCode,jdbcType=VARCHAR}
|
||||||
where stat.user_id = #{userId,jdbcType=VARCHAR}
|
where stat.user_id = #{userId,jdbcType=VARCHAR}
|
||||||
and stat.data_date = #{dataDate,jdbcType=DATE};
|
and stat.data_date = #{dataDate,jdbcType=DATE};
|
||||||
|
|||||||
+6
-3
@@ -158,7 +158,7 @@ public class WatchBindHisServiceImpl extends ServiceImpl<WatchBindHisMapper, Wat
|
|||||||
.le(WatchBindHis::getBindDate, bindDate)
|
.le(WatchBindHis::getBindDate, bindDate)
|
||||||
.isNull(WatchBindHis::getBindEndDate)
|
.isNull(WatchBindHis::getBindEndDate)
|
||||||
.orderByDesc(WatchBindHis::getBindDate)
|
.orderByDesc(WatchBindHis::getBindDate)
|
||||||
.last("LIMIT 1"));
|
.last("FETCH FIRST 1 ROWS ONLY"));
|
||||||
if (watchBindHis != null) {
|
if (watchBindHis != null) {
|
||||||
return watchBindHis.getBindUserId();
|
return watchBindHis.getBindUserId();
|
||||||
}
|
}
|
||||||
@@ -167,8 +167,11 @@ public class WatchBindHisServiceImpl extends ServiceImpl<WatchBindHisMapper, Wat
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getWatchNo(String bindUserId, Date bindDate) {
|
public String getWatchNo(String bindUserId, Date bindDate) {
|
||||||
WatchBindHis watchBindHis = getOne(new LambdaQueryWrapper<WatchBindHis>().eq(WatchBindHis::getBindUserId, bindUserId)
|
WatchBindHis watchBindHis = getOne(new LambdaQueryWrapper<WatchBindHis>()
|
||||||
.eq(WatchBindHis::getBindDate, bindDate).orderByDesc(WatchBindHis::getBindDate).last("LIMIT 1"));
|
.eq(WatchBindHis::getBindUserId, bindUserId)
|
||||||
|
.eq(WatchBindHis::getBindDate, bindDate)
|
||||||
|
.orderByDesc(WatchBindHis::getBindDate)
|
||||||
|
.last("FETCH FIRST 1 ROWS ONLY"));
|
||||||
if (watchBindHis != null) {
|
if (watchBindHis != null) {
|
||||||
return watchBindHis.getWatchNo();
|
return watchBindHis.getWatchNo();
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -812,7 +812,7 @@ public class WatchDeviceServiceImpl extends ServiceImpl<WatchDeviceMapper, Watch
|
|||||||
binHisQueryWrapper.isNull(WatchBindHis::getBindEndDate);
|
binHisQueryWrapper.isNull(WatchBindHis::getBindEndDate);
|
||||||
binHisQueryWrapper.eq(WatchBindHis::getWatchNo, watchDevice.getWatchNo());
|
binHisQueryWrapper.eq(WatchBindHis::getWatchNo, watchDevice.getWatchNo());
|
||||||
binHisQueryWrapper.orderByDesc(WatchBindHis::getCreateDate);
|
binHisQueryWrapper.orderByDesc(WatchBindHis::getCreateDate);
|
||||||
binHisQueryWrapper.last("limit 1");
|
binHisQueryWrapper.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
WatchBindHis watchBindHis = watchBindHisService.getOne(binHisQueryWrapper);
|
WatchBindHis watchBindHis = watchBindHisService.getOne(binHisQueryWrapper);
|
||||||
if (watchBindHis == null) {
|
if (watchBindHis == null) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
+3
-1
@@ -224,7 +224,9 @@ public class WatchMqttNoticeServiceImpl extends ServiceImpl<WatchMqttNoticeMappe
|
|||||||
|
|
||||||
private String getUserWatchNo(String userId) {
|
private String getUserWatchNo(String userId) {
|
||||||
LambdaQueryWrapper<WatchBindHis> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WatchBindHis> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(WatchBindHis::getBindUserId, userId).orderByDesc(WatchBindHis::getBindDate).last(" limit 1");
|
queryWrapper.eq(WatchBindHis::getBindUserId, userId)
|
||||||
|
.orderByDesc(WatchBindHis::getBindDate)
|
||||||
|
.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
WatchBindHis watchBindHis = watchBindHisMapper.selectOne(queryWrapper);
|
WatchBindHis watchBindHis = watchBindHisMapper.selectOne(queryWrapper);
|
||||||
if (watchBindHis != null) {
|
if (watchBindHis != null) {
|
||||||
return watchBindHis.getWatchNo();
|
return watchBindHis.getWatchNo();
|
||||||
|
|||||||
+23
-15
@@ -586,7 +586,7 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
wrapper.selectAs(WatchStatUserInfoDaySleep::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
wrapper.selectAs(WatchStatUserInfoDaySleep::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
||||||
wrapper.eq(WatchStatUserInfoDaySleep::getUserId, userId);
|
wrapper.eq(WatchStatUserInfoDaySleep::getUserId, userId);
|
||||||
wrapper.orderByDesc(WatchStatUserInfoDaySleep::getDataDate);
|
wrapper.orderByDesc(WatchStatUserInfoDaySleep::getDataDate);
|
||||||
wrapper.last("limit 1");
|
wrapper.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
return daySleepMapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
return daySleepMapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -597,7 +597,7 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
wrapper.selectAs(WatchStatUserInfoDaySdc::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
wrapper.selectAs(WatchStatUserInfoDaySdc::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
||||||
wrapper.eq(WatchStatUserInfoDaySdc::getUserId, userId);
|
wrapper.eq(WatchStatUserInfoDaySdc::getUserId, userId);
|
||||||
wrapper.orderByDesc(WatchStatUserInfoDaySdc::getDataDate);
|
wrapper.orderByDesc(WatchStatUserInfoDaySdc::getDataDate);
|
||||||
wrapper.last("limit 1");
|
wrapper.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
return statSdcMapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
return statSdcMapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,7 +611,7 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
wrapper.selectAs(WatchStatUserInfoDayHeartRate::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
wrapper.selectAs(WatchStatUserInfoDayHeartRate::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
||||||
wrapper.eq(WatchStatUserInfoDayHeartRate::getUserId, userId);
|
wrapper.eq(WatchStatUserInfoDayHeartRate::getUserId, userId);
|
||||||
wrapper.orderByDesc(WatchStatUserInfoDayHeartRate::getDataDate);
|
wrapper.orderByDesc(WatchStatUserInfoDayHeartRate::getDataDate);
|
||||||
wrapper.last("limit 1");
|
wrapper.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
return dayHeartRateMapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
return dayHeartRateMapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -625,7 +625,7 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
wrapper.selectAs(WatchStatUserInfoDaySpo2::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
wrapper.selectAs(WatchStatUserInfoDaySpo2::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
||||||
wrapper.eq(WatchStatUserInfoDaySpo2::getUserId, userId);
|
wrapper.eq(WatchStatUserInfoDaySpo2::getUserId, userId);
|
||||||
wrapper.orderByDesc(WatchStatUserInfoDaySpo2::getDataDate);
|
wrapper.orderByDesc(WatchStatUserInfoDaySpo2::getDataDate);
|
||||||
wrapper.last("limit 1");
|
wrapper.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
return daySpo2Mapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
return daySpo2Mapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -639,7 +639,7 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
wrapper.selectAs(WatchStatUserInfoDayStress::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
wrapper.selectAs(WatchStatUserInfoDayStress::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
||||||
wrapper.eq(WatchStatUserInfoDayStress::getUserId, userId);
|
wrapper.eq(WatchStatUserInfoDayStress::getUserId, userId);
|
||||||
wrapper.orderByDesc(WatchStatUserInfoDayStress::getDataDate);
|
wrapper.orderByDesc(WatchStatUserInfoDayStress::getDataDate);
|
||||||
wrapper.last("limit 1");
|
wrapper.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
return dayStressMapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
return dayStressMapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -653,7 +653,7 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
wrapper.selectAs(WatchStatUserInfoDayTemp::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
wrapper.selectAs(WatchStatUserInfoDayTemp::getDataDate,WatchH5IndexItemNewVo::getDataDate);
|
||||||
wrapper.eq(WatchStatUserInfoDayTemp::getUserId, userId);
|
wrapper.eq(WatchStatUserInfoDayTemp::getUserId, userId);
|
||||||
wrapper.orderByDesc(WatchStatUserInfoDayTemp::getDataDate);
|
wrapper.orderByDesc(WatchStatUserInfoDayTemp::getDataDate);
|
||||||
wrapper.last("limit 1");
|
wrapper.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
return dayTempMapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
return dayTempMapper.selectJoinOne(WatchH5IndexItemNewVo.class,wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -662,7 +662,7 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
LambdaQueryWrapper<WatchBindHis> wrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<WatchBindHis> wrapper = new LambdaQueryWrapper<>();
|
||||||
wrapper.eq(WatchBindHis::getBindUserId, userId);
|
wrapper.eq(WatchBindHis::getBindUserId, userId);
|
||||||
wrapper.orderByDesc(WatchBindHis::getBindDate);
|
wrapper.orderByDesc(WatchBindHis::getBindDate);
|
||||||
wrapper.last("limit 1");
|
wrapper.last("FETCH FIRST 1 ROWS ONLY");
|
||||||
return bindHisMapper.selectOne(wrapper);
|
return bindHisMapper.selectOne(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -903,8 +903,10 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
WatchH5WorkoutDayVo watchH5WorkoutDayVo = new WatchH5WorkoutDayVo();
|
WatchH5WorkoutDayVo watchH5WorkoutDayVo = new WatchH5WorkoutDayVo();
|
||||||
|
|
||||||
WatchBindHis watchBindHis = bindHisMapper.selectOne(new LambdaQueryWrapper<WatchBindHis>()
|
WatchBindHis watchBindHis = bindHisMapper.selectOne(new LambdaQueryWrapper<WatchBindHis>()
|
||||||
.eq(WatchBindHis::getBindUserId, userId).le(WatchBindHis::getBindDate, queryDate)
|
.eq(WatchBindHis::getBindUserId, userId)
|
||||||
.orderByDesc(WatchBindHis::getBindDate).last("limit 1"));
|
.le(WatchBindHis::getBindDate, queryDate)
|
||||||
|
.orderByDesc(WatchBindHis::getBindDate)
|
||||||
|
.last("FETCH FIRST 1 ROWS ONLY"));
|
||||||
|
|
||||||
String watchNo = null;
|
String watchNo = null;
|
||||||
if (watchBindHis != null) {
|
if (watchBindHis != null) {
|
||||||
@@ -1021,8 +1023,10 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
}
|
}
|
||||||
WatchH5StepsDayVo watchH5StepsDayVo = this.getStepsData(userId, queryDate);
|
WatchH5StepsDayVo watchH5StepsDayVo = this.getStepsData(userId, queryDate);
|
||||||
WatchBindHis watchBindHis = bindHisMapper.selectOne(new LambdaQueryWrapper<WatchBindHis>()
|
WatchBindHis watchBindHis = bindHisMapper.selectOne(new LambdaQueryWrapper<WatchBindHis>()
|
||||||
.eq(WatchBindHis::getBindUserId, userId).le(WatchBindHis::getBindDate, queryDate)
|
.eq(WatchBindHis::getBindUserId, userId)
|
||||||
.orderByDesc(WatchBindHis::getBindDate).last("limit 1"));
|
.le(WatchBindHis::getBindDate, queryDate)
|
||||||
|
.orderByDesc(WatchBindHis::getBindDate)
|
||||||
|
.last("FETCH FIRST 1 ROWS ONLY"));
|
||||||
String watchNo = null;
|
String watchNo = null;
|
||||||
if (watchBindHis != null) {
|
if (watchBindHis != null) {
|
||||||
watchNo = watchBindHis.getWatchNo();
|
watchNo = watchBindHis.getWatchNo();
|
||||||
@@ -1082,8 +1086,10 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
|
|
||||||
public WatchH5WorkoutResultVO getWorkoutWeekDayList(String userId, Date queryDate) {
|
public WatchH5WorkoutResultVO getWorkoutWeekDayList(String userId, Date queryDate) {
|
||||||
WatchBindHis watchBindHis = bindHisMapper.selectOne(new LambdaQueryWrapper<WatchBindHis>()
|
WatchBindHis watchBindHis = bindHisMapper.selectOne(new LambdaQueryWrapper<WatchBindHis>()
|
||||||
.eq(WatchBindHis::getBindUserId, userId).le(WatchBindHis::getBindDate, queryDate)
|
.eq(WatchBindHis::getBindUserId, userId)
|
||||||
.orderByDesc(WatchBindHis::getBindDate).last("limit 1"));
|
.le(WatchBindHis::getBindDate, queryDate)
|
||||||
|
.orderByDesc(WatchBindHis::getBindDate)
|
||||||
|
.last("FETCH FIRST 1 ROWS ONLY"));
|
||||||
String watchNo = null;
|
String watchNo = null;
|
||||||
if (watchBindHis != null) {
|
if (watchBindHis != null) {
|
||||||
watchNo = watchBindHis.getWatchNo();
|
watchNo = watchBindHis.getWatchNo();
|
||||||
@@ -1103,8 +1109,10 @@ public class WatchServiceImpl implements IWatchService {
|
|||||||
@Override
|
@Override
|
||||||
public WatchH5StepsResultVO getStepsWeekDayList(String userId, Date queryDate) {
|
public WatchH5StepsResultVO getStepsWeekDayList(String userId, Date queryDate) {
|
||||||
WatchBindHis watchBindHis = bindHisMapper.selectOne(new LambdaQueryWrapper<WatchBindHis>()
|
WatchBindHis watchBindHis = bindHisMapper.selectOne(new LambdaQueryWrapper<WatchBindHis>()
|
||||||
.eq(WatchBindHis::getBindUserId, userId).le(WatchBindHis::getBindDate, queryDate)
|
.eq(WatchBindHis::getBindUserId, userId)
|
||||||
.orderByDesc(WatchBindHis::getBindDate).last("limit 1"));
|
.le(WatchBindHis::getBindDate, queryDate)
|
||||||
|
.orderByDesc(WatchBindHis::getBindDate)
|
||||||
|
.last("FETCH FIRST 1 ROWS ONLY"));
|
||||||
String watchNo = null;
|
String watchNo = null;
|
||||||
if (watchBindHis != null) {
|
if (watchBindHis != null) {
|
||||||
watchNo = watchBindHis.getWatchNo();
|
watchNo = watchBindHis.getWatchNo();
|
||||||
|
|||||||
+6
-2
@@ -23,7 +23,9 @@ public class WatchSynMaxIdServiceImpl extends ServiceImpl<WatchSynMaxIdMapper, W
|
|||||||
@Override
|
@Override
|
||||||
public String getMaxId(String wdType) {
|
public String getMaxId(String wdType) {
|
||||||
WatchSynMaxId watchSynMaxId = getOne(new QueryWrapper<WatchSynMaxId>()
|
WatchSynMaxId watchSynMaxId = getOne(new QueryWrapper<WatchSynMaxId>()
|
||||||
.eq("wd_type", wdType).last("limit 1"));
|
.eq("wd_type", wdType)
|
||||||
|
.orderByDesc("max_id")
|
||||||
|
.last("FETCH FIRST 1 ROWS ONLY"));
|
||||||
if (watchSynMaxId != null) {
|
if (watchSynMaxId != null) {
|
||||||
return watchSynMaxId.getMaxId() == null ? "0" : watchSynMaxId.getMaxId();
|
return watchSynMaxId.getMaxId() == null ? "0" : watchSynMaxId.getMaxId();
|
||||||
}
|
}
|
||||||
@@ -34,7 +36,9 @@ public class WatchSynMaxIdServiceImpl extends ServiceImpl<WatchSynMaxIdMapper, W
|
|||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void setMaxId(String wdType, String maxId) {
|
public void setMaxId(String wdType, String maxId) {
|
||||||
WatchSynMaxId watchSynMaxId = getOne(new QueryWrapper<WatchSynMaxId>()
|
WatchSynMaxId watchSynMaxId = getOne(new QueryWrapper<WatchSynMaxId>()
|
||||||
.eq("wd_type", wdType).last("limit 1"));
|
.eq("wd_type", wdType)
|
||||||
|
.orderByDesc("max_id")
|
||||||
|
.last("FETCH FIRST 1 ROWS ONLY"));
|
||||||
if (watchSynMaxId != null) {
|
if (watchSynMaxId != null) {
|
||||||
if (StrUtil.isNotEmpty(maxId)) {
|
if (StrUtil.isNotEmpty(maxId)) {
|
||||||
watchSynMaxId.setMaxId(maxId);
|
watchSynMaxId.setMaxId(maxId);
|
||||||
|
|||||||
Reference in New Issue
Block a user