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 5931581..0f43d2e 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,10 +1,13 @@ package com.ruoyi.web.controller.pc; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.TImage; import com.ruoyi.system.domain.TRecord; @@ -15,6 +18,7 @@ import com.ruoyi.system.service.ITImageService; import com.ruoyi.system.service.ITRecordService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.CollectionUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -66,6 +70,42 @@ public class TRecordController extends BaseController { startPage(); List list = tRecordService.selectTRecordListWithoutResult(tRecord); + if(CollectionUtils.isNotEmpty(list)){ + list.stream().forEach(tRecordResp -> { + StringBuilder updateResult2 = new StringBuilder(); + if(StringUtils.isNotEmpty(tRecordResp.getUpdateResult2()) + && null != JSON.parseObject(tRecordResp.getUpdateResult2())){ + typeAppend(tRecordResp.getUpdateResult2(),updateResult2); + } + if(updateResult2.length() != 0){ + tRecordResp.setUpdateResult2(updateResult2.toString()); + } + StringBuilder updateResult = new StringBuilder(); + if(StringUtils.isNotEmpty(tRecordResp.getUpdateResult()) + && null != JSON.parseObject(tRecordResp.getUpdateResult())){ + typeAppend(tRecordResp.getUpdateResult(),updateResult); + } + if(updateResult.length() != 0){ + tRecordResp.setUpdateResult(updateResult.toString()); + } + StringBuilder aiResult2 = new StringBuilder(); + if(StringUtils.isNotEmpty(tRecordResp.getAiResult2()) + && null != JSON.parseObject(tRecordResp.getAiResult2())){ + typeAppend(tRecordResp.getAiResult2(),aiResult2); + } + if(aiResult2.length() != 0){ + tRecordResp.setAiResult2(aiResult2.toString()); + } + StringBuilder aiResult = new StringBuilder(); + if(StringUtils.isNotEmpty(tRecordResp.getAiResult()) + && null != JSON.parseObject(tRecordResp.getAiResult())){ + typeAppend(tRecordResp.getAiResult(),aiResult); + } + if(aiResult.length() != 0){ + tRecordResp.setAiResult(aiResult.toString()); + } + }); + } ExcelUtil util = new ExcelUtil<>(TRecordResp.class); util.exportExcel(response, list, "诊断记录信息数据"); } @@ -165,4 +205,213 @@ public class TRecordController extends BaseController BeanUtils.copyProperties(appRecordReq, tRecord); return AjaxResult.success(tRecordService.updateTRecord(tRecord)); } + + public void typeAppend(String type,StringBuilder resultBuilder){ + //获取json字符data中的数据 + String dataString = JSON.parseObject(type).getString("data"); + if(StringUtils.isNotEmpty(dataString) && null != JSON.parseObject(dataString)){ + JSONObject dataObject = JSON.parseObject(dataString); + //如果包含舌质 + if(StringUtils.isNotEmpty(dataObject.getString("shezhi")) + && null != JSON.parseObject(dataObject.getString("shezhi"))){ + resultBuilder.append("舌质"); + resultAppend(dataObject.getString("shezhi"),resultBuilder); + JSONObject shezhiObject = JSON.parseObject(dataObject.getString("shezhi")); + if(StringUtils.isNotEmpty(shezhiObject.getString("sz_color")) + && null != JSON.parseObject(shezhiObject.getString("sz_color"))){ + resultAppend(shezhiObject.getString("sz_color"),resultBuilder); + } + if(StringUtils.isNotEmpty(shezhiObject.getString("sz_yuban")) + && null != JSON.parseObject(shezhiObject.getString("sz_yuban"))){ + resultAppend(shezhiObject.getString("sz_yuban"),resultBuilder); + } + if(StringUtils.isNotEmpty(shezhiObject.getString("sz_yudian")) + && null != JSON.parseObject(shezhiObject.getString("sz_yudian"))){ + resultAppend(shezhiObject.getString("sz_yudian"),resultBuilder); + } + if(StringUtils.isNotEmpty(shezhiObject.getString("sz_liewen")) + && null != JSON.parseObject(shezhiObject.getString("sz_liewen"))){ + resultAppend(shezhiObject.getString("sz_liewen"),resultBuilder); + } + } + //如果包含舌苔 + if(StringUtils.isNotEmpty(dataObject.getString("shetai")) + && null != JSON.parseObject(dataObject.getString("shetai"))){ + resultBuilder.append("\n舌苔"); + JSONObject shetaiObject = JSON.parseObject(dataObject.getString("shetai")); + if(StringUtils.isNotEmpty(shetaiObject.getString("st_color")) + && null != JSON.parseObject(shetaiObject.getString("st_color"))){ + resultAppend(shetaiObject.getString("st_color"),resultBuilder); + } + resultAppend(dataObject.getString("shetai"),resultBuilder); + } + //如果包含舌下脉络 + if(StringUtils.isNotEmpty(dataObject.getString("shexia")) + && null != JSON.parseObject(dataObject.getString("shexia"))){ + resultBuilder.append("\n舌下脉络"); + JSONObject shexiaObject = JSON.parseObject(dataObject.getString("shexia")); + if(StringUtils.isNotEmpty(shexiaObject.getString("sx_vein_color")) + && null != JSON.parseObject(shexiaObject.getString("sx_vein_color"))){ + resultAppend(shexiaObject.getString("sx_vein_color"),resultBuilder); + } + resultAppend(dataObject.getString("shexia"),resultBuilder); + } + } + } + + /** + * 组装诊断结果 + * @param type + * @param resultBuilder + */ + public void resultAppend(String type,StringBuilder resultBuilder){ + JSONObject typeObject = JSON.parseObject(type); + if(StringUtils.isNotEmpty(typeObject.getString("sz_tip")) + && null != JSON.parseObject(typeObject.getString("sz_tip"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_tip")); + resultBuilder.append("\n舌尖红:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_laonen")) + && null != JSON.parseObject(typeObject.getString("sz_laonen"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_laonen")); + resultBuilder.append("\n舌质老嫩:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_chihen")) + && null != JSON.parseObject(typeObject.getString("sz_chihen"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_chihen")); + resultBuilder.append("\n舌质齿痕:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_color2")) + && null != JSON.parseObject(typeObject.getString("sz_color2"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_color2")); + resultBuilder.append("\n舌质颜色:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_color2")) + && null != JSON.parseObject(typeObject.getString("st_color2"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_color2")); + resultBuilder.append("\n舌苔颜色:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_avg_red")) + && null != JSON.parseObject(typeObject.getString("sz_avg_red")) + && StringUtils.isNotEmpty(JSON.parseObject(typeObject.getString("sz_avg_red")).getString("v"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_avg_red")); + resultBuilder.append("\n红度平均值:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_avg_purple")) + && null != JSON.parseObject(typeObject.getString("sz_avg_purple")) + && StringUtils.isNotEmpty(JSON.parseObject(typeObject.getString("sz_avg_purple")).getString("v"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_avg_purple")); + resultBuilder.append("\n紫度平均值:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_pangshou")) + && null != JSON.parseObject(typeObject.getString("sz_pangshou"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_pangshou")); + resultBuilder.append("\n舌质胖瘦:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_pangshou")) + && null != JSON.parseObject(typeObject.getString("sz_pangshou"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_pangshou")); + resultBuilder.append("\n胖度值:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_yuban_area")) + && null != JSON.parseObject(typeObject.getString("sz_yuban_area"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_yuban_area")); + resultBuilder.append("\n瘀斑面积:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_yudian_area")) + && null != JSON.parseObject(typeObject.getString("sz_yudian_area"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_yudian_area")); + resultBuilder.append("\n瘀点面积:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_yudian_num")) + && null != JSON.parseObject(typeObject.getString("sz_yudian_num"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_yudian_num")); + resultBuilder.append("\n瘀点个数:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sz_is_liewen")) + && null != JSON.parseObject(typeObject.getString("sz_is_liewen"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sz_is_liewen")); + resultBuilder.append("\n舌质裂纹:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_boluo")) + && null != JSON.parseObject(typeObject.getString("st_boluo"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_boluo")); + resultBuilder.append("\n剥落苔:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_area")) + && null != JSON.parseObject(typeObject.getString("st_area"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_area")); + resultBuilder.append("\n舌苔面积:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_houbo")) + && null != JSON.parseObject(typeObject.getString("st_houbo"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_houbo")); + resultBuilder.append("\n舌苔厚薄:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_houbo")) + && null != JSON.parseObject(typeObject.getString("st_houbo"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_houbo")); + resultBuilder.append("\n厚度值:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_funi")) + && null != JSON.parseObject(typeObject.getString("st_funi"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_funi")); + resultBuilder.append("\n舌苔腐腻:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_funi")) + && null != JSON.parseObject(typeObject.getString("st_funi"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_funi")); + resultBuilder.append("\n腐腻值:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_runzao")) + && null != JSON.parseObject(typeObject.getString("st_runzao"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_runzao")); + resultBuilder.append("\n舌苔润燥:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_runzao")) + && null != JSON.parseObject(typeObject.getString("st_runzao"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_runzao")); + resultBuilder.append("\n润度值:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_cao")) + && null != JSON.parseObject(typeObject.getString("st_cao"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_cao")); + resultBuilder.append("\n糙苔:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_cao")) + && null != JSON.parseObject(typeObject.getString("st_cao"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_cao")); + resultBuilder.append("\n糙度值:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("st_avg_yellow")) + && null != JSON.parseObject(typeObject.getString("st_avg_yellow"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("st_avg_yellow")); + resultBuilder.append("\n黄度平均值:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_width")) + && null != JSON.parseObject(typeObject.getString("sx_vein_width"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sx_vein_width")); + resultBuilder.append("\n脉络粗细:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_length")) + && null != JSON.parseObject(typeObject.getString("sx_vein_length"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sx_vein_length")); + resultBuilder.append("\n脉络长度:"+(StringUtils.isNotEmpty(valObject.getString("quantification")) ? valObject.getString("quantification") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_type")) + && null != JSON.parseObject(typeObject.getString("sx_vein_type"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sx_vein_type")); + resultBuilder.append("\n脉络形态:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_color2")) + && null != JSON.parseObject(typeObject.getString("sx_vein_color2"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sx_vein_color2")); + resultBuilder.append("\n脉络颜色:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + if(StringUtils.isNotEmpty(typeObject.getString("sx_vein_avg_purple")) + && null != JSON.parseObject(typeObject.getString("sx_vein_avg_purple"))){ + JSONObject valObject = JSON.parseObject(typeObject.getString("sx_vein_avg_purple")); + resultBuilder.append("\n紫度平均值:"+(StringUtils.isNotEmpty(valObject.getString("v")) ? valObject.getString("v") : "")); + } + } } diff --git a/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml b/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml index b09b7c9..5ca839b 100644 --- a/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/TRecordMapper.xml @@ -81,6 +81,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" tr.STATUS, tr.ai_result AS aiResult, tr.ai_result2 AS aiResult2, + tr.update_result as updateResult, tr.update_result2 AS updateResult2, tr.update_time AS updateTime, tr.upload_time AS uploadTime,