diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ApiChatNewController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ApiChatNewController.java index cd7f5cefc5194bdf58ce38df886490f50b1c6172..b976180f6c8963060c39d23506b53ddf0df5682b 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ApiChatNewController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ApiChatNewController.java @@ -48,21 +48,22 @@ public class ApiChatNewController { private RedisTemplate redisTemplate; @Resource private IMallMemberUserService mallMemberUserService; - - @Value("${baidu.appKey}") - private String appKey; + @Value("${baidu.appId}") - private String appId; - + private String APP_ID; + @Value("${baidu.appKey}") + private String APP_KEY; + + // 读取超时为60s private static final long READ_TIMEOUT = 60000; // 写入超时为60s private static final long WRITE_TIMEOUT = 60000; // 连接超时为60s private static final long CONNECT_TIMEOUT = 60000; - + private static final long CALL_TIMEOUT = 60000; - + private static final OkHttpClient HTTP_CLIENT = new OkHttpClient().newBuilder() // 设置调用超时时间 .callTimeout(CALL_TIMEOUT, TimeUnit.MILLISECONDS) @@ -76,6 +77,7 @@ public class ApiChatNewController { private static final ObjectMapper objectMapper = new ObjectMapper(); + // 本次对话ID private String conversation_id; @@ -262,14 +264,14 @@ public class ApiChatNewController { logger.info("提问千帆App:" + question); MediaType mediaType = MediaType.parse("application/json"); // 消息体 - String json = objectMapper.writeValueAsString(new BaiduAppRequest(appId, question, conversation_id)); + String json = objectMapper.writeValueAsString(new BaiduAppRequest(APP_ID, question, conversation_id)); RequestBody body = RequestBody.create(mediaType, json); // 请求 Request request = new Request.Builder() .url("https://qianfan.baidubce.com/v2/app/conversation/runs") .method("POST", body) .addHeader("Content-Type", "application/json") - .addHeader("X-Appbuilder-Authorization", "Bearer " + appKey) + .addHeader("X-Appbuilder-Authorization", "Bearer " + APP_KEY) .build(); Response response = HTTP_CLIENT.newCall(request).execute(); // 获取消息 @@ -291,12 +293,12 @@ public class ApiChatNewController { conversation_id = object.toString(); }else { MediaType mediaType = MediaType.parse("application/json"); - RequestBody body = RequestBody.create(mediaType, "{\"appId\":\"" + appId + "\"}"); + RequestBody body = RequestBody.create(mediaType, "{\"app_id\":\"" + APP_ID + "\"}"); Request request = new Request.Builder() .url("https://qianfan.baidubce.com/v2/app/conversation") .method("POST", body) .addHeader("Content-Type", "application/json") - .addHeader("X-Appbuilder-Authorization", "Bearer " + appKey) + .addHeader("X-Appbuilder-Authorization", "Bearer " + APP_KEY) .build(); Response response = HTTP_CLIENT.newCall(request).execute(); String res = response.body().string(); diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index 937c520e6680292228d6e70c822d3bc497b99352..bea47c088d610f7ffbbdf927bb4779857c020df4 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -144,5 +144,5 @@ qiNiu: baseUrl: https://image.xnszz.com/ baidu: - appId: a7234eb3-fc6b-4e8a-baae-e7f2df86a1f3 - appKey: bce-v3/ALTAK-SJq4Dnyo31QJlajmyMT40/d806d48c7b7f2ec9675c7cbf2171e6dd0676b274 \ No newline at end of file + appId: 3c3927bd-2722-41eb-8363-7539177f4914 + appKey: bce-v3/ALTAK-ZqT2bHLCdP4vVlnMk0d0s/67e7275c383eb772c85bffb939158f19e112f49f \ No newline at end of file diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/MallSchool.java b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/MallSchool.java index 72491a0e9349803f14a7c2e7dd9f1bb7a5fd1b41..52e49bed31b432c7e5f0d7ea3c09c533eafa4d63 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/mall/domain/MallSchool.java +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/domain/MallSchool.java @@ -21,7 +21,7 @@ public class MallSchool extends BaseEntity private static final long serialVersionUID = 1L; /** 学校主键ID */ - @Excel(name = "学校主键ID") + // @Excel(name = "学校主键ID") private Long schoolId; /** 学校名 */ @@ -47,6 +47,13 @@ public class MallSchool extends BaseEntity @Excel(name = "学校编号") private String schoolNumber; + /** 办学层次id */ + private Long configLevelId; + + /** 办学层次 */ + @Excel(name = "办学层次") + private String configLevelName; + /** 学校类型ID */ // @Excel(name = "学校类型ID") private Long configTypeId; @@ -56,7 +63,7 @@ public class MallSchool extends BaseEntity private String configTypeName; /** 办学机构:0-公办,1-民办,3-中外合作办学,4其他 */ - // @Excel(name = "办学机构:0-公办,1-民办,3-中外合作办学,4其他") + @Excel(name = "办学机构", readConverterExp = "0=公办,1=民办,3=中外合作办学,4=其他") private String schoolInstitution; /** 主管部门(教育部、各地市) */ @@ -186,11 +193,6 @@ public class MallSchool extends BaseEntity /** 批次id数组 */ private Long[] batchList; - /** 办学层次id */ - private Long configLevelId; - - /** 办学层次 */ - private String configLevelName; /** 推荐度id */ private Long suggestId; diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/MallSchoolLevelMapper.java b/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/MallSchoolLevelMapper.java index dd4c3339db5954ef518c59eed69d56482573cea8..73674ceaa6663260213ed47b20e2a4e217d2b004 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/MallSchoolLevelMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/mapper/MallSchoolLevelMapper.java @@ -23,6 +23,7 @@ public interface MallSchoolLevelMapper public MallSchoolLevel selectMallSchoolLevelBySchoolId(@Param("schoolId") Long schoolId); + public List selectMallSchoolLevelBySchoolIds(@Param("schoolId") List schoolIds); /** * 查询学校办学层次列表 diff --git a/ruoyi-system/src/main/java/com/ruoyi/mall/service/impl/MallSchoolServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/mall/service/impl/MallSchoolServiceImpl.java index 6409bb538af721cea56fde00a18a99ab5786e666..3d586a6e5675f117145aff29016c8a63390ccecf 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/mall/service/impl/MallSchoolServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/mall/service/impl/MallSchoolServiceImpl.java @@ -1,5 +1,6 @@ package com.ruoyi.mall.service.impl; +import cn.hutool.core.collection.CollectionUtil; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -190,16 +191,28 @@ public class MallSchoolServiceImpl implements IMallSchoolService { @Override public List selectMallSchoolListForExcel(MallSchool mallSchool) { List list = mallSchoolMapper.selectMallSchoolList(mallSchool); - if (!list.isEmpty()){ - for (MallSchool school : list) { - // 查询层次 - MallSchoolLevel mallSchoolLevel = mallSchoolLevelMapper.selectMallSchoolLevelBySchoolId(school.getSchoolId()); - if(ObjectUtils.isNotEmpty(mallSchoolLevel)){ - school.setConfigLevelId(mallSchoolLevel.getConfigLevelId()); - school.setConfigLevelName(mallSchoolLevel.getConfigLevelName()); - } - } - } + // if (!list.isEmpty()){ + // List mallSchoolLevels = mallSchoolLevelMapper.selectMallSchoolLevelBySchoolIds( + // list.stream().map(MallSchool::getSchoolId).collect(Collectors.toList())); + // if (CollectionUtil.isNotEmpty(mallSchoolLevels)){ + // Map collect = mallSchoolLevels.stream().collect(Collectors.toMap(MallSchoolLevel::getSchoolId, e -> e)); + // list.stream().peek(l -> { + // MallSchoolLevel mallSchoolLevel = collect.get(l.getSchoolId()); + // if (ObjectUtils.isNotEmpty(mallSchoolLevel)){ + // l.setConfigLevelId(mallSchoolLevel.getConfigLevelId()); + // l.setConfigLevelName(mallSchoolLevel.getConfigLevelName()); + // } + // }).collect(Collectors.toList()); + // } + // // for (MallSchool school : list) { + // // // 查询层次 + // // MallSchoolLevel mallSchoolLevel = mallSchoolLevelMapper.selectMallSchoolLevelBySchoolId(school.getSchoolId()); + // // if(ObjectUtils.isNotEmpty(mallSchoolLevel)){ + // // school.setConfigLevelId(mallSchoolLevel.getConfigLevelId()); + // // school.setConfigLevelName(mallSchoolLevel.getConfigLevelName()); + // // } + // // } + // } return list; } diff --git a/ruoyi-system/src/main/resources/mapper/mall/MallSchoolLevelMapper.xml b/ruoyi-system/src/main/resources/mapper/mall/MallSchoolLevelMapper.xml index 994fb729f8ec86880d14971678b4cc5b152d348e..ad95795cb3190de2277c4ad4ca0b7b21516a6a06 100644 --- a/ruoyi-system/src/main/resources/mapper/mall/MallSchoolLevelMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/mall/MallSchoolLevelMapper.xml @@ -78,6 +78,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and del_flag = '0' + + insert into mall_school_level diff --git a/ruoyi-system/src/main/resources/mapper/mall/MallSchoolMapper.xml b/ruoyi-system/src/main/resources/mapper/mall/MallSchoolMapper.xml index d2b7f183b316c5ddb4d8eaaa55cf939834f98245..6fee7c89fe169dee6cccbd2219291de8f5209d80 100644 --- a/ruoyi-system/src/main/resources/mapper/mall/MallSchoolMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/mall/MallSchoolMapper.xml @@ -54,6 +54,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -64,6 +65,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -78,11 +80,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"