Browse Source

修改:

1、新增log以及redis。
    2、添加时间戳。
    3、招呼语的retain参数为true。
tags/B.2.7.0_20240201_base
10710 1 year ago
parent
commit
7140b1411e
1 changed files with 19 additions and 2 deletions
  1. +19
    -2
      xueyi-modules/xueyi-nlt/src/main/java/com/xueyi/nlt/nlt/controller/DmIntentController.java

+ 19
- 2
xueyi-modules/xueyi-nlt/src/main/java/com/xueyi/nlt/nlt/controller/DmIntentController.java View File

@@ -962,10 +962,19 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt

@PostMapping("/api/testforwelcome")
public AjaxResult test(){
LocalDateTime dateTime = LocalDateTime.now();
String date = dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
JSONObject jo = generativeWelcomeTemplate.handle("1", "");
JSONArray ja = jo.getJSONArray("data");
Long timeStamp = System.currentTimeMillis();
JSONObject timeJson = new JSONObject();
timeJson.put("timestamp", timeStamp);
ja.add(timeJson);
log.info(ja.toJSONString());
redisTemplate2.opsForHash().put("group:task" + ":generate", date, AjaxResult.success(ja).toJson().toJSONString());
Map<Object, Object> devices = redisTemplate2.opsForHash().entries("group:dgman:device:");
for(Object devId:devices.keySet()){
mqttTemplate.sendToMqtt("/" + activeProfile + "/" + "digital_man" + "/" + devId.toString() + "/" + "notify" + "/" + "generate-welcome", AjaxResult.success(jo.getJSONArray("data")).toString());
mqttTemplate.sendToMqtt("/" + activeProfile + "/" + "digital_man" + "/" + devId.toString() + "/" + "notify" + "/" + "generate-welcome", true, AjaxResult.success(ja).toJson().toJSONString());
}
return AjaxResult.success();
}
@@ -974,14 +983,22 @@ public class DmIntentController extends BaseController<DmIntentQuery, DmIntentDt
@ResponseBody
public AjaxResult generateContextTask() {
LocalDateTime dateTime = LocalDateTime.now();
String date = dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
List<JSONObject> contentList = new ArrayList<>();
GenerativeWelcomeTemplate.lunar = "";
GenerativeWelcomeTemplate.term = null;
try {
JSONObject jo = generativeWelcomeTemplate.handle("1", "");
JSONArray ja = jo.getJSONArray("data");
Long timeStamp = System.currentTimeMillis();
JSONObject timeJson = new JSONObject();
timeJson.put("timestamp", timeStamp);
ja.add(timeJson);
log.info(ja.toJSONString());
redisTemplate2.opsForHash().put("group:task" + ":generate", date, AjaxResult.success(ja).toJson().toJSONString());
Map<Object, Object> devices = redisTemplate2.opsForHash().entries("group:dgman:device:");
for(Object devId:devices.keySet()){
mqttTemplate.sendToMqtt("/" + activeProfile + "/" + "digital_man" + "/" + devId.toString() + "/" + "notify" + "/" + "generate-welcome", AjaxResult.success(jo.getJSONArray("data")).toString());
mqttTemplate.sendToMqtt("/" + activeProfile + "/" + "digital_man" + "/" + devId.toString() + "/" + "notify" + "/" + "generate-welcome", true, AjaxResult.success(ja).toJson().toJSONString());
}
} catch (Exception e) {
log.error("生成任务失败:{}",e.getMessage());


Loading…
Cancel
Save