fix(watch): 上线修复BUG

This commit is contained in:
2026-05-10 03:54:25 +08:00
parent 270c9a52f9
commit 61f26973ae
4 changed files with 44 additions and 27 deletions
@@ -59,9 +59,16 @@ public class WatchCloudManager {
if (CollectionUtil.isEmpty(userIds)) {
return Collections.emptyList();
}
return ListUtil.partition(userIds, 500)
.stream()
.flatMap(subIds -> sysBaseApi.listUserByIdsNew(subIds).stream())
List<List<String>> partitions = ListUtil.partition(userIds, 500);
log.info("[userListNew] 开始批量查询用户,总数={},分批数={}", userIds.size(), partitions.size());
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());
}
@@ -193,7 +193,7 @@
) where rn = 1)
where userid = #{userid,jdbcType=VARCHAR}
and watch_no = #{watchNo,jdbcType=VARCHAR}
and "type" = 2;
and type = 2;
</update>
<insert id="insertStress">
@@ -226,7 +226,7 @@
) where rn = 1)
where userid = #{userid,jdbcType=VARCHAR}
and watch_no = #{watchNo,jdbcType=VARCHAR}
and "type" = 3;
and type = 3;
</update>
<insert id="insertSleep">
@@ -266,7 +266,7 @@
) where ROWNUM = 1)
where userid = #{userid,jdbcType=VARCHAR}
and watch_no = #{watchNo,jdbcType=VARCHAR}
and "type" = 4;
and type = 4;
</update>
<insert id="insertTemperature">
@@ -299,7 +299,7 @@
) where rn = 1)
where userid = #{userid,jdbcType=VARCHAR}
and watch_no = #{watchNo,jdbcType=VARCHAR}
and "type" = 5;
and type = 5;
</update>
<insert id="insertWorkout">
@@ -335,7 +335,7 @@
) where rn = 1)
where userid = #{userid,jdbcType=VARCHAR}
and watch_no = #{watchNo,jdbcType=VARCHAR}
and "type" = 6;
and type = 6;
</update>
<insert id="insertDistance">
@@ -371,7 +371,7 @@
) where rn = 1)
where userid = #{userid,jdbcType=VARCHAR}
and watch_no = #{watchNo,jdbcType=VARCHAR}
and "type" = 7;
and type = 7;
</update>
<insert id="insertSteps">
@@ -407,6 +407,6 @@
) where rn = 1)
where userid = #{userid,jdbcType=VARCHAR}
and watch_no = #{watchNo,jdbcType=VARCHAR}
and "type" = 8;
and type = 8;
</update>
</mapper>
@@ -12,6 +12,7 @@ import com.renkang.watch.mapper.*;
import com.renkang.watch.service.IWatchUserDataService;
import com.renkang.watch.util.WatchDataType;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.global.GlobalUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +29,7 @@ import java.util.stream.Collectors;
* @author Jiang Shunzhi
*/
@Component
@Slf4j
public class PostProcessor implements IPostProcessor {
private static WatchDataMapper watchDataMapperStatic;
@@ -123,14 +125,25 @@ public class PostProcessor implements IPostProcessor {
.stream()
.flatMap(map -> map.values().stream())
.collect(Collectors.toList());
log.info("[getUserMap] 准备查询用户信息,userIds数量={}", userIds.size());
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调用失败,耗时={}msuserIds数量={}", System.currentTimeMillis() - start, userIds.size(), e);
throw e;
}
}
private void statCommon(Map<String, Map<Date, String>> userBindWatch,
BiConsumer<LoginUser, String> updateLatest,
BiConsumer<LoginUser, Date> updateStat) {
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()) {
entry.getValue().values().stream().distinct().forEach(userId -> {
LoginUser userInfo = userMap.get(userId);
@@ -1099,22 +1099,19 @@
<update id="updateAge">
UPDATE QH_HLT_USER_EMPLOYEE_EX he
SET he.current_age = (
SELECT FLOOR((CURRENT_DATE - TO_DATE(SUBSTRING(REPLACE(su.id_card, ' ', ''), 7, 8), 'YYYYMMDD')) / 365)
FROM QH_SYS_USER su
WHERE he.id = su.id
AND LENGTH(REPLACE(su.id_card, ' ', '')) = 18
AND su.person_type = '1'
AND su.del_flag = 0
)
WHERE EXISTS (
SELECT 1 FROM QH_SYS_USER su
WHERE he.id = su.id
AND LENGTH(REPLACE(su.id_card, ' ', '')) = 18
AND su.person_type = '1'
AND su.del_flag = 0
)
MERGE INTO QH_HLT_USER_EMPLOYEE_EX he
USING (
SELECT
id,
FLOOR((CURRENT_DATE - TO_DATE(SUBSTRING(REPLACE(id_card, ' ', ''), 7, 8), 'YYYYMMDD')) / 365.25) as calculated_age
FROM QH_SYS_USER
WHERE LENGTH(REPLACE(id_card, ' ', '')) = 18
AND person_type = '1'
AND del_flag = 0
) su
ON (he.id = su.id)
WHEN MATCHED THEN
UPDATE SET he.current_age = su.calculated_age;
</update>
</mapper>