fix(watch): 上线修复BUG
This commit is contained in:
+10
-3
@@ -59,9 +59,16 @@ public class WatchCloudManager {
|
|||||||
if (CollectionUtil.isEmpty(userIds)) {
|
if (CollectionUtil.isEmpty(userIds)) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
return ListUtil.partition(userIds, 500)
|
List<List<String>> partitions = ListUtil.partition(userIds, 500);
|
||||||
.stream()
|
log.info("[userListNew] 开始批量查询用户,总数={},分批数={}", userIds.size(), partitions.size());
|
||||||
.flatMap(subIds -> sysBaseApi.listUserByIdsNew(subIds).stream())
|
return partitions.stream()
|
||||||
|
.flatMap(subIds -> {
|
||||||
|
log.info("[userListNew] 调用Feign,本批数量={}", subIds.size());
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
List<LoginUser> result = sysBaseApi.listUserByIdsNew(subIds);
|
||||||
|
log.info("[userListNew] Feign返回,本批耗时={}ms,返回数量={}", System.currentTimeMillis() - start, result == null ? 0 : result.size());
|
||||||
|
return result == null ? java.util.stream.Stream.empty() : result.stream();
|
||||||
|
})
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+7
-7
@@ -193,7 +193,7 @@
|
|||||||
) where rn = 1)
|
) 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">
|
||||||
@@ -226,7 +226,7 @@
|
|||||||
) where rn = 1)
|
) 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">
|
||||||
@@ -266,7 +266,7 @@
|
|||||||
) where ROWNUM = 1)
|
) 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">
|
||||||
@@ -299,7 +299,7 @@
|
|||||||
) where rn = 1)
|
) 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">
|
||||||
@@ -335,7 +335,7 @@
|
|||||||
) where rn = 1)
|
) 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">
|
||||||
@@ -371,7 +371,7 @@
|
|||||||
) where rn = 1)
|
) 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">
|
||||||
@@ -407,6 +407,6 @@
|
|||||||
) where rn = 1)
|
) 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>
|
||||||
|
|||||||
+14
-1
@@ -12,6 +12,7 @@ import com.renkang.watch.mapper.*;
|
|||||||
import com.renkang.watch.service.IWatchUserDataService;
|
import com.renkang.watch.service.IWatchUserDataService;
|
||||||
import com.renkang.watch.util.WatchDataType;
|
import com.renkang.watch.util.WatchDataType;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jeecg.common.system.vo.LoginUser;
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
import org.jeecg.global.GlobalUtils;
|
import org.jeecg.global.GlobalUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -28,6 +29,7 @@ import java.util.stream.Collectors;
|
|||||||
* @author Jiang Shunzhi
|
* @author Jiang Shunzhi
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
@Slf4j
|
||||||
public class PostProcessor implements IPostProcessor {
|
public class PostProcessor implements IPostProcessor {
|
||||||
|
|
||||||
private static WatchDataMapper watchDataMapperStatic;
|
private static WatchDataMapper watchDataMapperStatic;
|
||||||
@@ -123,14 +125,25 @@ public class PostProcessor implements IPostProcessor {
|
|||||||
.stream()
|
.stream()
|
||||||
.flatMap(map -> map.values().stream())
|
.flatMap(map -> map.values().stream())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
log.info("[getUserMap] 准备查询用户信息,userIds数量={}", userIds.size());
|
||||||
GlobalUtils.setFeignToken();
|
GlobalUtils.setFeignToken();
|
||||||
return cloudManager.userMapNew(userIds);
|
log.info("[getUserMap] setFeignToken完成,开始调用Feign");
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
Map<String, LoginUser> userMap = cloudManager.userMapNew(userIds);
|
||||||
|
log.info("[getUserMap] Feign调用成功,耗时={}ms,返回用户数={}", System.currentTimeMillis() - start, userMap.size());
|
||||||
|
return userMap;
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("[getUserMap] Feign调用失败,耗时={}ms,userIds数量={}", System.currentTimeMillis() - start, userIds.size(), e);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void statCommon(Map<String, Map<Date, String>> userBindWatch,
|
private void statCommon(Map<String, Map<Date, String>> userBindWatch,
|
||||||
BiConsumer<LoginUser, String> updateLatest,
|
BiConsumer<LoginUser, String> updateLatest,
|
||||||
BiConsumer<LoginUser, Date> updateStat) {
|
BiConsumer<LoginUser, Date> updateStat) {
|
||||||
Map<String, LoginUser> userMap = getUserMap(userBindWatch);
|
Map<String, LoginUser> userMap = getUserMap(userBindWatch);
|
||||||
|
log.info("[statCommon] userMap获取完成,共{}个用户,watchNo数量={}", userMap.size(), userBindWatch.size());
|
||||||
for (Map.Entry<String, Map<Date, String>> entry : userBindWatch.entrySet()) {
|
for (Map.Entry<String, Map<Date, String>> entry : userBindWatch.entrySet()) {
|
||||||
entry.getValue().values().stream().distinct().forEach(userId -> {
|
entry.getValue().values().stream().distinct().forEach(userId -> {
|
||||||
LoginUser userInfo = userMap.get(userId);
|
LoginUser userInfo = userMap.get(userId);
|
||||||
|
|||||||
+13
-16
@@ -1099,22 +1099,19 @@
|
|||||||
|
|
||||||
|
|
||||||
<update id="updateAge">
|
<update id="updateAge">
|
||||||
UPDATE QH_HLT_USER_EMPLOYEE_EX he
|
MERGE INTO QH_HLT_USER_EMPLOYEE_EX he
|
||||||
SET he.current_age = (
|
USING (
|
||||||
SELECT FLOOR((CURRENT_DATE - TO_DATE(SUBSTRING(REPLACE(su.id_card, ' ', ''), 7, 8), 'YYYYMMDD')) / 365)
|
SELECT
|
||||||
FROM QH_SYS_USER su
|
id,
|
||||||
WHERE he.id = su.id
|
FLOOR((CURRENT_DATE - TO_DATE(SUBSTRING(REPLACE(id_card, ' ', ''), 7, 8), 'YYYYMMDD')) / 365.25) as calculated_age
|
||||||
AND LENGTH(REPLACE(su.id_card, ' ', '')) = 18
|
FROM QH_SYS_USER
|
||||||
AND su.person_type = '1'
|
WHERE LENGTH(REPLACE(id_card, ' ', '')) = 18
|
||||||
AND su.del_flag = 0
|
AND person_type = '1'
|
||||||
)
|
AND del_flag = 0
|
||||||
WHERE EXISTS (
|
) su
|
||||||
SELECT 1 FROM QH_SYS_USER su
|
ON (he.id = su.id)
|
||||||
WHERE he.id = su.id
|
WHEN MATCHED THEN
|
||||||
AND LENGTH(REPLACE(su.id_card, ' ', '')) = 18
|
UPDATE SET he.current_age = su.calculated_age;
|
||||||
AND su.person_type = '1'
|
|
||||||
AND su.del_flag = 0
|
|
||||||
)
|
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user