From 9109fa09f1533ae94927940a07859ff1e3d13069 Mon Sep 17 00:00:00 2001
From: 苗权威 <1160292058@qq.com>
Date: Fri, 6 Sep 2019 21:26:41 +0800
Subject: [PATCH] 9.6
---
.idea/workspace.xml | 624 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java | 9 +++++----
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/FrameTemple.java | 13 ++-----------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java | 20 ++++++++------------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java | 44 ++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Event.java | 3 +++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java | 3 +++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java | 461 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java | 22 +++++++++++++++-------
xiaoduhome/src/main/resources/static/json/frame.json | 6 +++---
xiaoduhome/src/main/resources/static/json/textRota.json | 8 +++++++-
11 files changed, 660 insertions(+), 553 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 0baa8eb..b718326 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,25 +3,16 @@
-
-
-
-
-
-
+
-
-
-
-
-
-
+
+
+
+
-
-
-
+
@@ -67,120 +58,33 @@
-
-
+
+
-
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -199,9 +103,6 @@
- POOL.submit
- AppFavoriteTBRepository
- xiaoDuOrderTbRepository
SimpleDateFormat
Date
XiaoDuOrderTbRepository
@@ -229,6 +130,9 @@
DU_ID_2_US_ID
position
LunchUtils
+ onComplete
+ CATEGORY_PROD_LIST
+ USER_HISTORY
OPENID_CACHE
@@ -244,10 +148,6 @@
@@ -312,6 +216,15 @@
+
+
+
+
+
+
+
+
+
@@ -327,7 +240,7 @@
-
+
@@ -390,51 +303,63 @@
-
+
-
+
+
+
+
+
+
-
-
-
-
-
+
-
-
+
+
+
+
-
+
+
+
+
-
+
+
+
+
+
+
+
+
+
-
-
@@ -442,8 +367,6 @@
-
-
@@ -452,8 +375,6 @@
-
-
@@ -463,8 +384,6 @@
-
-
@@ -475,8 +394,6 @@
-
-
@@ -488,7 +405,6 @@
-
@@ -500,7 +416,7 @@
-
+
@@ -626,8 +542,8 @@
-
+
@@ -641,7 +557,7 @@
-
+
@@ -1072,6 +988,7 @@
+
@@ -1092,7 +1009,6 @@
-
@@ -1188,7 +1104,8 @@
-
+
+
@@ -1198,7 +1115,7 @@
-
+
@@ -1210,7 +1127,7 @@
-
+
@@ -1223,14 +1140,14 @@
-
+
-
+
@@ -1259,430 +1176,413 @@
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
+
+
-
-
+
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
+
-
-
+
+
-
-
-
-
-
+
+
-
+
-
-
+
+
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
index c1a1955..5dcdcb2 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
@@ -441,7 +441,7 @@ public class TTService {
/**
* 若文件已存在则不进行覆盖,除非是put更新请求.
- * 首先从音频下载地址下载数据到本地,文件地址为filepath(该文件原指的是mp3文件,先改为wav文件),
+ * 首先从音频下载地址下载数据到本地,文件地址为filepath(该路径以.mp3结尾,先改为wav文件),
* 该下载好的wav文件经过python的change_sound方法生成mp3文件,该文件即filepath.
*
* @param url 音频下载地址
@@ -468,7 +468,7 @@ public class TTService {
}
//long wavStartTime = System.currentTimeMillis();
//log.info("url:{}", url);
- res = requestTemplate(url, data, wavFilename, longTime);
+ res = requestTemplate(url, data, wavFilename, longTime, true);
//long wavEndTime = System.currentTimeMillis();
//log.info("wav whole time:{}", (wavEndTime-wavStartTime)/1000.0);
if (res.getCode() != 200) {
@@ -486,7 +486,7 @@ public class TTService {
}else if (!fileExist) {
if (offlineService.equals(url)) {
data.setFormat("mp3");
- res = requestTemplate(url , data, filePath, false);
+ res = requestTemplate(url , data, filePath, false, false);
if (res.getCode() != 200) {
log.error("线下请求音频文件:{},失败:{}",filePath, res);
}
@@ -571,7 +571,7 @@ public class TTService {
* @param longTime 线下测试超时为3s,线上为12s
* @return 返回状态码,调用方法通过此来判断方法是否成功
*/
- private ResponseCodeWithData requestTemplate(String url, GeneralMP3Data data, String filePath, boolean longTime) {
+ private ResponseCodeWithData requestTemplate(String url, GeneralMP3Data data, String filePath, boolean longTime, boolean getOnline) {
String dataStr = JSON.toJSONString(data);
// log.info("GeneralMP3Data:{}", dataStr);
ResponseCodeWithData res = null;
@@ -602,6 +602,7 @@ public class TTService {
return res;
}
else if (resCode == 404 && url.equals(offlineService)) {
+ if (!getOnline) return new ResponseCodeWithData(404, "没有找到该文件");
String person = data.getPerson();
String mood = data.getTone();
try {
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/FrameTemple.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/FrameTemple.java
index dcb9f9b..b5c1c18 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/FrameTemple.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/FrameTemple.java
@@ -1,5 +1,6 @@
package ai.qiwu.com.xiaoduhome.common.temple;
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Item;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@@ -30,14 +31,6 @@ public class FrameTemple implements Agent{
private String fontSize;
@JsonProperty("margin-left")
private String marginLeft;
- @JsonProperty("margin-bottom")
- private String marginBottom;
- @JsonProperty("margin-top")
- private String marginTop;
- private String width;
- private String height;
- @JsonProperty("border-width")
- private String borderWidth;
@JsonProperty("border-top-left-radius")
private String borderTopLeftRadius;
@JsonProperty("border-top-right-radius")
@@ -48,10 +41,8 @@ public class FrameTemple implements Agent{
private String paddingVertical;
@JsonProperty("padding-horizontal")
private String paddingHorizontal;
- @JsonProperty("border-color")
- private String borderColor;
@JsonProperty("background-color")
private String backgroundColor;
private String color;
- private String position;
+ private String height;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java
index ebc5fa8..d42c8b1 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java
@@ -6,10 +6,7 @@ import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
+import java.util.*;
/**
* @author 苗权威
@@ -62,8 +59,7 @@ public class LunchUtils {
LunchPojo list = new LunchPojo();
list.setType("List");
list.setHeight("310dp");
- list.setMarginLeft("15dp");
- list.setMarginRight("15dp");
+ list.setMarginLeft("30dp");
list.setDirection("horizontal");
list.setData(data);
list.setItems(Collections.singletonList(LUNCH_LIST_CATEGORY_CON));
@@ -80,8 +76,8 @@ public class LunchUtils {
LunchPojo list = new LunchPojo();
list.setType("List");
- list.setMarginLeft("15dp");
- list.setMarginRight("15dp");
+ list.setMarginLeft("30dp");
+// list.setMarginRight("15dp");
list.setMarginBottom("70dp");
list.setDirection("horizontal");
list.setData(data);
@@ -101,9 +97,9 @@ public class LunchUtils {
private static LunchPojo buildImgFrmTxtContainer() {
LunchPojo container = new LunchPojo();
container.setType("Container");
- container.setMarginTop("40dp");
+ container.setMarginTop("30dp");
container.setWidth("200dp");
- container.setMarginLeft("20dp");
+ container.setMarginRight("33dp");
//image
LunchPojo image = new LunchPojo();
@@ -123,7 +119,7 @@ public class LunchUtils {
frame.setType("Frame");
frame.setWidth("35dp");
frame.setHeight("35dp");
- frame.setBackgroundColor("rgba(0,0,0,0.9)");
+ frame.setBackgroundColor("rgba(0,0,0,0.8)");
frame.setBorderRadius("13dp");
LunchPojo frmCon = new LunchPojo();
@@ -144,7 +140,7 @@ public class LunchUtils {
LunchPojo text = new LunchPojo();
text.setType("Text");
text.setFontSize("23dp");
- text.setMarginTop("160dp");
+ text.setMarginTop("168dp");
text.setMarginLeft("7dp");
text.setText("${data.imageName}");
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java
index b3a3843..f4b012b 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java
@@ -5,6 +5,7 @@ import ai.qiwu.com.xiaoduhome.common.Constants;
import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils;
import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Data;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
import ai.qiwu.com.xiaoduhome.service.ScheduleService;
@@ -59,6 +60,49 @@ public class RecommendUtil {
return document;
}
+ public static RecommandDocument getCategory(int num, String category) {
+ RecommandDocument document = new RecommandDocument();
+ RecommandMainTemplate mainTemplate = new RecommandMainTemplate();
+ document.setMainTemplate(mainTemplate);
+
+ RecommandPojo scrollView = new RecommandPojo();
+ scrollView.setType("ScrollView");
+ scrollView.setWidth("100%");
+ scrollView.setMarginBottom("93dp");
+ scrollView.setDirection("vertical");
+ List scrollList = new ArrayList<>();
+ scrollView.setItems(scrollList);
+
+ List categoryIdList = ScheduleService.getCategoryProductIdList().get(category);
+ if (categoryIdList == null || categoryIdList.size() == 0) return null;
+ int bound = categoryIdList.size();
+ int begin = num*16;
+ int end;
+ if (begin >= bound) return null;
+ bound = begin+16 <= bound ? begin+16 : bound;
+
+ List bots = new ArrayList<>();
+ for (int i = begin; i < bound; i++) {
+ String botId = categoryIdList.get(i);
+ bots.add((ScheduleService.getProductIdDetail().get(botId)));
+ }
+ StringBuilder botIds = new StringBuilder();
+
+ int count = 0;
+ while (begin < bound) {
+ end = begin+4 <= bound ? begin+4 : bound;
+ scrollList.add(buildRecommendList(getListData(count,begin, end, bots, botIds)));
+ count++;
+ begin = end;
+ }
+ mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,RECOM_HEAD,scrollView,RECOM_FOOTER));
+
+ botIds.deleteCharAt(botIds.length()-1);
+ String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
+ document.setRecommendIdList(idToken);
+ return document;
+ }
+
private static List getListData(int row,int begin, int end, List bots, StringBuilder botIds) {
List data = new ArrayList<>();
int n = 1+row*4;
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Event.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Event.java
index 1f9b121..7e1b834 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Event.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Event.java
@@ -5,6 +5,8 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
+import java.util.List;
+
/**
* @author 苗权威
* @dateTime 19-8-6 下午9:26
@@ -28,6 +30,7 @@ public class Event {
private String repeatCount;
private String position;
private String value;
+ private List onComplete;
public Event() {
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java
index 65378c3..0adac6d 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java
@@ -23,6 +23,9 @@ public interface GameProjectTbRepository extends JpaRepository categoryProject(@Param("category") String category);
+ @Query(value = "select p.bot_account from game_project_tb as p,game_project_label_tb as l where l.name=?1 and p.apply_status=1 and p.id = l.project_id",nativeQuery = true)
+ List categoryProList(String category);
+
@Query(value = "select id,intro,name,watch,banner_img_url,apply_status,bot_account,user_nickname from game_project_tb where apply_status = 1 order by watch desc limit ?1,8", nativeQuery = true)
List postRankBot(Integer begin);
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java
index 9886b61..6d220b7 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java
@@ -69,7 +69,6 @@ import static ai.qiwu.com.xiaoduhome.common.Constants.WelcomeWord.ERROR_SEND_FLO
import static ai.qiwu.com.xiaoduhome.common.Constants.WelcomeWord.FAIL_COLLECT;
import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.*;
import static ai.qiwu.com.xiaoduhome.service.ScheduleService.CATEGORY;
-import static ai.qiwu.com.xiaoduhome.service.ScheduleService.CATEGORY_PRODUCT_LIST;
/**
* @author 苗权威
@@ -83,9 +82,9 @@ public class DplBotService extends BaseBot {
private static final MyDocument FIRST_PAGE;
- private static final MyDocument CATEGORY_PROD;
- private static final Item CATEGORY_PROD_LIST;
- private static final Item CATEGORY_PROD_HEAD;
+// private static final MyDocument CATEGORY_PROD;
+// private static final Item CATEGORY_PROD_LIST;
+// private static final Item CATEGORY_PROD_HEAD;
private static final int CORE = Runtime.getRuntime().availableProcessors();
@@ -118,10 +117,10 @@ public class DplBotService extends BaseBot {
// thirdRow.get(2).setFirstItem(l3);
// thirdRow.get(2).getItems().get(0).setData(buildCategoryDataList());
- CATEGORY_PROD = JSON.parseObject(getDPLTemple("static/json/categoryPro.json"), MyDocument.class);
- List- container = CATEGORY_PROD.getMainTemplate().getItems().get(0).getItems();
- CATEGORY_PROD_LIST = container.get(2).getItems().get(0);
- CATEGORY_PROD_HEAD = container.get(1);
+// CATEGORY_PROD = JSON.parseObject(getDPLTemple("static/json/categoryPro.json"), MyDocument.class);
+// List
- container = CATEGORY_PROD.getMainTemplate().getItems().get(0).getItems();
+// CATEGORY_PROD_LIST = container.get(2).getItems().get(0);
+// CATEGORY_PROD_HEAD = container.get(1);
PROD_INFO = JSON.parseObject(getDPLTemple("static/json/productInfo.json"), MyDocument.class);
FIRST_PAGE = JSON.parseObject(getDPLTemple("static/json/firstPage.json"), MyDocument.class);
DU_ID_2_US_ID = new ConcurrentHashMap<>();
@@ -139,6 +138,7 @@ public class DplBotService extends BaseBot {
POOL.submit(() -> {
XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
USER_HISTORY.put(getUserId(), repository.getUserHostory(getUserId()));
+ log.info("用户历史记录:{}",USER_HISTORY);
});
return new Response(outputSpeech);
}
@@ -336,7 +336,7 @@ public class DplBotService extends BaseBot {
}
try {
Future future = POOL.submit(new Task(intentRequest, this));
- future.get(2500, TimeUnit.MILLISECONDS);
+ future.get(2200, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException e) {
log.error("获取任务执行结果出错:{}", e.toString());
return buildErrorResponse(SORRY_UNCATCH);
@@ -412,6 +412,16 @@ public class DplBotService extends BaseBot {
}
String componentId = userEvent.getPayload().getComponentId();
String componentPrefix;
+// if ("frameTxtOver".equals(componentId)) {
+// ExecuteCommands commands = new ExecuteCommands();
+// SetStateCommand setState = new SetStateCommand();
+// setState.setComponentId("frameTxt");
+// setState.setState("text");
+// setState.setValue("233333333333333333333");
+// commands.addCommand(setState);
+// this.addDirective(commands);
+// return new Response();
+// }
if ("audio".equals(componentId)){
setExpectSpeech(true);
}
@@ -601,11 +611,17 @@ public class DplBotService extends BaseBot {
}
} else if (PRE_CATEGORY.equals(componentPrefix)) {
String category = componentId.substring(5);
- displayCategoryProd(category);
- CATEGORY_PROD_HEAD.setHeaderTitle(category);
- RenderDocument render = new RenderDocument(CATEGORY_PROD);
+// displayCategoryProd(category);
+// CATEGORY_PROD_HEAD.setHeaderTitle(category);
+// RenderDocument render = new RenderDocument(CATEGORY_PROD);
+ RecommandDocument document = RecommendUtil.getCategory(0, category);
+ if (document == null) return buildErrorResponse("不好意思该分类还没有作品");
+ RenderDocument render = new RenderDocument(document);
+ this.setSessionAttribute("category",category);
this.addDirective(render);
this.addDirective(new PushStack());
+ this.setSessionAttribute("pageSign","5");
+ this.setSessionAttribute("trace","05");
}
// else if ("funnyChange".equals(componentId)) {
// ExecuteCommands executeCommands = new ExecuteCommands();
@@ -809,17 +825,17 @@ public class DplBotService extends BaseBot {
return dataList;
}
- private void displayCategoryProd(String categoryName) {
- ArrayList dataList = new ArrayList<>();
- for (GameProjectTb projectInfo : CATEGORY_PRODUCT_LIST.get(categoryName)) {
- String productName = correctName(projectInfo.getName());
- String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(projectInfo.getName()).toString();
- String src = new StringBuilder(Constants.IMG_PREFIX).append(projectInfo.getBannerImgUrl()).toString();
- Data data = new Data(src, productName, imageId);
- dataList.add(data);
- }
- CATEGORY_PROD_LIST.setData(dataList);
- }
+// private void displayCategoryProd(String categoryName) {
+// ArrayList dataList = new ArrayList<>();
+// for (GameProjectTb projectInfo : CATEGORY_PRODUCT_LIST.get(categoryName)) {
+// String productName = correctName(projectInfo.getName());
+// String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(projectInfo.getName()).toString();
+// String src = new StringBuilder(Constants.IMG_PREFIX).append(projectInfo.getBannerImgUrl()).toString();
+// Data data = new Data(src, productName, imageId);
+// dataList.add(data);
+// }
+// CATEGORY_PROD_LIST.setData(dataList);
+// }
private Integer getUserSendFlowerNum(String productId) {
AppFlowerTBTintRepository repository = BaseHolder.getBean("appFlowerTBTintRepository");
@@ -1120,6 +1136,10 @@ public class DplBotService extends BaseBot {
String intentName = getIntent().getName();
OverTimeDetail detail = new OverTimeDetail();
log.info("Intent name:{}",intentName);
+ if ("ai.dueros.common.default_intent".equals(intentName) || "funny".equals(intentName)) {
+ dealDefaultIntent(intentRequest, detail, userId, intentName, null);
+ return;
+ }
if ("load".equals(intentName)) {
detail.setResponse(load());
LAST_OUTTIME_RESULT.put(userId, detail);
@@ -1134,9 +1154,7 @@ public class DplBotService extends BaseBot {
dplBotService.setSessionAttribute(BACK_TRACE,null);
detail.getDirectives().add(renderDocument);
detail.getAttributes().put(BACK_TRACE, null);
- sendCancellToTerminate(userId);
- dplBotService.setSessionAttribute(BACK_TRACE,null);
- detail.getAttributes().put(BACK_TRACE,null);
+ if (trace != null && StringUtils.endsWith(trace,File.separator)) sendCancellToTerminate(userId);
} else if (StringUtils.endsWith(trace,File.separator)){
String botAccount = trace.substring(2, trace.length()-1);
log.info("返回作品的id:{}", botAccount);
@@ -1212,6 +1230,7 @@ public class DplBotService extends BaseBot {
dplBotService.setSessionAttribute(BACK_TRACE, "03");
detail.getAttributes().put(BACK_TRACE, "03");
detail.getDirectives().add(render);
+ detail.setResponse(buildErrorResponse(new StringBuilder("已为您返回到推荐页").toString()));
break;
}
case '4': {
@@ -1230,6 +1249,27 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put(BACK_TRACE, "04");
break;
}
+ case '5':{
+ String category = getSessionAttribute("category");
+ if (category == null) {
+ RenderDocument renderDocument = new RenderDocument(LunchUtils.getLunchDocument());
+ dplBotService.addDirective(renderDocument);
+ dplBotService.setSessionAttribute(BACK_TRACE,null);
+ detail.getDirectives().add(renderDocument);
+ detail.getAttributes().put(BACK_TRACE, null);
+ } else {
+ String count = getSessionAttribute("comCnt");
+ int pageIndex = 0;
+ if (count != null) pageIndex = Integer.parseInt(count)-1;
+ RecommandDocument document = RecommendUtil.getCategory(pageIndex, category);
+ RenderDocument render = new RenderDocument(document);
+ addDirective(render);
+ detail.getDirectives().add(render);
+ detail.setResponse(buildErrorResponse(new StringBuilder("已为您返回到")
+ .append(category).append("分类第").append(pageIndex+1).append("页").toString()));
+ }
+ break;
+ }
}
}
LAST_OUTTIME_RESULT.put(userId, detail);
@@ -1284,25 +1324,80 @@ public class DplBotService extends BaseBot {
detail.setResponse(dealOpenNumInHome(num, detail));
LAST_OUTTIME_RESULT.put(userId, detail);
return;
+ } else if (trace.length() > 2) {
+ detail.setResponse(buildErrorResponse("客官,您在这个页面想打开啥"));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
}
- String collectToken = getSessionAttribute(PRE_COLLE);
- String rankToken = getSessionAttribute("ranking");
- String recommengToken = getSessionAttribute("recommand");
- log.info("openNum slot value:{}", getSlot("sys.number"));
- if (collectToken != null) {
- detail.setResponse(dealOpenNum(collectToken, detail));
- //LAST_OUTTIME_RESULT.put(userId, dealOpenNum(collectToken));
- } else if (rankToken != null){
- detail.setResponse(dealOpenNum(rankToken,detail));
- //LAST_OUTTIME_RESULT.put(userId, dealOpenNum(rankToken));
- } else if (recommengToken != null) {
- detail.setResponse(dealOpenNumInRecommend(recommengToken,detail));
- //LAST_OUTTIME_RESULT.put(userId, dealOpenNum(recommengToken));
- } else {
- OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "屏幕上的图标都是可以点击的哦");
- detail.getResponse().setOutputSpeech(outputSpeech);
- //LAST_OUTTIME_RESULT.put(userId, new Response(outputSpeech));
+ char page = trace.charAt(1);
+ switch (page){
+ case '1':
+ case '2': detail.setResponse(dealOpenNum(getSessionAttribute(PRE_COLLE), detail)); break;
+ case '3': detail.setResponse(dealOpenNumInRecommend(getSessionAttribute("recommand"),detail)); break;
+ case '4': detail.setResponse(dealOpenNum(getSessionAttribute("ranking"),detail)); break;
+ case '5': {
+ String count = getSessionAttribute("comCnt");
+ int pageIndex = 0;
+ if (count != null) pageIndex = Integer.parseInt(count)-1;
+ String numStr = getSlot("sys.number");
+ int num = 1;
+ if (numStr != null) num = Integer.parseInt(numStr);
+ List categoryBots = ScheduleService.getCategoryProductIdList().get(getSessionAttribute("category"));
+ if (num <= 0 || num > categoryBots.size()) {
+ detail.setResponse(buildErrorResponse("这个数字超出了范围,作品的序号已显示在图片左上角"));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ }
+ String botId = categoryBots.get(pageIndex*16+num-1);
+ String name = ScheduleService.getProductIdDetail().get(botId).getName();
+ Response response;
+ if (doesUserPlayed(botId)) response = directInProduct(correctName(name), botId, detail);
+ else response = enterProductInfo(correctName(name), detail);
+ detail.setResponse(response);
+ break;
+ }
+ default:{
+ OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "屏幕上的图标都是可以点击的哦");
+ detail.getResponse().setOutputSpeech(outputSpeech);
+ }
}
+// String collectToken = getSessionAttribute(PRE_COLLE); //collect,history
+// String rankToken = getSessionAttribute("ranking");
+// String recommengToken = getSessionAttribute("recommand");
+// String category = getSessionAttribute("category");
+// log.info("openNum slot value:{}", getSlot("sys.number"));
+// if (collectToken != null) {
+// detail.setResponse(dealOpenNum(collectToken, detail));
+// //LAST_OUTTIME_RESULT.put(userId, dealOpenNum(collectToken));
+// } else if (rankToken != null){
+// detail.setResponse(dealOpenNum(rankToken,detail));
+// //LAST_OUTTIME_RESULT.put(userId, dealOpenNum(rankToken));
+// } else if (recommengToken != null) {
+// detail.setResponse(dealOpenNumInRecommend(recommengToken,detail));
+// //LAST_OUTTIME_RESULT.put(userId, dealOpenNum(recommengToken));
+// } else if (category != null) {
+// String count = getSessionAttribute("comCnt");
+// int pageIndex = 0;
+// if (count != null) pageIndex = Integer.parseInt(count)-1;
+// String numStr = getSlot("sys.number");
+// int num = 1;
+// if (numStr != null) num = Integer.parseInt(numStr);
+// if (num > 16) {
+// detail.setResponse(buildErrorResponse("这个数字超出了范围,你可以说下一页"));
+// }else {
+// String botId = ScheduleService.getCategoryProductIdList().get(category).get(pageIndex*16+num-1);
+// String name = ScheduleService.getProductIdDetail().get(botId).getName();
+// Response response;
+// if (doesUserPlayed(botId)) response = directInProduct(correctName(name), botId, detail);
+// else response = enterProductInfo(correctName(name), detail);
+// detail.setResponse(response);
+// }
+// }
+// else {
+// OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "屏幕上的图标都是可以点击的哦");
+// detail.getResponse().setOutputSpeech(outputSpeech);
+// //LAST_OUTTIME_RESULT.put(userId, new Response(outputSpeech));
+// }
LAST_OUTTIME_RESULT.put(userId, detail);
return;
}
@@ -1384,6 +1479,23 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put("pageIndex", String.valueOf(index));
break;
}
+ case 5:{
+ String category = dplBotService.getSessionAttribute("category");
+ if (category == null) category = "古风";
+ String recommendNextCount = dplBotService.getSessionAttribute("comCnt");
+ if (recommendNextCount == null || "1".equals(recommendNextCount)) {
+ detail.setResponse(buildErrorResponse("客观,前面没啦,没法往前翻了"));
+ break;
+ }
+ int count = Integer.parseInt(recommendNextCount);
+ RecommandDocument document = RecommendUtil.getCategory(count-2,category);
+ RenderDocument render = new RenderDocument(document);
+ dplBotService.addDirective(render);
+ detail.getDirectives().add(render);
+ dplBotService.setSessionAttribute("comCnt",String.valueOf(count-1));
+ detail.getAttributes().put("comCnt",String.valueOf(count-1));
+ break;
+ }
default:{
detail.setResponse(buildErrorResponse("该功能还没实现"));
}
@@ -1479,6 +1591,25 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put("pageIndex", String.valueOf(index));
break;
}
+ case 5:{
+ String category = dplBotService.getSessionAttribute("category");
+ if (category == null) category = "古风";
+ String categoryNextCount = dplBotService.getSessionAttribute("comCnt");
+ int count = 1;
+ if (categoryNextCount != null) count = Integer.parseInt(categoryNextCount);
+ RecommandDocument document = RecommendUtil.getCategory(count,category);
+ if (document == null) {
+ detail.setResponse(buildErrorResponse("客观你已经翻到底了,没有更多了"));
+ break;
+ }
+ RenderDocument render = new RenderDocument(document);
+ dplBotService.addDirective(render);
+ detail.getDirectives().add(render);
+ String countStr = String.valueOf(count+1);
+ setSessionAttribute("comCnt",countStr);
+ detail.getAttributes().put("comCnt",countStr);
+ break;
+ }
default:{
detail.setResponse(buildErrorResponse("该功能还没实现"));
}
@@ -1718,136 +1849,149 @@ public class DplBotService extends BaseBot {
LAST_OUTTIME_RESULT.put(userId, detail);
}
return;
+ } else if ("start".equals(intentName)) {
+ String trace = getSessionAttribute("trace");
+ if (trace != null && trace.length() > 2 && !StringUtils.endsWith(trace,File.separator)) {
+ String botId = trace.substring(2);
+ String enterName = new StringBuilder("我要玩")
+ .append(ScheduleService.getProductIdDetail().get(botId).getName()).toString();
+ dealDefaultIntent(intentRequest, detail, userId, intentName, enterName);
+ }else {
+ dealDefaultIntent(intentRequest, detail, userId, intentName, null);
+ }
}
+ }
+ }
+ private void dealDefaultIntent(IntentRequest intentRequest, OverTimeDetail detail, String userId, String intentName,String word) {
+ if (word == null) {
Query query = intentRequest.getQuery();
- String userWord = null;
- if (query != null) userWord = query.getOriginal();
- if (userWord == null){
+ if (query != null) word = query.getOriginal();
+ if (word == null){
log.info("小度没有传来任何话语");
detail.setResponse(buildErrorResponse(SORRY_UNCATCH));
LAST_OUTTIME_RESULT.put(userId, detail);
//LAST_OUTTIME_RESULT.put(userId, buildErrorResponse(SORRY_UNCATCH));
return;
}
- QiWuResponse data = null;
- try {
- data = RequestTerminal.requestTerminate(userWord, userId);
- } catch (Exception e) {
- log.error("请求终端接口出错:", e.toString());
- }
- if (data == null) {
- detail.setResponse(buildErrorResponse(SORRY_UNCATCH));
- LAST_OUTTIME_RESULT.put(userId, detail);
- //LAST_OUTTIME_RESULT.put(userId, buildErrorResponse(SORRY_UNCATCH));
- return;
- }
- String text = data.getText();
- if ("funny".equals(intentName)) {
- FunnyDocument document = displayFunnyRecommandPage(text);
- if (document != null) {
- document.getMainTemplate().getItems().get(2).setSrc(data.getAudio());
- FUNNY_DEFAULT_DOCUMENT = document;
- RenderDocument render = new RenderDocument(document);
- dplBotService.addDirective(new PushStack());
- detail.getDirectives().add(new PushStack());
- dplBotService.addDirective(render);
- //detail.getDirectives().add(render);
- LAST_OUTTIME_RESULT.put(userId, detail);
- dplBotService.setSessionAttribute("pageSign", "6");
- detail.getAttributes().put("pageSign", "6");
- return;
- }
- log.info("funny出现问题");
- }
- //log.info("小悟返回:{}", text);
- text = text.substring(text.indexOf("】")+1);
- final String botAccount = ScheduleService.getNx2BotToHz1().get(data.getAipioneerUsername());
- if (botAccount == null) {
- detail.setResponse(buildErrorResponse("不支持该作品换一个吧"));
+ }
+ QiWuResponse data = null;
+ try {
+ data = RequestTerminal.requestTerminate(word, userId);
+ } catch (Exception e) {
+ log.error("请求终端接口出错:", e.toString());
+ }
+ if (data == null) {
+ detail.setResponse(buildErrorResponse(SORRY_UNCATCH));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, buildErrorResponse(SORRY_UNCATCH));
+ return;
+ }
+ String text = data.getText();
+ if ("funny".equals(intentName)) {
+ FunnyDocument document = displayFunnyRecommandPage(text);
+ if (document != null) {
+ document.getMainTemplate().getItems().get(2).setSrc(data.getAudio());
+ FUNNY_DEFAULT_DOCUMENT = document;
+ RenderDocument render = new RenderDocument(document);
+ addDirective(new PushStack());
+ detail.getDirectives().add(new PushStack());
+ addDirective(render);
+ //detail.getDirectives().add(render);
LAST_OUTTIME_RESULT.put(userId, detail);
- //LAST_OUTTIME_RESULT.put(userId, buildErrorResponse("不支持该作品换一个吧"));
+ setSessionAttribute("pageSign", "6");
+ detail.getAttributes().put("pageSign", "6");
return;
}
- String beforeBotAccount = getSessionAttribute("botAcc");
- if (ScheduleService.getExceptBotAccount().contains(botAccount)) {
- OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, text.substring(text.indexOf("】")+1));
- detail.getResponse().setOutputSpeech(outputSpeech);
- LAST_OUTTIME_RESULT.put(userId, detail);
- //LAST_OUTTIME_RESULT.put(userId, new Response(outputSpeech));
- }
- else if (!botAccount.equals(beforeBotAccount)) {
+ log.info("funny出现问题");
+ }
+ //log.info("小悟返回:{}", text);
+ text = text.substring(text.indexOf("】")+1);
+ final String botAccount = ScheduleService.getNx2BotToHz1().get(data.getAipioneerUsername());
+ if (botAccount == null) {
+ detail.setResponse(buildErrorResponse("不支持该作品换一个吧"));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, buildErrorResponse("不支持该作品换一个吧"));
+ return;
+ }
+ String beforeBotAccount = getSessionAttribute("botAcc");
+ if (ScheduleService.getExceptBotAccount().contains(botAccount)) {
+ OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, text.substring(text.indexOf("】")+1));
+ detail.getResponse().setOutputSpeech(outputSpeech);
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, new Response(outputSpeech));
+ }
+ else if (!botAccount.equals(beforeBotAccount)) {
// List
- container = PLAY_DOCUMENT.getMainTemplate().getItems().get(2).getItems();
// container.get(1).setSrc(data.getAudio());
// container.get(0).getItems().get(0).setText(text);
- String productName = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
- PlayDocument document = PlayUtils.getPlayDocument(correctName(productName), data.getAudio(), text);
- RenderDocument render = new RenderDocument(document);
- dplBotService.addDirective(render);
- detail.getDirectives().add(render);
- POOL.submit(() -> {
- XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
- XiaoDuHistoryTB historyTB = repository.getByXiaoduUserIdAndBotId(userId, botAccount);
- if (historyTB == null) {
- historyTB = new XiaoDuHistoryTB();
- historyTB.setLastTime(System.currentTimeMillis());
- historyTB.setBotId(botAccount);
- historyTB.setXiaoduUserId(userId);
- Timestamp timestamp = new Timestamp(System.currentTimeMillis());
- historyTB.setCreateTime(timestamp);
- historyTB.setUpdateTime(timestamp);
- log.info("插入历史数据:{}", botAccount);
- } else {
- historyTB.setLastTime(System.currentTimeMillis());
- log.info("更新历史数据:{}", botAccount);
- }
- repository.save(historyTB);
- });
- String trace = dplBotService.getSessionAttribute(BACK_TRACE);
- if (trace == null || trace.length() != 2) trace = "00";
- trace = new StringBuilder(trace).append(botAccount).append(File.separator).toString();
- dplBotService.setSessionAttribute(BACK_TRACE, trace);
- dplBotService.setSessionAttribute("botAcc", botAccount);
- detail.getAttributes().put("botAcc", botAccount);
- detail.getAttributes().put(BACK_TRACE,trace);
- LAST_OUTTIME_RESULT.put(userId, detail);
- //LAST_OUTTIME_RESULT.put(userId, new Response());
- } else {
-// ExecuteCommands executeCommands = new ExecuteCommands();
-// SetStateCommand audio = new SetStateCommand();
-// SetStateCommand textState = new SetStateCommand();
-// audio.setComponentId("audioCom");
-// audio.setState("src");
-// audio.setValue(data.getAudio());
-// textState.setComponentId("text");
-// textState.setState("text");
-// textState.setValue(text);
-//
-// executeCommands.addCommand(textState);
-// executeCommands.addCommand(audio);
+ String productName = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
+ PlayDocument document = PlayUtils.getPlayDocument(correctName(productName), data.getAudio(), text);
+ RenderDocument render = new RenderDocument(document);
+ addDirective(render);
+ detail.getDirectives().add(render);
+ POOL.submit(() -> {
+ XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
+ XiaoDuHistoryTB historyTB = repository.getByXiaoduUserIdAndBotId(userId, botAccount);
+ if (historyTB == null) {
+ historyTB = new XiaoDuHistoryTB();
+ historyTB.setLastTime(System.currentTimeMillis());
+ historyTB.setBotId(botAccount);
+ historyTB.setXiaoduUserId(userId);
+ Timestamp timestamp = new Timestamp(System.currentTimeMillis());
+ historyTB.setCreateTime(timestamp);
+ historyTB.setUpdateTime(timestamp);
+ log.info("插入历史数据:{}", botAccount);
+ } else {
+ historyTB.setLastTime(System.currentTimeMillis());
+ log.info("更新历史数据:{}", botAccount);
+ }
+ repository.save(historyTB);
+ });
+ String trace = getSessionAttribute(BACK_TRACE);
+ if (trace == null || trace.length() != 2) trace = "00";
+ trace = new StringBuilder(trace).append(botAccount).append(File.separator).toString();
+ setSessionAttribute(BACK_TRACE, trace);
+ setSessionAttribute("botAcc", botAccount);
+ detail.getAttributes().put("botAcc", botAccount);
+ detail.getAttributes().put(BACK_TRACE,trace);
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, new Response());
+ } else {
+ ExecuteCommands executeCommands = new ExecuteCommands();
+ SetStateCommand audio = new SetStateCommand();
+ SetStateCommand textState = new SetStateCommand();
+ audio.setComponentId("audioCom");
+ audio.setState("src");
+ audio.setValue(data.getAudio());
+ textState.setComponentId("text");
+ textState.setState("text");
+ textState.setValue(text);
+
+ executeCommands.addCommand(textState);
+ executeCommands.addCommand(audio);
// UpdateComponentCommand update = new UpdateComponentCommand();
// update.setComponentId("whole");
// update.setDocument(TempleUtils.getPlayUpdate(data.getAudio(), text));
// executeCommands.addCommand(update);
-// dplBotService.addDirective(executeCommands);
-// detail.getDirectives().add(executeCommands);
+ addDirective(executeCommands);
+ detail.getDirectives().add(executeCommands);
- String productName = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
- PlayDocument document = PlayUtils.getPlayDocument(correctName(productName), data.getAudio(), text);
- RenderDocument render = new RenderDocument(document);
- dplBotService.addDirective(render);
- detail.getDirectives().add(render);
- LAST_OUTTIME_RESULT.put(userId, detail);
- //LAST_OUTTIME_RESULT.put(userId, new Response());
- }
+// String productName = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
+// PlayDocument document = PlayUtils.getPlayDocument(correctName(productName), data.getAudio(), text);
+// RenderDocument render = new RenderDocument(document);
+// addDirective(render);
+// detail.getDirectives().add(render);
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, new Response());
}
}
private Response dealOpenNumInRecommend(String idsToken, OverTimeDetail overDetail) {
int collectNum = Integer.parseInt(getSlot("sys.number"));
String[] tokenList = new String(Base64.getDecoder().decode(idsToken)).split(File.separator);
- if (collectNum > tokenList.length) return buildErrorResponse("这个数字超出了范围");
+ if (collectNum > tokenList.length || collectNum <= 0) return buildErrorResponse("这个数字超出了范围");
OnProductDetail detail = ScheduleService.PRODUCT_ID_DETAIL.get(tokenList[collectNum-1]);
if (doesUserPlayed(detail.getBotAccount())) {
String productName = correctName(detail.getName());
@@ -1859,20 +2003,31 @@ public class DplBotService extends BaseBot {
private Response dealOpenNumInHome(int num, OverTimeDetail detail) {
if (num > 0 && num <= 10) {
- GameProjectTb bot = ScheduleService.getRankingList().get(num-1);
- if (doesUserPlayed(bot.getBotAccount())) return enterProductInfo(bot.getName(), detail);
+ GameProjectTb bot = ScheduleService.getRecommendList().get(num-1);
+ log.info("历史:作品id:{}",bot.getBotAccount());
+ if (!doesUserPlayed(bot.getBotAccount())) return enterProductInfo(bot.getName(), detail);
else return directInProduct(bot.getName(), bot.getBotAccount(), detail);
} else if (num > 10 && num <= 20) {
- GameProjectTb bot = ScheduleService.getRecommendList().get(num-11);
- if (doesUserPlayed(bot.getBotAccount())) return enterProductInfo(bot.getName(), detail);
+ GameProjectTb bot = ScheduleService.getRankingList().get(num-11);
+ log.info("历史:作品id:{}",bot.getBotAccount());
+ if (!doesUserPlayed(bot.getBotAccount())) return enterProductInfo(bot.getName(), detail);
else return directInProduct(bot.getName(), bot.getBotAccount(), detail);
} else if (num > 20 && num <= 30) {
String categoryName = ScheduleService.CATEGORY[num-21];
- displayCategoryProd(categoryName);
- CATEGORY_PROD_HEAD.setHeaderTitle(categoryName);
- RenderDocument render = new RenderDocument(CATEGORY_PROD);
+// displayCategoryProd(categoryName);
+// CATEGORY_PROD_HEAD.setHeaderTitle(categoryName);
+// RenderDocument render = new RenderDocument(CATEGORY_PROD);
+ RecommandDocument document = RecommendUtil.getCategory(0, categoryName);
+ if (document == null) return buildErrorResponse("不好意思该分类还没有作品");
+ RenderDocument render = new RenderDocument(document);
this.addDirective(render);
detail.getDirectives().add(render);
+ this.setSessionAttribute("category",categoryName);
+ detail.getAttributes().put("category",categoryName);
+ this.setSessionAttribute("trace","05");
+ detail.getAttributes().put("trace","05");
+ this.setSessionAttribute("pageSign","5");
+ detail.getAttributes().put("pageSign","5");
return buildErrorResponse(new StringBuilder("为您打开").append(categoryName).append("类作品").toString());
// this.addDirective(new PushStack());
// detail.getDirectives().add(new PushStack());
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
index be1f11c..ae27df4 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
@@ -41,8 +41,9 @@ public class ScheduleService implements InitializingBean {
static final List EXCEPT_BOT_ACCOUNT = new ArrayList<>();
static final String[] CATEGORY = {"古风", "儿童", "科幻", "占星", "恋爱", "灾难", "架空", "经营", "冒险", "武侠"};
- static final String[] CATEGORY_CHARAC={"gufeng","child","kehuan","zhanxing","lianai","zainan","jiakong","jingying","maoxian","wuxia"};
- static final ConcurrentHashMap> CATEGORY_PRODUCT_LIST = new ConcurrentHashMap<>();
+ private static final String[] CATEGORY_CHARAC={"gufeng","child","kehuan","zhanxing","lianai","zainan","jiakong","jingying","maoxian","wuxia"};
+
+ static final HashMap> CATEGORY_PRODUCT_ID_LIST = new HashMap<>();
private final GameProjectTbRepository gameProjectTbRepository;
@@ -71,6 +72,7 @@ public class ScheduleService implements InitializingBean {
public void initRankingList() {
new Thread(() -> {
RANKING_LIST = gameProjectTbRepository.findFirst10ByApplyStatusOrderByWatchDesc(1);
+ LunchUtils.setLunchDocument(LunchUtils.buildLunchDocument());
//log.info("排行榜:{}", RANKING_LIST);
}).start();
//log.error("更新排行榜出错:{}", e.getMessage());
@@ -80,6 +82,7 @@ public class ScheduleService implements InitializingBean {
public void initRecommendList() {
new Thread(() -> {
RECOMMEND_LIST = gameProjectTbRepository.recommendList();
+ LunchUtils.setLunchDocument(LunchUtils.buildLunchDocument());
//log.info("推荐:{}", RECOMMEND_LIST);
}).start();
//log.error("更新推荐页出错:{}", e.getMessage());
@@ -104,13 +107,15 @@ public class ScheduleService implements InitializingBean {
//log.error("更新推荐页出错:{}", e.getMessage());
}
- @Scheduled(cron = "0 0 1 ? * 7")
+ @Scheduled(cron = "0 0 1 * * ?")
public void initProductList() {
new Thread(() -> {
for (String category: CATEGORY) {
- List list = gameProjectTbRepository.categoryProject(category);
- CATEGORY_PRODUCT_LIST.put(category, list);
- log.info("分类{},作品列表{}", category, list);
+ //List list = gameProjectTbRepository.categoryProject(category);
+ List idList = gameProjectTbRepository.categoryProList(category);
+ CATEGORY_PRODUCT_ID_LIST.put(category, idList);
+ //CATEGORY_PRODUCT_LIST.put(category, list);
+ //log.info("分类{},作品列表{}", category, list);
}
}).start();
//log.error("更新分类作品列表出错:{}", e.getMessage());
@@ -141,7 +146,6 @@ public class ScheduleService implements InitializingBean {
public void shuffleAllProList() {
new Thread(() -> {
Collections.shuffle(ALL_ON_PRODUCT);
- LunchUtils.setLunchDocument(LunchUtils.buildLunchDocument());
}).start();
}
@@ -222,4 +226,8 @@ public class ScheduleService implements InitializingBean {
public static String[] getCategoryCharac() {
return CATEGORY_CHARAC;
}
+
+ public static HashMap> getCategoryProductIdList() {
+ return CATEGORY_PRODUCT_ID_LIST;
+ }
}
diff --git a/xiaoduhome/src/main/resources/static/json/frame.json b/xiaoduhome/src/main/resources/static/json/frame.json
index 415d6dd..bd849cd 100644
--- a/xiaoduhome/src/main/resources/static/json/frame.json
+++ b/xiaoduhome/src/main/resources/static/json/frame.json
@@ -5,7 +5,7 @@
"items": [
{
"type": "Text",
- "font-size": "31dp",
+ "font-size": "28dp",
"margin-left": "30dp"
},
{
@@ -20,8 +20,8 @@
"items": [
{
"type": "Text",
- "font-size": "23dp",
- "color": "rgb(255,255,255)"
+ "font-size": "22dp",
+ "color": "rgba(255,255,255,0.8)"
}
]
}
diff --git a/xiaoduhome/src/main/resources/static/json/textRota.json b/xiaoduhome/src/main/resources/static/json/textRota.json
index b792e88..6a40152 100644
--- a/xiaoduhome/src/main/resources/static/json/textRota.json
+++ b/xiaoduhome/src/main/resources/static/json/textRota.json
@@ -38,7 +38,13 @@
"attribute": "rotation",
"duration": 3000,
"repeatCount": 4,
- "repeatMode": "reverse"
+ "repeatMode": "reverse",
+ "onComplete": [
+ {
+ "type": "SendEvent",
+ "componentId": "test2333333"
+ }
+ ]
}
]
},
--
libgit2 0.27.1