From 31c39c5abf2c8eef557c13df8679dbcf1461f638 Mon Sep 17 00:00:00 2001 From: chenfei <18955928961@163.com> Date: Tue, 9 Aug 2022 18:02:19 +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=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=94=BE=E5=9C=A8=E4=B8=9A=E5=8A=A1=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/pc/TRecordController.java | 48 +-------------- .../ruoyi/system/service/ITRecordService.java | 3 + .../service/impl/TRecordServiceImpl.java | 61 ++++++++++++++++++- 3 files changed, 64 insertions(+), 48 deletions(-) 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 1aa767c..adfd3ac 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 @@ -127,52 +127,6 @@ public class TRecordController extends BaseController @GetMapping("getHistoryList") @ApiOperation("查询患者历史数据图表") public AjaxResult getHistoryList(TRecord tRecord){ - 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::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()); - 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)); - }); - recordHistoryDataResp.setShezhiList(shezhiList); - recordHistoryDataResp.setShetaiList(shetaiList); - recordHistoryDataResp.setShexiaList(shexiaList); - } - return recordHistoryDataResp; + return tRecordService.getHistoryList(tRecord); } } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITRecordService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITRecordService.java index 20a2387..5dbcc13 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ITRecordService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ITRecordService.java @@ -2,6 +2,7 @@ package com.ruoyi.system.service; import java.util.List; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.system.domain.TPatientHospitalDoctor; import com.ruoyi.system.domain.TRecord; import com.ruoyi.system.domain.req.TRecordResultReq; @@ -86,4 +87,6 @@ public interface ITRecordService * @return {@code List} */ public List queryRecordListByPHDids(TPatientHospitalDoctor tPatientHospitalDoctor); + + AjaxResult getHistoryList(TRecord tRecord); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java index 44d5ead..3e42c5d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TRecordServiceImpl.java @@ -1,10 +1,17 @@ package com.ruoyi.system.service.impl; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; + +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.domain.TPatientHospitalDoctor; import com.ruoyi.system.domain.req.TRecordResultReq; +import com.ruoyi.system.domain.resp.RecordHistoryDataResp; import com.ruoyi.system.domain.resp.TRecordResp; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.system.mapper.TRecordMapper; @@ -114,4 +121,56 @@ public class TRecordServiceImpl implements ITRecordService { return tRecordMapper.queryRecordListByPHDids(tPatientHospitalDoctor); } + + @Override + public AjaxResult getHistoryList(TRecord tRecord) + { + List tRecords = tRecordMapper.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::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()); + 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)); + }); + recordHistoryDataResp.setShezhiList(shezhiList); + recordHistoryDataResp.setShetaiList(shetaiList); + recordHistoryDataResp.setShexiaList(shexiaList); + } + return recordHistoryDataResp; + } }