Fix Bug #566: AI修复
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.openhis.web.inpatient.mapper;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 住院体征数据 Mapper
|
||||
* 修复 Bug #566:确保查询结果按时间升序返回,且字段名与前端映射一致
|
||||
*/
|
||||
@Mapper
|
||||
public interface VitalSignsMapper {
|
||||
|
||||
@Select("SELECT id, patient_id, record_time, temperature, heart_rate, pulse, status " +
|
||||
"FROM his_vital_signs " +
|
||||
"WHERE patient_id = #{patientId} AND status = 1 " +
|
||||
"ORDER BY record_time ASC")
|
||||
List<Map<String, Object>> selectVitalSignsByPatient(@Param("patientId") Long patientId);
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.openhis.web.inpatient.service;
|
||||
|
||||
import com.openhis.web.inpatient.mapper.VitalSignsMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 住院体征服务实现
|
||||
* 修复 Bug #566:统一时间格式为 yyyy-MM-dd HH:mm,避免前端解析异常导致坐标映射失败
|
||||
*/
|
||||
@Service
|
||||
public class VitalSignsServiceImpl implements VitalSignsService {
|
||||
|
||||
private final VitalSignsMapper vitalSignsMapper;
|
||||
private static final DateTimeFormatter TIME_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
|
||||
public VitalSignsServiceImpl(VitalSignsMapper vitalSignsMapper) {
|
||||
this.vitalSignsMapper = vitalSignsMapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getVitalSignsData(Long patientId) {
|
||||
List<Map<String, Object>> records = vitalSignsMapper.selectVitalSignsByPatient(patientId);
|
||||
return records.stream().map(r -> {
|
||||
// 统一时间格式供前端直接作为 xAxis 分类
|
||||
if (r.get("record_time") != null) {
|
||||
r.put("timeStr", r.get("record_time").toString().replace("T", " ").substring(0, 16));
|
||||
r.put("recordTime", r.get("record_time"));
|
||||
}
|
||||
return r;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user