From 61f26973aeb755ef1435b187ca2be7401b8b1683 Mon Sep 17 00:00:00 2001 From: lianlonggang Date: Sun, 10 May 2026 03:54:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(watch):=20=E4=B8=8A=E7=BA=BF=E4=BF=AE?= =?UTF-8?q?=E5=A4=8DBUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../watch/manager/WatchCloudManager.java | 13 +++++++-- .../watch/mapper/xml/WatchDataMapper.xml | 14 ++++----- .../com/renkang/watch/task/PostProcessor.java | 15 +++++++++- .../mapper/xml/HealthUserEmployeeExMapper.xml | 29 +++++++++---------- 4 files changed, 44 insertions(+), 27 deletions(-) diff --git a/health-watch/health-watch-biz/src/main/java/com/renkang/watch/manager/WatchCloudManager.java b/health-watch/health-watch-biz/src/main/java/com/renkang/watch/manager/WatchCloudManager.java index 189b2f7..5eb2825 100644 --- a/health-watch/health-watch-biz/src/main/java/com/renkang/watch/manager/WatchCloudManager.java +++ b/health-watch/health-watch-biz/src/main/java/com/renkang/watch/manager/WatchCloudManager.java @@ -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> 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 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()); } diff --git a/health-watch/health-watch-biz/src/main/java/com/renkang/watch/mapper/xml/WatchDataMapper.xml b/health-watch/health-watch-biz/src/main/java/com/renkang/watch/mapper/xml/WatchDataMapper.xml index 694e819..042a066 100644 --- a/health-watch/health-watch-biz/src/main/java/com/renkang/watch/mapper/xml/WatchDataMapper.xml +++ b/health-watch/health-watch-biz/src/main/java/com/renkang/watch/mapper/xml/WatchDataMapper.xml @@ -193,7 +193,7 @@ ) where rn = 1) where userid = #{userid,jdbcType=VARCHAR} and watch_no = #{watchNo,jdbcType=VARCHAR} - and "type" = 2; + and type = 2; @@ -226,7 +226,7 @@ ) where rn = 1) where userid = #{userid,jdbcType=VARCHAR} and watch_no = #{watchNo,jdbcType=VARCHAR} - and "type" = 3; + and type = 3; @@ -266,7 +266,7 @@ ) where ROWNUM = 1) where userid = #{userid,jdbcType=VARCHAR} and watch_no = #{watchNo,jdbcType=VARCHAR} - and "type" = 4; + and type = 4; @@ -299,7 +299,7 @@ ) where rn = 1) where userid = #{userid,jdbcType=VARCHAR} and watch_no = #{watchNo,jdbcType=VARCHAR} - and "type" = 5; + and type = 5; @@ -335,7 +335,7 @@ ) where rn = 1) where userid = #{userid,jdbcType=VARCHAR} and watch_no = #{watchNo,jdbcType=VARCHAR} - and "type" = 6; + and type = 6; @@ -371,7 +371,7 @@ ) where rn = 1) where userid = #{userid,jdbcType=VARCHAR} and watch_no = #{watchNo,jdbcType=VARCHAR} - and "type" = 7; + and type = 7; @@ -407,6 +407,6 @@ ) where rn = 1) where userid = #{userid,jdbcType=VARCHAR} and watch_no = #{watchNo,jdbcType=VARCHAR} - and "type" = 8; + and type = 8; diff --git a/health-watch/health-watch-biz/src/main/java/com/renkang/watch/task/PostProcessor.java b/health-watch/health-watch-biz/src/main/java/com/renkang/watch/task/PostProcessor.java index bc544e9..7f1736a 100644 --- a/health-watch/health-watch-biz/src/main/java/com/renkang/watch/task/PostProcessor.java +++ b/health-watch/health-watch-biz/src/main/java/com/renkang/watch/task/PostProcessor.java @@ -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 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> userBindWatch, BiConsumer updateLatest, BiConsumer updateStat) { Map userMap = getUserMap(userBindWatch); + log.info("[statCommon] userMap获取完成,共{}个用户,watchNo数量={}", userMap.size(), userBindWatch.size()); for (Map.Entry> entry : userBindWatch.entrySet()) { entry.getValue().values().stream().distinct().forEach(userId -> { LoginUser userInfo = userMap.get(userId); diff --git a/jeecg-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/HealthUserEmployeeExMapper.xml b/jeecg-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/HealthUserEmployeeExMapper.xml index 971fcd5..a616556 100644 --- a/jeecg-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/HealthUserEmployeeExMapper.xml +++ b/jeecg-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/mapper/xml/HealthUserEmployeeExMapper.xml @@ -1099,22 +1099,19 @@ - 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;