ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
@@ -542,8 +542,12 @@ * @param dataClazz 数据对象的Class */ @SuppressWarnings("unchecked") public void writeAdditionalSheet(List<?> dataList, String sheetName, Class<?> dataClazz) { if (dataList == null) { dataList = new ArrayList<>(); public void writeAdditionalSheet(List<?> dataList, String sheetName, Class<?> dataClazz) { // 没有数据或没有行类型时跳过附加 Sheet: // SatisfactionExportBundle.empty() 的 rowClass 为 null,若继续执行会把 this.clazz 置空, // 随后 getFields() 调用 clazz.getSuperclass() 触发 NullPointerException。 if (dataClazz == null || dataList == null || dataList.isEmpty()) { return; } // 保存原始状态 Class<T> originClazz = this.clazz; @@ -1341,6 +1345,11 @@ */ public List<Object[]> getFields() { List<Object[]> fields = new ArrayList<Object[]>(); // 防御:clazz 为空时不再调用 getSuperclass(),避免 NullPointerException。 if (clazz == null) { log.warn("ExcelUtil.clazz 为空,无法解析导出字段,跳过当前 Sheet"); return fields; } List<Field> tempFields = new ArrayList<>(); tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); ruoyi-task/src/main/java/com/ruoyi/task/controller/ServiceSubtaskController.java
@@ -1313,10 +1313,12 @@ Boolean redisFlag = false; if (MapUtils.isNotEmpty(redisMap)) { long tCmp = System.currentTimeMillis(); ServiceSubtaskEntity oldCondition = (ServiceSubtaskEntity) redisMap.get("searchCondition"); ServiceSubtaskEntity oldCondition = convertCachedCondition(redisMap.get("searchCondition")); if (ObjectUtils.isNotEmpty(oldCondition) && isSameCondition(oldCondition, serviceSubtaskEntity)) { redisFlag = true; map = redisMap; // 顺手回填转换后的实体,让这条缓存下次能以正确类型反序列化 map.put("searchCondition", oldCondition); redisCache.setCacheObject(userId + "patItemCount", map, 60, TimeUnit.MINUTES); } log.info("[patItem耗时] 4.2 条件比对={}ms,命中={}", System.currentTimeMillis() - tCmp, redisFlag); @@ -1336,6 +1338,36 @@ return map; } /** * 把 Redis 缓存里的查询条件还原成 {@link ServiceSubtaskEntity}。 * <p> * 缓存由 {@code FastJson2JsonRedisSerializer} 按 {@code Object.class} 反序列化: * 当 {@code searchCondition} 的 {@code @type} 缺失、或指向已迁移的旧包名 * (如 {@code com.smartor.domain.entity.ServiceSubtaskEntity})时,fastjson2 会 * 静默退化成 {@link com.alibaba.fastjson2.JSONObject},直接强转会抛 * {@code ClassCastException}。这里统一转换;转换失败返回 {@code null}, * 调用方按缓存未命中处理(重新查库),避免整个接口 500。 */ private ServiceSubtaskEntity convertCachedCondition(Object cachedCondition) { if (cachedCondition == null) { return null; } if (cachedCondition instanceof ServiceSubtaskEntity) { return (ServiceSubtaskEntity) cachedCondition; } try { // 不能直接用 TypeUtils.cast / toJavaObject:旧缓存里的 @type 可能指向已迁移的类, // fastjson2 会按 @type 去找类并抛 "No suitable ObjectReader found"。 // 转成 JSON 字符串后按目标类解析,未开启 SupportAutoType 时 @type 只会被当作普通字段忽略。 return com.alibaba.fastjson2.JSON.parseObject( com.alibaba.fastjson2.JSON.toJSONString(cachedCondition), ServiceSubtaskEntity.class); } catch (Exception e) { log.warn("【patItemCount】缓存中的查询条件无法还原为 ServiceSubtaskEntity,按缓存未命中处理,实际类型:{}", cachedCondition.getClass().getName(), e); return null; } } /** * 比较两个ServiceSubtaskVO的查询条件是否一致 ruoyi-task/src/main/java/com/ruoyi/task/service/impl/ServiceSubtaskServiceImpl.java
@@ -2459,7 +2459,10 @@ if (serviceSubtaskCountReq.getDrcode() != null && !serviceSubtaskCountReq.getDrcode().isEmpty()) { groupKey = drcode; } else { groupKey = "deptcode"; // 2026-11 字段重命名后:deptcode 是在院科室(历史数据为空), // 出院科室已改名为 leaveldeptcode,分组必须用后者, // 否则 getSfStatisticsGroupKey 会返回 NULL,拼成 IN (NULL) 导致整表查空。 groupKey = "leaveldeptcode"; } } else if (serviceSubtaskCountReq.getStatisticaltype() != null && serviceSubtaskCountReq.getStatisticaltype() == 3) { // 病种统计:按任务ID分组,每个任务即一个病种随访任务 @@ -2470,6 +2473,17 @@ Map<String, List<ServiceSubtask>> collect = new HashMap<>(); serviceSubtaskCountReq.setGroupKey(groupKey); List<String> groupKeyList = serviceSubtaskMapper.getSfStatisticsGroupKey(serviceSubtaskCountReq); /* * 分组键可能为 NULL(历史数据、或重命名后尚未回填的在院维度列), * 直接拼进 SQL 会变成 `AND IFNULL(列,'Unknown') IN (NULL)`,恒不成立,整张统计表为空。 * 这里统一成 'Unknown',与聚合 SQL 的 IFNULL(列,'Unknown') 口径对齐。 */ if (groupKeyList != null) { groupKeyList = groupKeyList.stream() .map(key -> key == null ? "Unknown" : key) .distinct() .collect(Collectors.toList()); } serviceSubtaskCountReq.setGroupKeyList(groupKeyList); List<ServiceSubtask> rawData = serviceSubtaskMapper.getSfStatistics(serviceSubtaskCountReq); switch (groupKey) { @@ -2484,6 +2498,7 @@ collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getManagementDoctorCode()).orElse("Unknown"))); break; case "deptcode": case "leaveldeptcode": collect = rawData.stream().collect(Collectors.groupingBy(subtask -> Optional.ofNullable(subtask.getLeaveldeptcode()).orElse("Unknown"))); break; case "leavehospitaldistrictcode": smartor/src/main/java/com/smartor/message/LishuiMessageConfigProviderImpl.java
@@ -1,5 +1,6 @@ package com.smartor.message; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.message.sms.provider.ls.LishuiMessageConfig; @@ -36,6 +37,12 @@ */ private static final String CONFIG_KEY = "ls.msg.info"; private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper(); private static final TypeReference<Map<String, String>> MSG_INFO_TYPE = new TypeReference<Map<String, String>>() { }; private final ISysConfigService configService; public LishuiMessageConfigProviderImpl(ISysConfigService configService) { @@ -60,7 +67,7 @@ Map<String, String> msgInfo = new HashMap<>(); if (StringUtils.isNotEmpty(configValue)) { try { msgInfo = new ObjectMapper().readValue(configValue, Map.class); msgInfo = OBJECT_MAPPER.readValue(configValue, MSG_INFO_TYPE); } catch (Exception e) { log.error("【LishuiMessageConfigProviderImpl】解析 {} 失败,orgid:{},value:{},err:{}", CONFIG_KEY, orgid, configValue, e.getMessage(), e);