|
|
|
@@ -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()); |
|
|
|
|