From b04b2f78269c7971a0352271f09f72e993c95bc2 Mon Sep 17 00:00:00 2001 From: chenfei <18955928961@163.com> Date: Tue, 9 Aug 2022 17:43:39 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=82=A3=E8=80=85=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E6=95=B0=E6=8D=AE=E5=9B=BE=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/pc/TRecordController.java | 60 ++++++++++++++++++- .../domain/resp/RecordHistoryDataResp.java | 35 +++++++++++ .../resources/mapper/system/TRecordMapper.xml | 3 +- 3 files changed, 94 insertions(+), 4 deletions(-) create mode 100644 ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/RecordHistoryDataResp.java diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java index e2b6e98..b7214fc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/pc/TRecordController.java @@ -1,13 +1,19 @@ 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 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.resp.RecordHistoryDataResp; import com.ruoyi.system.domain.resp.TRecordResp; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections.CollectionUtils; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -121,6 +127,54 @@ public class TRecordController extends BaseController @GetMapping("getHistoryList") @ApiOperation("查询患者历史数据图表") public AjaxResult getHistoryList(TRecord tRecord){ - return null; + List tRecords = tRecordService.selectTRecordList(tRecord); + tRecords.removeIf(o->"0".equals(o.getStatus())); + if (CollectionUtils.isEmpty(tRecords)){ + return AjaxResult.success(); + } + List records = tRecords.stream().sorted(Comparator.comparing(TRecord::getCreateTime)).collect(Collectors.toList()); + List jsonKeyList = new ArrayList(){{ + 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 records, List jsonKeyList) + { + + RecordHistoryDataResp recordHistoryDataResp = new RecordHistoryDataResp(); + List dateList = records.stream().map(tRecord -> DateUtils.parseDateToStr("dd/MM/yyyy",tRecord.getCreateTime())).collect(Collectors.toList()); + recordHistoryDataResp.setDateList(dateList); + List 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> dataMap = new HashMap<>(); + if (!CollectionUtils.isEmpty(result)){ + List shezhiList = new LinkedList<>(); + List shetaiList = new LinkedList<>(); + List 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; } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/RecordHistoryDataResp.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/RecordHistoryDataResp.java new file mode 100644 index 0000000..0d71885 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/resp/RecordHistoryDataResp.java @@ -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> dataMap; + private List dateList; + + public RecordHistoryDataResp() + { + } + + public Map> getDataMap() + { + return dataMap; + } + + public void setDataMap(Map> dataMap) + { + this.dataMap = dataMap; + } + + public List getDateList() + { + return dateList; + } + + public void setDateList(List dateList) + { + this.dateList = dateList; + } +} diff --git a/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml index 220e61d..db84bc0 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml @@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - 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 SELECT @@ -155,6 +155,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and img_sm = #{imgSm} and response_time = #{responseTime} +