|
@@ -1,5 +1,7 @@
|
|
|
package com.etotem.cfc.service;
|
|
package com.etotem.cfc.service;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.etotem.cfc.dto.EmiReportDTO;
|
|
import com.etotem.cfc.dto.EmiReportDTO;
|
|
|
import com.etotem.cfc.entity.DanAssessmentResult;
|
|
import com.etotem.cfc.entity.DanAssessmentResult;
|
|
@@ -10,6 +12,7 @@ import org.springframework.stereotype.Service;
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
@@ -45,15 +48,90 @@ public class EmiReportService {
|
|
|
dto.setEmpathyScore(result.getEmpathyScore());
|
|
dto.setEmpathyScore(result.getEmpathyScore());
|
|
|
dto.setSocialAdaptabilityScore(result.getSocialAdaptabilityScore());
|
|
dto.setSocialAdaptabilityScore(result.getSocialAdaptabilityScore());
|
|
|
dto.setSelfMotivationScore(result.getSelfMotivationScore());
|
|
dto.setSelfMotivationScore(result.getSelfMotivationScore());
|
|
|
|
|
+ // 情绪稳定性 = 四个EMI子分均值
|
|
|
|
|
+ int eSum = safeScore(result.getEmotionScore()) + safeScore(result.getResilienceScore())
|
|
|
|
|
+ + safeScore(result.getStressCopingScore()) + safeScore(result.getSelfAwarenessScore());
|
|
|
|
|
+ dto.setEmotionStability(eSum / 4);
|
|
|
|
|
+ // 自驱力 + 自我概念 从 structuredAnalysis JSON 解析
|
|
|
|
|
+ Map<String, Object> analysis = parseStructuredAnalysis(result.getStructuredAnalysis());
|
|
|
|
|
+ if (analysis != null) {
|
|
|
|
|
+ Map<String, Object> extra = (Map<String, Object>) analysis.get("extra");
|
|
|
|
|
+ if (extra != null) {
|
|
|
|
|
+ // 自驱力三维度
|
|
|
|
|
+ Map<String, Object> sd = (Map<String, Object>) extra.get("selfDriving");
|
|
|
|
|
+ if (sd != null) {
|
|
|
|
|
+ dto.setDriveAutonomy(getInt(sd, "自主性", "selfDriving_autonomy"));
|
|
|
|
|
+ dto.setDriveCompetence(getInt(sd, "胜任感", "selfDriving_competence"));
|
|
|
|
|
+ dto.setDriveRelatedness(getInt(sd, "归属感", "selfDriving_relatedness"));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 综合自我概念
|
|
|
|
|
+ Map<String, Object> sc = (Map<String, Object>) extra.get("selfConcept");
|
|
|
|
|
+ if (sc != null && !sc.isEmpty()) {
|
|
|
|
|
+ int scSum = 0, scCount = 0;
|
|
|
|
|
+ for (Object v : sc.values()) {
|
|
|
|
|
+ Integer n = parseNumber(v);
|
|
|
|
|
+ if (n != null) { scSum += n; scCount++; }
|
|
|
|
|
+ }
|
|
|
|
|
+ dto.setSelfConceptOverall(scCount > 0 ? scSum / scCount : 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ dto.setAnalysisReport(result.getAnalysisReport());
|
|
|
|
|
+ dto.setGrowthSuggestions(result.getGrowthSuggestions());
|
|
|
|
|
+ dto.setAssessmentDate(result.getAssessmentDate());
|
|
|
|
|
+ return dto;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private EmiReportDTO toDTO(DanAssessmentResult result) {
|
|
|
|
|
+ EmiReportDTO dto = new EmiReportDTO();
|
|
|
|
|
+ dto.setMemberId(result.getChildId());
|
|
|
|
|
+ dto.setChildName(result.getChildName());
|
|
|
|
|
+ dto.setEmotionScore(result.getEmotionScore());
|
|
|
|
|
+ dto.setResilienceScore(result.getResilienceScore());
|
|
|
|
|
+ dto.setStressCopingScore(result.getStressCopingScore());
|
|
|
|
|
+ dto.setSelfAwarenessScore(result.getSelfAwarenessScore());
|
|
|
|
|
+ dto.setOpennessScore(result.getOpennessScore());
|
|
|
|
|
+ dto.setConscientiousnessScore(result.getConscientiousnessScore());
|
|
|
|
|
+ dto.setExtraversionScore(result.getExtraversionScore());
|
|
|
|
|
+ dto.setAgreeablenessScore(result.getAgreeablenessScore());
|
|
|
|
|
+ dto.setNeuroticismScore(result.getNeuroticismScore());
|
|
|
|
|
+ dto.setBigFiveOverallScore(result.getBigFiveOverallScore());
|
|
|
|
|
+ dto.setEmotionManagementScore(result.getEmotionManagementScore());
|
|
|
|
|
+ dto.setEmpathyScore(result.getEmpathyScore());
|
|
|
|
|
+ dto.setSocialAdaptabilityScore(result.getSocialAdaptabilityScore());
|
|
|
|
|
+ dto.setSelfMotivationScore(result.getSelfMotivationScore());
|
|
|
|
|
+ int eSum = safeScore(result.getEmotionScore()) + safeScore(result.getResilienceScore())
|
|
|
|
|
+ + safeScore(result.getStressCopingScore()) + safeScore(result.getSelfAwarenessScore());
|
|
|
|
|
+ dto.setEmotionStability(eSum / 4);
|
|
|
|
|
+ Map<String, Object> analysis = parseStructuredAnalysis(result.getStructuredAnalysis());
|
|
|
|
|
+ if (analysis != null) {
|
|
|
|
|
+ Map<String, Object> extra = (Map<String, Object>) analysis.get("extra");
|
|
|
|
|
+ if (extra != null) {
|
|
|
|
|
+ Map<String, Object> sd = (Map<String, Object>) extra.get("selfDriving");
|
|
|
|
|
+ if (sd != null) {
|
|
|
|
|
+ dto.setDriveAutonomy(getInt(sd, "自主性", "selfDriving_autonomy"));
|
|
|
|
|
+ dto.setDriveCompetence(getInt(sd, "胜任感", "selfDriving_competence"));
|
|
|
|
|
+ dto.setDriveRelatedness(getInt(sd, "归属感", "selfDriving_relatedness"));
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, Object> sc = (Map<String, Object>) extra.get("selfConcept");
|
|
|
|
|
+ if (sc != null && !sc.isEmpty()) {
|
|
|
|
|
+ int scSum = 0, scCount = 0;
|
|
|
|
|
+ for (Object v : sc.values()) {
|
|
|
|
|
+ Integer n = parseNumber(v);
|
|
|
|
|
+ if (n != null) { scSum += n; scCount++; }
|
|
|
|
|
+ }
|
|
|
|
|
+ dto.setSelfConceptOverall(scCount > 0 ? scSum / scCount : 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ dto.setOverallScore(result.getOverallScore());
|
|
|
dto.setAnalysisReport(result.getAnalysisReport());
|
|
dto.setAnalysisReport(result.getAnalysisReport());
|
|
|
dto.setGrowthSuggestions(result.getGrowthSuggestions());
|
|
dto.setGrowthSuggestions(result.getGrowthSuggestions());
|
|
|
dto.setAssessmentDate(result.getAssessmentDate());
|
|
dto.setAssessmentDate(result.getAssessmentDate());
|
|
|
return dto;
|
|
return dto;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 获取家庭所有孩子的最新EMI心理报告
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ /** 获取家庭所有孩子的最新EMI心理报告 */
|
|
|
public List<EmiReportDTO> getFamilyLatestEmiReports(List<Long> childIds) {
|
|
public List<EmiReportDTO> getFamilyLatestEmiReports(List<Long> childIds) {
|
|
|
if (childIds == null || childIds.isEmpty()) return new ArrayList<>();
|
|
if (childIds == null || childIds.isEmpty()) return new ArrayList<>();
|
|
|
LambdaQueryWrapper<DanAssessmentResult> wrapper = new LambdaQueryWrapper<DanAssessmentResult>()
|
|
LambdaQueryWrapper<DanAssessmentResult> wrapper = new LambdaQueryWrapper<DanAssessmentResult>()
|
|
@@ -63,27 +141,33 @@ public class EmiReportService {
|
|
|
List<DanAssessmentResult> results = danAssessmentResultMapper.selectList(wrapper);
|
|
List<DanAssessmentResult> results = danAssessmentResultMapper.selectList(wrapper);
|
|
|
List<EmiReportDTO> list = new ArrayList<>();
|
|
List<EmiReportDTO> list = new ArrayList<>();
|
|
|
for (DanAssessmentResult r : results) {
|
|
for (DanAssessmentResult r : results) {
|
|
|
- EmiReportDTO dto = new EmiReportDTO();
|
|
|
|
|
- dto.setMemberId(r.getChildId());
|
|
|
|
|
- dto.setChildName(r.getChildName());
|
|
|
|
|
- dto.setEmotionScore(r.getEmotionScore());
|
|
|
|
|
- dto.setResilienceScore(r.getResilienceScore());
|
|
|
|
|
- dto.setStressCopingScore(r.getStressCopingScore());
|
|
|
|
|
- dto.setSelfAwarenessScore(r.getSelfAwarenessScore());
|
|
|
|
|
- dto.setOpennessScore(r.getOpennessScore());
|
|
|
|
|
- dto.setConscientiousnessScore(r.getConscientiousnessScore());
|
|
|
|
|
- dto.setExtraversionScore(r.getExtraversionScore());
|
|
|
|
|
- dto.setAgreeablenessScore(r.getAgreeablenessScore());
|
|
|
|
|
- dto.setNeuroticismScore(r.getNeuroticismScore());
|
|
|
|
|
- dto.setBigFiveOverallScore(r.getBigFiveOverallScore());
|
|
|
|
|
- dto.setEmotionManagementScore(r.getEmotionManagementScore());
|
|
|
|
|
- dto.setEmpathyScore(r.getEmpathyScore());
|
|
|
|
|
- dto.setSocialAdaptabilityScore(r.getSocialAdaptabilityScore());
|
|
|
|
|
- dto.setSelfMotivationScore(r.getSelfMotivationScore());
|
|
|
|
|
- dto.setOverallScore(r.getOverallScore());
|
|
|
|
|
- dto.setAssessmentDate(r.getAssessmentDate());
|
|
|
|
|
- list.add(dto);
|
|
|
|
|
|
|
+ list.add(toDTO(r));
|
|
|
}
|
|
}
|
|
|
return list;
|
|
return list;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ private static int safeScore(Integer v) { return v != null && v > 0 ? v : 0; }
|
|
|
|
|
+
|
|
|
|
|
+ private static Integer getInt(Map<String, Object> map, String cnKey, String enKey) {
|
|
|
|
|
+ if (map == null) return null;
|
|
|
|
|
+ Object val = map.get(cnKey);
|
|
|
|
|
+ if (val == null) val = map.get(enKey);
|
|
|
|
|
+ return parseNumber(val);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Integer parseNumber(Object val) {
|
|
|
|
|
+ if (val == null) return null;
|
|
|
|
|
+ if (val instanceof Number) return ((Number) val).intValue();
|
|
|
|
|
+ if (val instanceof String) {
|
|
|
|
|
+ try { return Integer.parseInt(((String) val).trim()); }
|
|
|
|
|
+ catch (NumberFormatException e) { return null; }
|
|
|
|
|
+ }
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static Map<String, Object> parseStructuredAnalysis(String json) {
|
|
|
|
|
+ if (json == null || json.isEmpty()) return null;
|
|
|
|
|
+ try { return JSON.parseObject(json, Map.class); }
|
|
|
|
|
+ catch (Exception e) { return null; }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|