Commit d532e54a authored by 何金镒's avatar 何金镒

新增communityCode

parent 2778b066
......@@ -8,6 +8,7 @@ import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ikonke.konkeaialibabamcp.constant.RedisKeys;
import com.ikonke.konkeaialibabamcp.controller.param.DifyStreamResponse;
import com.ikonke.konkeaialibabamcp.entity.cdc.UserEntity;
import com.ikonke.konkeaialibabamcp.entity.mysql.CDCToken;
import com.ikonke.konkeaialibabamcp.event.mode.DifyChatSteamEvent;
import com.ikonke.konkeaialibabamcp.service.cdc.CdcHttpUtils;
......@@ -48,24 +49,25 @@ public class DifyControllerV2 {
@Value("${cdc.difyChatSteamMessages}")
private String difyChatSteamMessages;
@Value("${dify.key}")
private String dify_api_key;
public DifyControllerV2(ApplicationEventPublisher eventPublisher) {
this.eventPublisher = eventPublisher;
}
@PostConstruct
public void init() {
Object redisValue = redisTemplate.opsForValue().get(RedisKeys.KONKE_DIFY_API_KEY);
// 如果Redis中有值,则使用Redis中的值覆盖配置文件的值
if (redisValue != null) {
this.dify_api_key = redisValue.toString();
log.info("Using Dify API key from Redis: {}", this.dify_api_key);
} else {
log.info("Using Dify API key from configuration file: {}", this.dify_api_key);
}
}
// @PostConstruct
// public void init() {
// Object redisValue = redisTemplate.opsForValue().get(RedisKeys.KONKE_DIFY_API_KEY);
//
// // 如果Redis中有值,则使用Redis中的值覆盖配置文件的值
// if (redisValue != null) {
// this.dify_api_key = redisValue.toString();
// log.info("Using Dify API key from Redis: {}", this.dify_api_key);
// } else {
// log.info("Using Dify API key from configuration file: {}", this.dify_api_key);
// }
// }
......@@ -102,7 +104,7 @@ public class DifyControllerV2 {
if(list.size() == 1){
CDCToken token = list.get(0);
if(StrUtil.isBlank(token.getCcuId())){
res = String.format(res, "未绑定主机绑定", false);
res = String.format(res, "未绑定主机", false);
response = JSONUtil.parseObj(res);
}
......@@ -168,6 +170,8 @@ public class DifyControllerV2 {
return Flux.just("未绑定社区账号");
}
UserEntity userEntity = cdcHttpUtils.getOwner(sn);
//workflows/run
String url = "http://172.17.12.12:8088/v1/chat-messages";
......@@ -175,6 +179,14 @@ public class DifyControllerV2 {
inputs.set("ccuName",token.getCcuId());
inputs.set("sn",sn);
inputs.set("token",token.getAccessToken());
inputs.set("communityCode",userEntity.getCommunityCode());
inputs.set("communityId",userEntity.getCommunityId());
inputs.set("easId",userEntity.getEasId());
inputs.set("roomId",userEntity.getRoomInfo().getRoomId());
inputs.set("roomName",userEntity.getRoomInfo().getRoomId());
inputs.set("buildingId",userEntity.getRoomInfo().getBuildingId());
inputs.set("userPhone",userEntity.getPhoneNum());
inputs.set("userName",userEntity.getPhoneNum());
JSONObject body = new JSONObject();
body.set("inputs",inputs);
......@@ -182,6 +194,7 @@ public class DifyControllerV2 {
body.set("response_mode","streaming");//blocking 阻塞模式,streaming 流式模式
body.set("user",sn);
String redis_key = RedisKeys.KONKE_DIFY_CONVERSATION_ID+ sn;
Object redis_conversationId =redisTemplate.opsForValue().get(redis_key);
String conversationId = null;
......
......@@ -69,6 +69,15 @@ public class UserEntity implements Serializable {
public String easId;
public OwnerRoom ownerRoom;
public RoomInfo roomInfo;
public String communityCode;
public String getCommunityCode() {
return communityCode;
}
public void setCommunityCode(String communityCode) {
this.communityCode = communityCode;
}
public String getOwnerId() {
return ownerId;
......
......@@ -53,8 +53,12 @@ konke:
appKey: 216531bf-6394-455d-98c0-87d74ad2fcc5
baseUrl: http://172.24.10.11:16000
dify:
key: app-Lev1PRD3VBWH9P0AhfnywKJT
cdc:
timeout: 20000
url: https://sqdn.cndmega.com/prod-v2.0.1
# url: https://sqdn.cndmega.com/prod-v2.0.1
url: http://community.jfzhtest.com/prod-api
difyChatSteamMessages: http://127.0.0.1:${server.port}
......@@ -46,6 +46,9 @@ konke:
appKey: 0c350d82-aa95-46e1-91b8-b8d508b5226a
baseUrl: http://172.17.12.6:10000
dify:
key: app-Lev1PRD3VBWH9P0AhfnywKJT
cdc:
timeout: 20000
url: http://community.jfzhtest.com/prod-api
......
......@@ -38,11 +38,11 @@ class KonkeAiAlibabaMcpApplicationTests {
// @Test
// void redistest() {
// String redis_key = RedisKeys.KONKE_DIFY_CONVERSATION_ID+ sn;
// // String redis_key = RedisKeys.KONKE_DIFY_CONVERSATION_ID+ sn;
//
// Set<String> keys = redisTemplate.keys(RedisKeys.KONKE_DIFY_CONVERSATION_ID + "*");
// for(String key : keys){
// System.out.println( key);
// System.out.println("----->"+ key);
// redisTemplate.delete(key);
// }
// }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment