|
|
@@ -185,14 +185,14 @@ public class HealthReportService {
|
|
|
// 所有报告都没有总分时,取子分值的加权平均
|
|
|
int totalWeight = 0;
|
|
|
int weightedSum = 0;
|
|
|
- for (HealthReport r : reports) {
|
|
|
- int weight = 1; // 默认权重
|
|
|
- // 越新的报告权重越高
|
|
|
+ int reportCount = reports.size();
|
|
|
+ for (int i = 0; i < reportCount; i++) {
|
|
|
+ HealthReport r = reports.get(i);
|
|
|
+ int weight = reportCount - i;
|
|
|
if (r.getOverallScore() != null) {
|
|
|
weightedSum += r.getOverallScore() * weight;
|
|
|
totalWeight += weight;
|
|
|
}
|
|
|
- // 也可以综合子项
|
|
|
if (r.getGutHealthScore() != null) {
|
|
|
weightedSum += r.getGutHealthScore() * weight;
|
|
|
totalWeight += weight;
|
|
|
@@ -730,6 +730,48 @@ public class HealthReportService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ public com.baomidou.mybatisplus.extension.plugins.pagination.Page<Map<String, Object>> listAllReportsForAdmin(int page, int size) {
|
|
|
+ com.baomidou.mybatisplus.extension.plugins.pagination.Page<HealthReport> p =
|
|
|
+ new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size);
|
|
|
+ LambdaQueryWrapper<HealthReport> wrapper = new LambdaQueryWrapper<HealthReport>()
|
|
|
+ .eq(HealthReport::getStatus, "active")
|
|
|
+ .orderByDesc(HealthReport::getReportDate);
|
|
|
+ p = healthReportMapper.selectPage(p, wrapper);
|
|
|
+
|
|
|
+ List<Map<String, Object>> records = new ArrayList<>();
|
|
|
+ for (HealthReport r : p.getRecords()) {
|
|
|
+ Map<String, Object> m = new HashMap<>();
|
|
|
+ m.put("id", r.getId());
|
|
|
+ m.put("reportType", r.getReportType());
|
|
|
+ m.put("overallScore", r.getOverallScore());
|
|
|
+ m.put("gutHealthScore", r.getGutHealthScore());
|
|
|
+ m.put("nutritionScore", r.getNutritionScore());
|
|
|
+ m.put("reportDate", r.getReportDate());
|
|
|
+ m.put("personName", r.getPersonName());
|
|
|
+ m.put("fileUrl", r.getFileUrl());
|
|
|
+ m.put("gutAge", r.getGutAge());
|
|
|
+ m.put("gutType", r.getGutType());
|
|
|
+ Long subjectId = r.getSubjectId() != null ? r.getSubjectId() : r.getUserId();
|
|
|
+ if (subjectId != null) {
|
|
|
+ User user = userMapper.selectById(subjectId);
|
|
|
+ if (user != null) {
|
|
|
+ m.put("childName", user.getRealName() != null ? user.getRealName() : user.getNickname());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (m.get("childName") == null) {
|
|
|
+ m.put("childName", r.getPersonName());
|
|
|
+ }
|
|
|
+ records.add(m);
|
|
|
+ }
|
|
|
+
|
|
|
+ com.baomidou.mybatisplus.extension.plugins.pagination.Page<Map<String, Object>> result =
|
|
|
+ new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page, size);
|
|
|
+ result.setRecords(records);
|
|
|
+ result.setTotal(p.getTotal());
|
|
|
+ result.setPages(p.getPages());
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
public HealthReport getReportById(Long reportId) {
|
|
|
return healthReportMapper.selectById(reportId);
|
|
|
}
|