|
|
@@ -5,42 +5,46 @@ import cn.hutool.http.HttpResponse;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
-import com.alibaba.fastjson2.JSON;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.therapi.runtimejavadoc.repack.com.eclipsesource.json.JsonObject;
|
|
|
-import com.inspur.device.domain.SmsbDeviceGroupRel;
|
|
|
-import com.inspur.device.domain.SmsbDifyDatasetsFile;
|
|
|
import com.inspur.device.domain.vo.SmsbDeviceChatKeyVo;
|
|
|
import com.inspur.device.domain.vo.SmsbDeviceGroupRelVo;
|
|
|
-import com.inspur.device.domain.vo.SmsbDeviceVo;
|
|
|
import com.inspur.device.domain.vo.SmsbDeviceXfApiVo;
|
|
|
import com.inspur.device.mapper.SmsbDeviceChatKeyMapper;
|
|
|
import com.inspur.device.mapper.SmsbDeviceGroupRelMapper;
|
|
|
import com.inspur.device.mapper.SmsbDeviceMapper;
|
|
|
import com.inspur.device.mapper.SmsbDeviceXfApiMapper;
|
|
|
+import com.inspur.digital.domain.SmsbAppointmentInfo;
|
|
|
+import com.inspur.digital.domain.SmsbDeviceChatScReport;
|
|
|
+import com.inspur.digital.domain.bo.SmsbAppointmentInfoBo;
|
|
|
import com.inspur.digital.domain.bo.SmsbStartInfoBo;
|
|
|
+import com.inspur.digital.domain.vo.SmsbAppointmentInfoVo;
|
|
|
import com.inspur.digital.domain.vo.SmsbStartInfoVo;
|
|
|
+import com.inspur.digital.mapper.SmsbAppointmentInfoMapper;
|
|
|
+import com.inspur.digital.mapper.SmsbDeviceChatScReportMapper;
|
|
|
+import com.inspur.digital.service.ISmsbAppointmentInfoService;
|
|
|
+import com.inspur.digital.util.DifyStreamUtil;
|
|
|
import com.inspur.digital.util.EncryptUtil;
|
|
|
-import com.inspur.digital.util.InteractionListParser;
|
|
|
-import com.inspur.digital.util.ReportMapParser;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
+import org.dromara.common.core.exception.ServiceException;
|
|
|
import org.dromara.common.core.utils.MapstructUtils;
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
-import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import lombok.RequiredArgsConstructor;
|
|
|
-import org.dromara.system.domain.vo.SysOssVo;
|
|
|
+import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.inspur.digital.domain.bo.SmsbAppointmentInfoBo;
|
|
|
-import com.inspur.digital.domain.vo.SmsbAppointmentInfoVo;
|
|
|
-import com.inspur.digital.domain.SmsbAppointmentInfo;
|
|
|
-import com.inspur.digital.mapper.SmsbAppointmentInfoMapper;
|
|
|
-import com.inspur.digital.service.ISmsbAppointmentInfoService;
|
|
|
|
|
|
-import java.io.File;
|
|
|
-import java.util.*;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Collection;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 预约信息Service业务层处理
|
|
|
@@ -50,6 +54,7 @@ import java.util.*;
|
|
|
*/
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class SmsbAppointmentInfoServiceImpl implements ISmsbAppointmentInfoService {
|
|
|
|
|
|
private final SmsbAppointmentInfoMapper baseMapper;
|
|
|
@@ -57,6 +62,24 @@ public class SmsbAppointmentInfoServiceImpl implements ISmsbAppointmentInfoServi
|
|
|
private final SmsbDeviceXfApiMapper xfApiMapper;
|
|
|
private final SmsbDeviceChatKeyMapper chatKeyMapper;
|
|
|
private final SmsbDeviceMapper deviceMapper;
|
|
|
+ private final SmsbDeviceChatScReportMapper smsbDeviceChatScReportMapper;
|
|
|
+ @Autowired
|
|
|
+ private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
|
|
+ @Value("${sc.api.url}")
|
|
|
+ private String scApiBaseUrl;
|
|
|
+ @Value("${sc.api.secretKey}")
|
|
|
+ private String scApiSecretKey;
|
|
|
+ @Value("${sc.api.publicKey}")
|
|
|
+ private String scApiPublicKey;
|
|
|
+ @Value("${sc.api.interfaceId}")
|
|
|
+ private String scApiInterfaceId;
|
|
|
+ @Value("${sc.api.appId}")
|
|
|
+ private String scApiAppId;
|
|
|
+ @Value("${dify.url}")
|
|
|
+ private String difyBaseUrl;
|
|
|
+
|
|
|
+ @Value("${dify.sc_agent.apiKey}")
|
|
|
+ private String difyScAgentApiKey;
|
|
|
|
|
|
/**
|
|
|
* 查询预约信息
|
|
|
@@ -65,7 +88,7 @@ public class SmsbAppointmentInfoServiceImpl implements ISmsbAppointmentInfoServi
|
|
|
* @return 预约信息
|
|
|
*/
|
|
|
@Override
|
|
|
- public SmsbAppointmentInfoVo queryById(Long id){
|
|
|
+ public SmsbAppointmentInfoVo queryById(Long id) {
|
|
|
return baseMapper.selectVoById(id);
|
|
|
}
|
|
|
|
|
|
@@ -111,99 +134,172 @@ public class SmsbAppointmentInfoServiceImpl implements ISmsbAppointmentInfoServi
|
|
|
return lqw;
|
|
|
}
|
|
|
|
|
|
- private String getAssessmentReport(String json) {
|
|
|
- JSONObject reportMap = JSONUtil.parseObj(json);
|
|
|
- if ("false".equalsIgnoreCase(reportMap.getStr("result", "false"))) {
|
|
|
- return null;
|
|
|
- }
|
|
|
- StringBuilder result = new StringBuilder("诊断等级:" + reportMap.getStr("rateName"));
|
|
|
- result.append("\n评估名称:").append(reportMap.getStr("estimateName"));
|
|
|
- result.append("\n测评名称:").append(reportMap.getStr("evaluationName"));
|
|
|
- result.append("\n企业名称:").append(reportMap.getStr("organizeName"));
|
|
|
- result.append("\n企业地市:").append(reportMap.getStr("organizeZone"));
|
|
|
- result.append("\n报告时间:").append(reportMap.getStr("commitTime"));
|
|
|
- result.append("\n测评得分:").append(reportMap.getStr("totalScore"));
|
|
|
- JSONObject reportContent = reportMap.getJSONObject("reportContent");
|
|
|
- result.append("\n当前分值:").append(reportContent.getStr("score"));
|
|
|
- JSONObject benchmarking = reportContent.getJSONObject("benchmarking");
|
|
|
- JSONObject totalCompare = benchmarking.getJSONObject("totalCompare");
|
|
|
- result.append("\n").append(totalCompare.getStr("name")).append(":");
|
|
|
- totalCompare.getJSONArray("childList").forEach(item -> {
|
|
|
- JSONObject child = JSONUtil.parseObj(item);
|
|
|
- result.append(child.getStr("name")).append(child.getStr("score")).append("家;");
|
|
|
- });
|
|
|
- JSONObject industryTotalCompare = benchmarking.getJSONObject("industryTotalCompare");
|
|
|
- result.append("\n").append(industryTotalCompare.getStr("name")).append(":");
|
|
|
- industryTotalCompare.getJSONArray("childList").forEach(item -> {
|
|
|
- JSONObject child = JSONUtil.parseObj(item);
|
|
|
- result.append(child.getStr("name")).append(child.getStr("score")).append("家;");
|
|
|
- });
|
|
|
- JSONObject industryScoreCompare = benchmarking.getJSONObject("industryScoreCompare");
|
|
|
- result.append("\n").append(industryScoreCompare.getStr("name")).append(":");
|
|
|
- result.append("分数为").append(industryScoreCompare.getStr("score")).append(";");
|
|
|
- industryScoreCompare.getJSONArray("childList").forEach(item -> {
|
|
|
- JSONObject child = JSONUtil.parseObj(item);
|
|
|
- result.append(child.getStr("name")).append(child.getStr("score")).append("家;");
|
|
|
- });
|
|
|
- reportContent.getJSONArray("barChartList").forEach(item -> {
|
|
|
- JSONObject barChart = JSONUtil.parseObj(item);
|
|
|
- result.append("\n").append(barChart.getStr("name")).append(":")
|
|
|
- .append("分数为").append(barChart.getStr("score")).append(",")
|
|
|
- .append("各家平均分为").append(barChart.getStr("avgScore")).append(";")
|
|
|
- .append("其中");
|
|
|
- barChart.getJSONArray("childList").forEach(childItem -> {
|
|
|
- JSONObject childChild = JSONUtil.parseObj(childItem);
|
|
|
- result.append(childChild.getStr("name"))
|
|
|
- .append("分数为").append(childChild.getStr("score")).append(",")
|
|
|
- .append("各家平均分为").append(childChild.getStr("avgScore")).append(";");
|
|
|
- });
|
|
|
- });
|
|
|
- JSONObject suggestion = reportContent.getJSONObject("suggestion");
|
|
|
- result.append("\n企业弱势:");
|
|
|
- if (!suggestion.getJSONArray("disadvantage").isEmpty()) {
|
|
|
- suggestion.getJSONArray("disadvantage").forEach(item -> {
|
|
|
- result.append(item).append(",");
|
|
|
- });
|
|
|
- result.deleteCharAt(result.length() - 1);
|
|
|
- }
|
|
|
- result.append(";\n企业优势:");
|
|
|
- if (!suggestion.getJSONArray("advantage").isEmpty()) {
|
|
|
- suggestion.getJSONArray("advantage").forEach(item -> {
|
|
|
- result.append(item).append(",");
|
|
|
- });
|
|
|
- result.deleteCharAt(result.length() - 1);
|
|
|
- }
|
|
|
- result.append(";\n分析建议:数字化管理方面");
|
|
|
- JSONObject content = suggestion.getJSONObject("content");
|
|
|
- if (!content.getJSONArray("数字化管理").isEmpty()) {
|
|
|
- content.getJSONArray("数字化管理").forEach(item -> {
|
|
|
- result.append(item).append(",");
|
|
|
- });
|
|
|
- result.deleteCharAt(result.length() - 1);
|
|
|
+ @Override
|
|
|
+ public Boolean insertByBoV2(SmsbAppointmentInfoBo bo) {
|
|
|
+ SmsbAppointmentInfo add = MapstructUtils.convert(bo, SmsbAppointmentInfo.class);
|
|
|
+ validEntityBeforeSave(add);
|
|
|
+ // 1、 保存预约信息
|
|
|
+ boolean flag = baseMapper.insert(add) > 0;
|
|
|
+ // 2、 调用第三方接口 获取数据
|
|
|
+ String reportMap = "";
|
|
|
+ try {
|
|
|
+ reportMap = requestApiGetReportMap(add);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("请求第三方接口失败", e);
|
|
|
+ return false;
|
|
|
}
|
|
|
- result.append(";数字化经营方面");
|
|
|
- if (!content.getJSONArray("数字化经营").isEmpty()) {
|
|
|
- content.getJSONArray("数字化经营").forEach(item -> {
|
|
|
- result.append(item).append(",");
|
|
|
- });
|
|
|
- result.deleteCharAt(result.length() - 1);
|
|
|
+ // 3、 读取评估报告内容
|
|
|
+ List<String> reportList = getAssessmentReportV2(reportMap);
|
|
|
+ if (!CollectionUtils.isEmpty(reportList)) {
|
|
|
+ // 4 启动线程,保存至数据库,生成总结
|
|
|
+ createReport(reportList, add, smsbDeviceChatScReportMapper);
|
|
|
}
|
|
|
- result.append(";数字化基础方面");
|
|
|
- if (!content.getJSONArray("数字化基础").isEmpty()) {
|
|
|
- content.getJSONArray("数字化基础").forEach(item -> {
|
|
|
- result.append(item).append(",");
|
|
|
- });
|
|
|
- result.deleteCharAt(result.length() - 1);
|
|
|
+
|
|
|
+
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void createReport(List<String> reportContentList, SmsbAppointmentInfo add, SmsbDeviceChatScReportMapper smsbDeviceChatScReportMapper) {
|
|
|
+ Runnable transTask = () -> {
|
|
|
+ log.info("createReport thread begin reportContentList.size(): " + reportContentList.size());
|
|
|
+ // 数据库保存条目
|
|
|
+ List<SmsbDeviceChatScReport> scReportList = new ArrayList<>();
|
|
|
+ StringBuilder reportContentStr = new StringBuilder();
|
|
|
+ reportContentStr.append("帮我对一下内容进行汇总总结,返回100字的纯文本内容:").append("\n");
|
|
|
+ for (String reportContent : reportContentList) {
|
|
|
+ reportContentStr.append(reportContent).append("\n");
|
|
|
+ SmsbDeviceChatScReport scReport = new SmsbDeviceChatScReport();
|
|
|
+ scReport.setType(2);
|
|
|
+ scReport.setContent(reportContent);
|
|
|
+ scReport.setAppointmentId(add.getId());
|
|
|
+ scReport.setEnterprise(add.getEnterprise());
|
|
|
+ scReport.setTenantId(add.getTenantId());
|
|
|
+ scReportList.add(scReport);
|
|
|
+ }
|
|
|
+ smsbDeviceChatScReportMapper.insertBatch(scReportList);
|
|
|
+ // 调用公共Dify接口 进行内容总结 并保存
|
|
|
+ String reportSummary = DifyStreamUtil.callDifyStreamApi(difyBaseUrl + "/v1/chat-messages", difyScAgentApiKey, reportContentStr.toString());
|
|
|
+ SmsbDeviceChatScReport scReport = new SmsbDeviceChatScReport();
|
|
|
+ scReport.setType(1);
|
|
|
+ String content = "你好," + add.getEnterprise() + "企业,我是小数智能分析助手。您企业的诊断评估简单介绍为:" + reportSummary + "您可以继续向我提问。";
|
|
|
+ scReport.setContent(content);
|
|
|
+ scReport.setAppointmentId(add.getId());
|
|
|
+ scReport.setEnterprise(add.getEnterprise());
|
|
|
+ scReport.setTenantId(add.getTenantId());
|
|
|
+ smsbDeviceChatScReportMapper.insert(scReport);
|
|
|
+ log.info("createReport thread end !");
|
|
|
+ };
|
|
|
+ // 提交Runnable任务到线程池
|
|
|
+ threadPoolTaskExecutor.submit(transTask);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> getAssessmentReportV2(String reportMap) {
|
|
|
+ try {
|
|
|
+ JSONObject reportMapJson = JSONUtil.parseObj(reportMap);
|
|
|
+ if (!"true".equalsIgnoreCase(reportMapJson.getStr("result"))) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<String> result = new ArrayList<>();
|
|
|
+ // 1-获取reportMap的数据。
|
|
|
+ result.add("诊断等级:" + reportMapJson.get("rateName"));
|
|
|
+ result.add("评估名称:" + reportMapJson.get("estimateName"));
|
|
|
+ result.add("测评名称:" + reportMapJson.get("evaluationName"));
|
|
|
+ result.add("企业名称:" + reportMapJson.get("organizeName"));
|
|
|
+ result.add("企业地市:" + reportMapJson.get("organizeZone"));
|
|
|
+ result.add("报告时间:" + reportMapJson.get("commitTime"));
|
|
|
+ result.add("测评得分:" + reportMapJson.get("totalScore"));
|
|
|
+ // 2-读取报告具体内容
|
|
|
+ JSONObject reportContent = reportMapJson.getJSONObject("reportContent");
|
|
|
+ // 2-1 评分标准:
|
|
|
+ JSONArray standards = reportContent.getJSONArray("standards");
|
|
|
+ StringBuilder standardResult = new StringBuilder();
|
|
|
+ standardResult.append("评分标准:\n");
|
|
|
+ for (int i = 0; i < standards.size(); i++) {
|
|
|
+
|
|
|
+ standardResult.append("等级名称:").append(standards.getJSONObject(i).getStr("levelName")).append("\n");
|
|
|
+ standardResult.append("等级描述:").append(standards.getJSONObject(i).get("levelDesc")).append("\n");
|
|
|
+ standardResult.append("最小分值:").append(standards.getJSONObject(i).get("minScore")).append("\n");
|
|
|
+ standardResult.append("最大分值:").append(standards.getJSONObject(i).get("maxScore")).append("\n");
|
|
|
+ }
|
|
|
+ result.add(standardResult.toString());
|
|
|
+ // 2-2 当前分值
|
|
|
+ result.add("当前分值:" + reportContent.get("score"));
|
|
|
+ // 2-3 对标情况
|
|
|
+ JSONObject benchmarking = reportContent.getJSONObject("benchmarking");
|
|
|
+ // 2-3-1 等级情况
|
|
|
+ JSONArray rate = benchmarking.getJSONArray("rate");
|
|
|
+ StringBuilder rateResult = new StringBuilder();
|
|
|
+ for (int i = 0; i < rate.size(); i++) {
|
|
|
+ rateResult.append("等级情况:\n");
|
|
|
+ rateResult.append("等级名称:").append(rate.getJSONObject(i).getStr("rate")).append("\n");
|
|
|
+ rateResult.append("等级数量:").append(rate.getJSONObject(i).get("quantity")).append("\n");
|
|
|
+ rateResult.append("平均分值:").append(rate.getJSONObject(i).get("avg")).append("\n");
|
|
|
+ }
|
|
|
+ result.add(rateResult.toString());
|
|
|
+ // 2-3-2 得分情况
|
|
|
+ JSONObject location = benchmarking.getJSONObject("location");
|
|
|
+ StringBuilder locationResult = new StringBuilder();
|
|
|
+ locationResult.append("得分情况:\n");
|
|
|
+ locationResult.append("自评高于贵公司的数量:").append(location.get("current")).append("\n");
|
|
|
+ locationResult.append("自评等于贵公司的数量:").append(location.get("equalCount")).append("\n");
|
|
|
+ locationResult.append("总数量:").append(location.get("count")).append("\n");
|
|
|
+ result.add(locationResult.toString());
|
|
|
+ // 2-4 分析建议
|
|
|
+ JSONObject suggestion = reportContent.getJSONObject("suggestion");
|
|
|
+ // 2-4-1 劣势列表
|
|
|
+ JSONArray disadvantage = suggestion.getJSONArray("disadvantage");
|
|
|
+ StringBuilder disadvantageResult = new StringBuilder();
|
|
|
+ for (int i = 0; i < disadvantage.size(); i++) {
|
|
|
+ disadvantageResult.append("劣势列表:\n");
|
|
|
+ disadvantageResult.append(disadvantage.get(i)).append("\n");
|
|
|
+ }
|
|
|
+ result.add(disadvantageResult.toString());
|
|
|
+ // 2-4-2 优势列表
|
|
|
+ JSONArray advantage = suggestion.getJSONArray("advantage");
|
|
|
+ StringBuilder advantageResult = new StringBuilder();
|
|
|
+ for (int i = 0; i < advantage.size(); i++) {
|
|
|
+ advantageResult.append("优势列表:\n");
|
|
|
+ advantageResult.append(advantage.get(i)).append("\n");
|
|
|
+ }
|
|
|
+ result.add(advantageResult.toString());
|
|
|
+ // 2-4-3 相关建议列表
|
|
|
+ JSONObject content = suggestion.getJSONObject("content");
|
|
|
+
|
|
|
+ result.add("相关建议:" + content.toString()
|
|
|
+ .replaceAll("\\{", "").replaceAll("}", "")
|
|
|
+ .replaceAll("\\[", "").replaceAll("]", "").trim());
|
|
|
+ // 2-5 满分
|
|
|
+ result.add("满分:" + reportContent.get("fullScore"));
|
|
|
+ return result;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取评估报告内容失败", e);
|
|
|
+ return null;
|
|
|
}
|
|
|
- result.append(";数字化成效方面");
|
|
|
- if (!content.getJSONArray("数字化成效").isEmpty()) {
|
|
|
- content.getJSONArray("数字化成效").forEach(item -> {
|
|
|
- result.append(item).append(",");
|
|
|
- });
|
|
|
- result.deleteCharAt(result.length() - 1);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private String requestApiGetReportMap(SmsbAppointmentInfo add) {
|
|
|
+ JsonObject requestBody = new JsonObject();
|
|
|
+ requestBody.add("interfaceId", scApiInterfaceId);
|
|
|
+ requestBody.add("appId", scApiAppId);
|
|
|
+ String secret = EncryptUtil.encryptOuter(scApiPublicKey, scApiSecretKey);
|
|
|
+ log.info("requestApiGetScData,secret:" + secret);
|
|
|
+ requestBody.add("secret", secret);
|
|
|
+ JsonObject body = new JsonObject();
|
|
|
+ body.add("phoneNumber", add.getPhone());
|
|
|
+ requestBody.add("body", body.toString());
|
|
|
+ HttpRequest request = HttpRequest.post(scApiBaseUrl)
|
|
|
+ .header("Content-Type", "application/json")
|
|
|
+ .body(requestBody.toString());
|
|
|
+ HttpResponse response = request.execute();
|
|
|
+ if (!response.isOk()) {
|
|
|
+ return null;
|
|
|
}
|
|
|
- result.append(";\n满分:").append(reportContent.getStr("fullScore"));
|
|
|
- return result.toString();
|
|
|
+ String responseBody = response.body();
|
|
|
+ JSONObject responseJson = JSONUtil.parseObj(responseBody);
|
|
|
+ String reportMapStr = responseJson.getJSONObject("data").getStr("reportMap");
|
|
|
+ return reportMapStr;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -217,77 +313,6 @@ public class SmsbAppointmentInfoServiceImpl implements ISmsbAppointmentInfoServi
|
|
|
SmsbAppointmentInfo add = MapstructUtils.convert(bo, SmsbAppointmentInfo.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
- if (flag) {
|
|
|
- bo.setId(add.getId());
|
|
|
- // 请求拿到诊断报告
|
|
|
- String requestUrl = "http://gctest.yunzhouiip.com:8018/gateway/third/call";
|
|
|
- JsonObject body = new JsonObject();
|
|
|
- body.add("phoneNumber", bo.getPhone());
|
|
|
- body.add("interfaceId", "ZT49DigitalHuman");
|
|
|
- body.add("appId", "ZT");
|
|
|
- body.add("secret", EncryptUtil.encryptOuter("0430e45e154b4e73278b0e05d81c530377d4fbad" +
|
|
|
- "e470aefdba484542bb49a04b15aae372084fd7f0792df40d3b6caabccac585027091321b034e1ab0dee258341b",
|
|
|
- "ExperienceCenterKey01"));
|
|
|
- body.add("phoneNumber", bo.getPhone());
|
|
|
- HttpRequest request = HttpRequest.post(requestUrl)
|
|
|
- .header("Content-Type", "application/json")
|
|
|
-// .body("interfaceId", "ZT49DigitalHuman")
|
|
|
-// .body("appId", "ZT")
|
|
|
-// .body("secret", EncryptUtil.encryptOuter("0430e45e154b4e73278b0e05d81c530377d4fbad" +
|
|
|
-// "e470aefdba484542bb49a04b15aae372084fd7f0792df40d3b6caabccac585027091321b034e1ab0dee258341b",
|
|
|
-// "ExperienceCenterKey01"))
|
|
|
- .body(body.toString());
|
|
|
- HttpResponse response = request.execute();
|
|
|
- if (!response.isOk()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- String responseBody = response.body();
|
|
|
- JSONObject responseJson = JSONUtil.parseObj(responseBody);
|
|
|
- String reportMapStr = responseJson.getJSONObject("data").getStr("reportMap");
|
|
|
- String interactionListStr = responseJson.getJSONObject("data").getStr("interactionList");
|
|
|
-
|
|
|
- Map<String, Object> reportMap = ReportMapParser.parse(reportMapStr);
|
|
|
- List<Map<String, Object>> interactionList = InteractionListParser.parse(interactionListStr);
|
|
|
-
|
|
|
-// 先把需要的数据摘出来放着,然后交给智能体生成欢迎语,再拼接写入到知识库
|
|
|
- String assessmentReport = getAssessmentReport(reportMapStr);
|
|
|
-
|
|
|
- // 搞个公共智慧体ai这里喂给他报告,让他生成100字左右简单建议
|
|
|
- String agentUrl = "http://dify01.snctv.net/v1";
|
|
|
- HttpRequest agentRequest = HttpRequest.post(agentUrl)
|
|
|
- .header("Content-Type", "application/json")
|
|
|
- .header("Authorization", "Bearer " + "app-11vDqngW7qVyggfsKyjssv23")
|
|
|
-// .body("inputs", inputs.toString())
|
|
|
- .body("query", "请根据下列诊断报告\n" + assessmentReport)
|
|
|
- .body("response_mode", "blocking")
|
|
|
-// .body("conversation_id", "")
|
|
|
- .body("user", "public_intelligent_agent");
|
|
|
- HttpResponse agentResponse = agentRequest.execute();
|
|
|
- if (!agentResponse.isOk()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- String agentResponseBody = agentResponse.body();
|
|
|
- String answer = JSONUtil.parseObj(agentResponseBody).getJSONObject("data").getStr("outputs");
|
|
|
-
|
|
|
- // 报告内容创建一个知识库文件,以手机号命名
|
|
|
- String datasetId = "dataset_id";
|
|
|
- String repositoryUrl = "http://dify01.snctv.net/v1/datasets/" + datasetId + "/document/create-by-text";
|
|
|
- HttpRequest repositoryRequest = HttpRequest.post(repositoryUrl)
|
|
|
- .header("Content-Type", "application/json")
|
|
|
- // 这里的agentApiKey后面替换掉
|
|
|
- .header("Authorization", "Bearer " + "agentApiKey")
|
|
|
- .body("name", add.getPhone().toString())
|
|
|
- .body("text", "简单介绍:" + answer + "\n" + assessmentReport)
|
|
|
-// .body("doc_type", "business_document")
|
|
|
-// .body("doc_metadata", "这里写文档元数据")
|
|
|
- .body("indexing_technique", "high_quality")
|
|
|
- .body("doc_form", "text_model")
|
|
|
- .body("process_rule", "{\"mode\": \"automatic\"}");
|
|
|
- HttpResponse repositoryResponse = repositoryRequest.execute();
|
|
|
- if (!repositoryResponse.isOk()) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
@@ -300,15 +325,22 @@ public class SmsbAppointmentInfoServiceImpl implements ISmsbAppointmentInfoServi
|
|
|
@Override
|
|
|
public Boolean updateByBo(SmsbAppointmentInfoBo bo) {
|
|
|
SmsbAppointmentInfo update = MapstructUtils.convert(bo, SmsbAppointmentInfo.class);
|
|
|
- validEntityBeforeSave(update);
|
|
|
return baseMapper.updateById(update) > 0;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 保存前的数据校验
|
|
|
*/
|
|
|
- private void validEntityBeforeSave(SmsbAppointmentInfo entity){
|
|
|
- //TODO 做一些数据校验,如唯一约束
|
|
|
+ private void validEntityBeforeSave(SmsbAppointmentInfo entity) {
|
|
|
+ // 预约信息手机号和企业信息不能为空
|
|
|
+ if (StringUtils.isEmpty(entity.getEnterprise()) || StringUtils.isEmpty(entity.getPhone())) {
|
|
|
+ log.error("预约信息手机号和企业信息为空");
|
|
|
+ throw new ServiceException("预约信息手机号和企业信息为空");
|
|
|
+ }
|
|
|
+ entity.setCreateBy(1L);
|
|
|
+ entity.setTenantId("000000");
|
|
|
+ entity.setCreateDept(103L);
|
|
|
+ entity.setUpdateBy(1L);
|
|
|
}
|
|
|
|
|
|
/**
|