From f9926c8598425eb1c3747b63f9daae54588dbaf1 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 07 一月 2026 15:12:49 +0800
Subject: [PATCH] 海诊通AI对接,H5报告推送存储

---
 ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/H5AICallbackController.java |   75 ++++++++++++++++++++++++++++---------
 1 files changed, 56 insertions(+), 19 deletions(-)

diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/H5AICallbackController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/H5AICallbackController.java
index 1103ddf..9e8f4a6 100644
--- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/H5AICallbackController.java
+++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/H5AICallbackController.java
@@ -132,31 +132,67 @@
 
 
     @PostMapping("/xiMaReportPush")
-    public String xiMaReportPush(JSONObject jsonObject) throws Exception {
+    public JSONObject xiMaReportPush(JSONObject json) throws Exception {
         TSysAiConfig sysAiConfig = sysAiConfigService.getById(1);
         // 应用AES秘钥
         String clientKey = sysAiConfig.getClientKey();
         // 平台RSA公钥
         String clientIV = sysAiConfig.getClientIV();
 
-        String data = jsonObject.getString("data");
+        String data = json.getString("data");
         // 解密
         String raw = AesUtil.decrypt(clientKey, clientIV , data);
         log.info("H5舌面报告推送,解密后:{}",raw);
 
-        return "success";
+        JSONObject jsonObject = JSONObject.parseObject(raw);
+
+        // 报告信息
+        String reportTime = jsonObject.getString("reportTime"); // 报告时间
+        String reportH5Url = jsonObject.getString("reportH5Url"); // 报告H5地址URL
+
+        TSysInspection sysInspection = new TSysInspection();
+        sysInspection.setCheckTime(reportTime);
+        sysInspection.setReportPrintUrl(reportH5Url);
+
+        // 用户信息
+        JSONObject userInfo = jsonObject.getJSONObject("userInfo");
+        String outUserId = userInfo.getString("outUserId"); // 用户唯一标识
+        String birthday = userInfo.getString("birthday"); // 生日
+        String gender = userInfo.getString("gender"); // 用户性别:0男1女
+        String nickname = userInfo.getString("nickname"); // 用户姓名
+
+        // 查询用户
+        TSysAppUser sysAppUser = sysAppUserService.getOne(Wrappers.lambdaQuery(TSysAppUser.class)
+                .eq(TSysAppUser::getIdentifierNumber, outUserId)
+                .last("LIMIT 1"));
+        sysInspection.setAppUserId(sysAppUser.getId());
+        sysInspection.setOutUserId(outUserId);
+        sysInspection.setBirthday(birthday);
+        sysInspection.setSex("0".equals(gender)?1:2);
+        sysInspection.setNickName(nickname);
+        // 小程序检测
+        sysInspection.setInspectionType(2);
+
+        // TODO 舌诊信息
+
+
+        sysInspectionService.save(sysInspection);
+
+        JSONObject response = new JSONObject();
+        response.put("error_code",0);
+        return response;
     }
 
     @PostMapping("/xiMaDoubleScreenReportPush")
     public JSONObject xiMaDoubleScreenReportPush(JSONObject jsonObject) throws Exception {
         log.info("双屏仪报告推送:{}",jsonObject);
         // 主体信息
-        String reportTime = jsonObject.getString("report_time");
-        String report_print_url = jsonObject.getString("report_print_url");
-        String present_history = jsonObject.getString("present_history");
-        String tcm_syndrome = jsonObject.getString("tcm_syndrome");
-        String disease_history_memo = jsonObject.getString("disease_history_memo");
-        String western_medicine_diagnosis = jsonObject.getString("western_medicine_diagnosis");
+        String reportTime = jsonObject.getString("report_time"); // 报告时间
+        String report_print_url = jsonObject.getString("report_print_url"); // 报告H5页面地址
+        String present_history = jsonObject.getString("present_history"); // 患者现病史
+        String tcm_syndrome = jsonObject.getString("tcm_syndrome"); // 中医证型
+        String disease_history_memo = jsonObject.getString("disease_history_memo"); // 历史疾病补充
+        String western_medicine_diagnosis = jsonObject.getString("western_medicine_diagnosis"); // 西医诊断
 
         TSysInspection sysInspection = new TSysInspection();
         sysInspection.setCheckTime(reportTime);
@@ -168,12 +204,12 @@
 
         // 用户信息
         JSONObject userInfo = jsonObject.getJSONObject("user_info");
-        Long id = userInfo.getLong("id");
-        String phone = userInfo.getString("phone");
-        String user_name = userInfo.getString("user_name");
-        Long device_account_id = userInfo.getLong("device_account_id");
-        String sex = userInfo.getString("sex");
-        String age = userInfo.getString("age");
+        Long id = userInfo.getLong("id"); // 用户ID
+        String phone = userInfo.getString("phone"); // 手机号
+        String user_name = userInfo.getString("user_name"); // 用户姓名
+        Long device_account_id = userInfo.getLong("device_account_id"); // 设备账号ID
+        String sex = userInfo.getString("sex"); // 性别
+        String age = userInfo.getString("age"); // 年龄
 
         sysInspection.setThreeUserId(id);
         sysInspection.setPhone(phone);
@@ -181,6 +217,7 @@
         sysInspection.setSex("男".equals(sex) ? 1 : 2);
         sysInspection.setAge(Integer.parseInt(age));
         sysInspection.setDeviceAccountId(device_account_id);
+        // 硬件检测
         sysInspection.setInspectionType(3);
 
         // 通过手机号查询小程序用户
@@ -202,10 +239,10 @@
             JSONObject json = riskEstimate.getJSONObject(i);
             TSysInspectionRiskEstimate sysInspectionRiskEstimate = new TSysInspectionRiskEstimate();
             sysInspectionRiskEstimate.setInspectionId(sysInspection.getId());
-            String name = json.getString("name");
-            String link_url = json.getString("link_url");
-            String value = json.getString("value");
-            String value_desc = json.getString("value_desc");
+            String name = json.getString("name"); // 疾病名称
+            String link_url = json.getString("link_url"); // 疾病H5链接
+            String value = json.getString("value"); // 风险值
+            String value_desc = json.getString("value_desc"); // 风险值描述
             sysInspectionRiskEstimate.setRiskName(name);
             sysInspectionRiskEstimate.setRiskLinkUrl(link_url);
             sysInspectionRiskEstimate.setRiskValue(value);

--
Gitblit v1.7.1