|
|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.etotem.cfc.dto.CfBalanceView;
|
|
|
import com.etotem.cfc.dto.EnergySandboxDTO;
|
|
|
import com.etotem.cfc.dto.MemberEnergyDTO;
|
|
|
+import com.etotem.cfc.dto.DimensionNode;
|
|
|
import com.etotem.cfc.entity.*;
|
|
|
import com.etotem.cfc.mapper.*;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
@@ -93,6 +94,10 @@ public class EnergyService {
|
|
|
@Resource
|
|
|
private FamilyMetricAggConfigMapper familyMetricAggConfigMapper;
|
|
|
|
|
|
+ /** 统一维度注册中心:五维根节点五行归属(wuxing_rule_ref)的权威来源 */
|
|
|
+ @Resource
|
|
|
+ private DimensionRegistryService dimensionRegistryService;
|
|
|
+
|
|
|
/**
|
|
|
* 计算整个家庭的能量沙盘数据
|
|
|
*
|
|
|
@@ -2279,10 +2284,53 @@ public class EnergyService {
|
|
|
new LambdaQueryWrapper<EnergyDimension>()
|
|
|
.orderByAsc(EnergyDimension::getSortOrder)
|
|
|
);
|
|
|
+ // 统一维度体系:五维五行归属改以注册中心为准(root 节点 wuxing_rule_ref,与旧
|
|
|
+ // energy_dimension.element 同值,迁移448 已对齐)。注册中心未就绪或维度缺失时
|
|
|
+ // 保留旧表值,保证五行回归结果不变、返回结构不变。
|
|
|
+ enrichWuxingElementFromRegistry(dimCache);
|
|
|
}
|
|
|
return dimCache;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 统一维度体系:按注册中心 5 根节点的 wuxing_rule_ref 覆盖五行元素归属(element)。
|
|
|
+ *
|
|
|
+ * <p>维度 code(body/mind/wisdom/action/wealth)与统一 5 根同码,无需 alias 翻译;
|
|
|
+ * id/name/icon/sortOrder/status 仍以 energy_dimension 表为准(energy_log/energy_balance
|
|
|
+ * 以 dimension_id 关联该表 id,切换仅限五行归属来源,保证回归不变)。</p>
|
|
|
+ *
|
|
|
+ * @param dims 已加载的旧表维度列表(就地更新 element)
|
|
|
+ */
|
|
|
+ private void enrichWuxingElementFromRegistry(List<EnergyDimension> dims) {
|
|
|
+ if (dims == null || dims.isEmpty() || dimensionRegistryService == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ List<DimensionNode> roots = dimensionRegistryService.getRoots();
|
|
|
+ if (roots == null || roots.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Map<String, String> elementByCode = new HashMap<>();
|
|
|
+ for (DimensionNode root : roots) {
|
|
|
+ if (root == null || root.getCode() == null || root.getWuxingRuleRef() == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ elementByCode.put(root.getCode(), root.getWuxingRuleRef());
|
|
|
+ }
|
|
|
+ for (EnergyDimension d : dims) {
|
|
|
+ if (d == null || d.getCode() == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String element = elementByCode.get(d.getCode());
|
|
|
+ if (element != null) {
|
|
|
+ d.setElement(element);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.warn("EnergyService.enrichWuxingElementFromRegistry: 注册中心五行归属补齐失败(忽略): {}", e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 按code查维度
|
|
|
*/
|