获取患者历史数据图表

master
chenfei 2 years ago
parent d1084fabe5
commit b04b2f7826

@ -1,13 +1,19 @@
package com.ruoyi.web.controller.pc; package com.ruoyi.web.controller.pc;
import java.util.List; import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.ruoyi.system.domain.TPatientHospitalDoctor; import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.domain.req.TRecordResultReq; import com.ruoyi.system.domain.req.TRecordResultReq;
import com.ruoyi.system.domain.resp.RecordHistoryDataResp;
import com.ruoyi.system.domain.resp.TRecordResp; import com.ruoyi.system.domain.resp.TRecordResp;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@ -121,6 +127,54 @@ public class TRecordController extends BaseController
@GetMapping("getHistoryList") @GetMapping("getHistoryList")
@ApiOperation("查询患者历史数据图表") @ApiOperation("查询患者历史数据图表")
public AjaxResult getHistoryList(TRecord tRecord){ public AjaxResult getHistoryList(TRecord tRecord){
return null; List<TRecord> tRecords = tRecordService.selectTRecordList(tRecord);
tRecords.removeIf(o->"0".equals(o.getStatus()));
if (CollectionUtils.isEmpty(tRecords)){
return AjaxResult.success();
}
List<TRecord> records = tRecords.stream().sorted(Comparator.comparing(TRecord::getCreateTime)).collect(Collectors.toList());
List<String> jsonKeyList = new ArrayList<String>(){{
add("shemian-sz_avg_red");
add("st_avg_yellow");
add("sx_vein_color");
}};
RecordHistoryDataResp recordHistoryDataRespMap = getDataList(records,jsonKeyList);
return AjaxResult.success(recordHistoryDataRespMap);
}
private RecordHistoryDataResp getDataList(List<TRecord> records, List<String> jsonKeyList)
{
RecordHistoryDataResp recordHistoryDataResp = new RecordHistoryDataResp();
List<String> dateList = records.stream().map(tRecord -> DateUtils.parseDateToStr("dd/MM/yyyy",tRecord.getCreateTime())).collect(Collectors.toList());
recordHistoryDataResp.setDateList(dateList);
List<JSONObject> result = records.stream().map(tRecord -> {
JSONObject jsonObject;
if(StringUtils.isEmpty(tRecord.getUpdateResult2())){
jsonObject = JSONObject.parseObject(tRecord.getAiResult2());
}else {
jsonObject = JSONObject.parseObject(tRecord.getUpdateResult2());
}
return jsonObject;
}).collect(Collectors.toList());
Map<String,List<Integer>> dataMap = new HashMap<>();
if (!CollectionUtils.isEmpty(result)){
List<Integer> shezhiList = new LinkedList<>();
List<Integer> shetaiList = new LinkedList<>();
List<Integer> shexiaList = new LinkedList<>();
String[] keys0 = jsonKeyList.get(0).split("-");
String key1 = jsonKeyList.get(1);
String key2 = jsonKeyList.get(2);
result.forEach(jsonObject -> {
shezhiList.add(jsonObject.getJSONObject("data").getJSONObject("shezhi").getJSONObject(keys0[0]).getInteger(keys0[1]));
shetaiList.add(jsonObject.getJSONObject("data").getJSONObject("shetai").getInteger(key1));
shexiaList.add(jsonObject.getJSONObject("data").getJSONObject("shexia").getInteger(key2));
});
dataMap.put("shezhi",shezhiList);
dataMap.put("shetai",shetaiList);
dataMap.put("shexia",shexiaList);
}
recordHistoryDataResp.setDataMap(dataMap);
return recordHistoryDataResp;
} }
} }

@ -0,0 +1,35 @@
package com.ruoyi.system.domain.resp;
import java.util.Date;
import java.util.List;
import java.util.Map;
public class RecordHistoryDataResp
{
private Map<String,List<Integer>> dataMap;
private List<String> dateList;
public RecordHistoryDataResp()
{
}
public Map<String, List<Integer>> getDataMap()
{
return dataMap;
}
public void setDataMap(Map<String, List<Integer>> dataMap)
{
this.dataMap = dataMap;
}
public List<String> getDateList()
{
return dateList;
}
public void setDateList(List<String> dateList)
{
this.dateList = dateList;
}
}

@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectTRecordVo"> <sql id="selectTRecordVo">
select id, patient_id, doctor_id, hospital_id, status, ai_result, ai_result2, update_result, update_result2, create_time, update_time, upload_time, img_sx, img_sm, response_time from t_record select id, patient_id, doctor_id, hospital_id, status,ai_result2,update_result2, create_time, update_time, upload_time,response_time from t_record
</sql> </sql>
<sql id="selectTRecordWithResult"> <sql id="selectTRecordWithResult">
SELECT SELECT
@ -155,6 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="imgSm != null and imgSm != ''"> and img_sm = #{imgSm}</if> <if test="imgSm != null and imgSm != ''"> and img_sm = #{imgSm}</if>
<if test="responseTime != null "> and response_time = #{responseTime}</if> <if test="responseTime != null "> and response_time = #{responseTime}</if>
</where> </where>
</select> </select>
<select id="selectTRecordListWithoutResult" parameterType="TRecordResultReq" resultType="TRecordResp"> <select id="selectTRecordListWithoutResult" parameterType="TRecordResultReq" resultType="TRecordResp">

Loading…
Cancel
Save