diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 62e43e0..c881282 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,17 +7,21 @@
+
+
+
+
+
+
+
+
-
-
-
-
@@ -61,68 +65,65 @@
-
+
-
-
+
+
+
+
+
+
+
-
+
-
-
+
+
-
-
+
-
+
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
@@ -131,29 +132,26 @@
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
+
+
@@ -172,36 +170,36 @@
- variableText
- csvUtilByCommon
- filePath
- pattern
- data
- log.info
- folder
- hasCombineAndMarchAlsoHas
- text
- recordFolder
- filePathList
- COMBINE_FILE
- THIRD_PARTY_WITH_ITS_PER
- jump
- ONLINE_ID_2_URL
- URL_2_PERSON_TON
- OFFLINE_SERVER
- tts
- delRecordCallbackUrl
- init_person
- PERSON_INFO_ONLINE
- PERSON_INFO_OFFLINE
- OFFLINE_2_ONLINE
- 16
- RECOMMEND_LIST
- tts_ls
- ALL_ON_PRODUCT
$
Constants.PRE_PRODUCT_IMG
pageNum
+ rootFolder
+ uploadFolder
+ imgSrc
+ imgName
+ productName
+ n
+ mainTemplate
+ ranking
+ count
+ "count"
+ RANKING_LIST
+ RECOMMEND_LIST
+ ALL_ON_PRODUCT
+ PRODUCT_NAME_DETAIL
+ System.out.println
+ ASIDE_IMG
+ allProductCount
+ CATEGORY_PRODUCT_ID_LIST
+ 16
+ recommand
+ onIntent
+ rankDocument
+ RANK_ORDER_IDs
+ buildImgFrmTxtContainerFirstRow
+ LUNCH_LIST_CATEGORY_CON
+ setMarginBottom
+ Task
OPENID_CACHE
@@ -217,13 +215,6 @@
@@ -300,8 +298,8 @@
-
-
+
+
@@ -313,8 +311,6 @@
-
-
@@ -325,51 +321,36 @@
-
-
-
-
-
-
-
+
-
+
-
-
+
-
-
+
-
-
+
-
-
-
-
-
-
@@ -377,21 +358,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -401,6 +371,8 @@
+
+
@@ -411,6 +383,8 @@
+
+
@@ -422,6 +396,7 @@
+
@@ -433,7 +408,7 @@
-
+
@@ -476,10 +451,20 @@
+
+
+
+
+
+
+
+
+
+
@@ -493,7 +478,7 @@
-
+
@@ -1064,7 +1049,9 @@
-
+
+
+
@@ -1074,7 +1061,7 @@
-
+
@@ -1086,7 +1073,7 @@
-
+
@@ -1096,17 +1083,17 @@
-
+
-
+
-
+
@@ -1173,384 +1160,384 @@
-
+
-
-
+
+
-
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
+
+
+
+
+
+
+
-
+
+
+
+
+
-
+
-
-
+
+
-
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
-
-
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
-
+
-
-
-
-
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
-
+
-
-
-
-
-
+
+
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 a73b23e..6ec60ca 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
@@ -232,6 +232,9 @@ public class TTService {
}
List> futures = new ArrayList<>();
List file_ls = new ArrayList<>();
+ String rootFolder = new StringBuilder(Initialize.getAudioDir()).append(File.separator).append(botName).append(File.separator).toString();
+ String uploadFolder = new StringBuilder(rootFolder).append(Initialize.getUploadedDir()).append(File.separator).toString();
+ //String combineFolder = new StringBuilder(rootFolder).append("combine").append(File.separator).toString();
// 第三方语音是否生成,为0则代表不处理该第三方语音
boolean geneThird = request.getGen3rd() == null || request.getGen3rd() != 0;
if (infoList != null && infoList.size() != 0) {
@@ -247,8 +250,10 @@ public class TTService {
String url = null; //moodUrl
String tone = "正常"; // 第三方请求的情绪为:正常
+
// 是否是第三方请求
boolean isPersonThirdParty = Initialize.getThirdPartyTts().contains(person);
+
// 非第三方请求需要对person及tone进行校正,以得到确实存在的url
if (!isPersonThirdParty) {
// person不存在则置为默认person
@@ -280,24 +285,22 @@ public class TTService {
String fileName = TTSUtils.buildMP3Filename(text);
// 含有npcName字段则先去人工合成目录下找寻,人工没有则去合成目录寻找
if (StringUtils.isNotBlank(npcName)) {
- String path = StringUtils.join(new String[]{Initialize.getAudioDir(), botName, Initialize.getUploadedDir(),npcName, fileName}, File.separator);
+ String path = new StringBuilder(uploadFolder).append(npcName).append(File.separator).append(fileName).toString();
+ //String path = StringUtils.join(new String[]{Initialize.getAudioDir(), botName, Initialize.getUploadedDir(),npcName, fileName}, File.separator);
// log.info("111");
if (TTSUtils.doesFileExist(path)) {
filepath = path;
}
-// else {
-// Pattern pattern = Pattern.compile(TTSUtils.getAbRegex());
-// if (pattern.matcher(text).find()) {
-// String combineRecordPath = StringUtils.join(new String[]{Initialize.getAudioDir(), botName, person, tone, Initialize.getUploadedDir(), fileName}, File.separator);
-// if (TTSUtils.doesFileExist(combineRecordPath)) filepath = combineRecordPath;
-// }
+// else if (text.indexOf("\uD83C\uDD70") != -1){
+//
// }
//log.info("222");
}
if (filepath == null) {
//log.info("333");
// 目录为:(audio_dir)/botname/person/tone
- String folder = StringUtils.join(new String[]{Initialize.getAudioDir(), botName, person, tone}, File.separator);
+ String folder = new StringBuilder(rootFolder).append(person).append(File.separator).append(tone).toString();
+ //String folder = StringUtils.join(new String[]{Initialize.getAudioDir(), botName, person, tone}, File.separator);
boolean createDirRes = TTSUtils.makedir(folder);
if (!createDirRes) {
log.error("tts_ls创建目录:{}失败",folder);
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java
index d31b073..c435340 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java
@@ -268,6 +268,6 @@ public class Test {
System.out.println(mr.replaceAll("\\W", ""));
String ssss = "你当{/dang1/}前分{/fen1/}数{/shu4/}是\uD83C\uDD700\uD83C\uDD71。";
- System.out.println(TTSUtils.buildMP3Filename(ssss));
+ System.out.println(ssss.indexOf("\uD83C\uDD70"));
}
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java
index 6d739e6..636d3b5 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java
@@ -34,7 +34,7 @@ public interface Constants {
String UNIT_PRICE = "1";
Integer CO_HI_PAGE_SIZE = 4;
- Integer RE_RA_CA_PAGE_SIZE = 16;
+ Integer RE_RA_CA_PAGE_SIZE = 12;
interface DPL_COMPONENT_ID {
String FLOWE = "flowe";
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryPagePojo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryPagePojo.java
index b8e9efd..368bed9 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryPagePojo.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryPagePojo.java
@@ -24,6 +24,7 @@ public class CollectHistoryPagePojo {
private String type;
private String position;
private String left;
+ private String right;
private String width;
private String bottom;
private String height;
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java
index 2d08dae..ca0432a 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java
@@ -31,7 +31,7 @@ public class CollectHistoryUtils {
allContainer.setWidth("100%");
allContainer.setPaddingRight("15dp");
allContainer.setPaddingLeft("15dp");
- allContainer.setPaddingBottom("180dp");
+ allContainer.setPaddingBottom("130dp");
CollectHistoryPagePojo list = new CollectHistoryPagePojo();
list.setType("List");
@@ -109,24 +109,24 @@ public class CollectHistoryUtils {
author.setMarginLeft("100dp");
author.setTextOverflow("ellipsis");
- // divide
- CollectHistoryPagePojo divide = new CollectHistoryPagePojo();
- divide.setType("Frame");
- divide.setPosition("absolute");
- divide.setMarginTop("90dp");
- divide.setWidth("100%");
- divide.setBorderColor("rgba(255,255,255,0.5)");
- divide.setBorderWidth("1dp");
+// // divide
+// CollectHistoryPagePojo divide = new CollectHistoryPagePojo();
+// divide.setType("Frame");
+// divide.setPosition("absolute");
+// divide.setMarginTop("90dp");
+// divide.setWidth("100%");
+// divide.setBorderColor("rgba(255,255,255,0.3)");
+// divide.setBorderWidth("0.5dp");
- main.setItems(Arrays.asList(num,image, nameIntroCon, author, divide));
+ main.setItems(Arrays.asList(num,image, nameIntroCon, author));
return main;
}
private static CollectHistoryPagePojo buildPageButton(int curIndex, int num) {
CollectHistoryPagePojo fCon = new CollectHistoryPagePojo();
fCon.setType("Container");
- fCon.setLeft("447dp");
- fCon.setBottom("70dp");
+ fCon.setTop("20dp");
+ fCon.setRight("15dp");
fCon.setPosition("absolute");
CollectHistoryPagePojo frame = new CollectHistoryPagePojo();
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
index 55162fb..8b1c533 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
@@ -59,7 +59,7 @@ public class TempleUtils {
FRAME_RAKKING.getItems().get(1).getItems().get(0).setText("小度小度,打开排行榜");
FRAME_RAKKING.getItems().get(0).setText("排行榜");
FRAME_RECOMMAND = JSON.parseObject(getDPLTemple("static/json/frame.json"), FrameTemple.class);
- FRAME_RECOMMAND.getItems().get(1).getItems().get(0).setText("小度小度,打开推荐");
+ FRAME_RECOMMAND.getItems().get(1).getItems().get(0).setText("小度小度,打开推荐页");
FRAME_RECOMMAND.getItems().get(0).setText("推荐作品");
FRAME_CATEGORY = JSON.parseObject(getDPLTemple("static/json/frame.json"), FrameTemple.class);
FRAME_CATEGORY.getItems().get(1).getItems().get(0).setText("小度小度,打开第二十一个");
@@ -269,11 +269,11 @@ public class TempleUtils {
public static List buildCategoryDataList() {
ArrayList dataList = new ArrayList<>();
- int i = 21;
+ int i = 17;
for (String cateName : ScheduleService.getCATEGORY()) {
String imageId = new StringBuilder(PRE_CATEGORY).append(cateName).toString();
String imgSrc = new StringBuilder(IMG_CUSTOM_PREFIX)
- .append(ScheduleService.getCategoryCharac()[i-21]).append(".png").toString();
+ .append(ScheduleService.getCategoryCharac()[i-17]).append(".png").toString();
LunchBotData data = new LunchBotData(imgSrc, imageId, cateName);
data.setNum(i++);
dataList.add(data);
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 f23b696..36a26bd 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
@@ -4,7 +4,6 @@ import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Component;
import java.util.*;
@@ -34,7 +33,7 @@ public class LunchUtils {
conRecommend.setFirstItem(Collections.singletonList(TempleUtils.getFrameRecommand()));
conRecommend.setMarginTop("30dp");
- LunchPojo conRanking = buildLunchList(TempleUtils.buildDataList(ScheduleService.getRankingList(), 11));
+ LunchPojo conRanking = buildLunchList(TempleUtils.buildDataList(ScheduleService.getRankingList(), 9));
conRanking.setFirstItem(Collections.singletonList(TempleUtils.getFrameRakking()));
LunchPojo conCategory = buildLunchCategoryList(TempleUtils.buildCategoryDataList());
@@ -217,7 +216,7 @@ public class LunchUtils {
LunchPojo logo = new LunchPojo();
logo.setType("Image");
logo.setPosition("absolute");
- logo.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/uncollec.png");
+ logo.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/collec.png");
logo.setWidth("40dp");
logo.setHeight("40dp");
logo.setScaleType("centerInside");
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayPojo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayPojo.java
index 0b8f5cc..86854bf 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayPojo.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayPojo.java
@@ -20,6 +20,7 @@ public class PlayPojo {
private String position;
private String left;
private String top;
+ private String bottom;
private String src;
private String height;
private String width;
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java
index 7c2cec8..41aa615 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java
@@ -22,20 +22,67 @@ public class PlayUtils {
private static final PlayPojo PLAY_UN_COLLECT = buildUnCollect();
public static PlayDocument getPlayDocument(String headerName, String aside, String asideImg,
- String audio, String text, boolean collected) {
+ String audio, String text) {
PlayDocument document = new PlayDocument();
document.setDuration(180000);
PlayMainTemplate mainTemplate = new PlayMainTemplate();
document.setMainTemplate(mainTemplate);
PlayPojo collectComponent = PLAY_COLLECT;
- if (!collected) collectComponent = PLAY_UN_COLLECT;
+ //if (!collected) collectComponent = PLAY_UN_COLLECT;
mainTemplate.setItems(Arrays.asList(PLAY_BACK_IMG, buildLunchHead(headerName), PLAY_LOGO,
buildAside(aside), buildAsideImage(asideImg), buildWholeContainer(audio, text)
,collectComponent, PLAY_FLOWER, PLAY_HINT));
return document;
}
- public static PlayPojo buildCollect() {
+ private static PlayPojo buildFlower() {
+ PlayPojo backGroundImg = new PlayPojo();
+ backGroundImg.setType("Image");
+ backGroundImg.setPosition("absolute");
+ backGroundImg.setRight("120dp");
+ backGroundImg.setTop("20dp");
+ backGroundImg.setHeight("50dp");
+ backGroundImg.setWidth("50dp");
+ backGroundImg.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/flower.png");
+ backGroundImg.setOnClick(Collections.singletonList(new Event("SendEvent", "playButton")));
+ backGroundImg.setScaleType("fitCenter");
+
+ return backGroundImg;
+ }
+
+ private static PlayPojo buildCollect() {
+ PlayPojo backGroundImg = new PlayPojo();
+ backGroundImg.setType("Image");
+ backGroundImg.setPosition("absolute");
+ backGroundImg.setRight("30dp");
+ backGroundImg.setTop("20dp");
+ backGroundImg.setHeight("50dp");
+ backGroundImg.setWidth("50dp");
+ backGroundImg.setComponentId("playCollect");
+ backGroundImg.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/collec.png");
+ backGroundImg.setOnClick(Collections.singletonList(new Event("SendEvent", "playButton")));
+ backGroundImg.setScaleType("fitCenter");
+
+ return backGroundImg;
+ }
+
+ private static PlayPojo buildUnCollect() {
+ PlayPojo backGroundImg = new PlayPojo();
+ backGroundImg.setType("Image");
+ backGroundImg.setPosition("absolute");
+ backGroundImg.setRight("30dp");
+ backGroundImg.setTop("20dp");
+ backGroundImg.setHeight("50dp");
+ backGroundImg.setWidth("50dp");
+ backGroundImg.setComponentId("playCollect");
+ backGroundImg.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/uncollec.png");
+ backGroundImg.setOnClick(Collections.singletonList(new Event("SendEvent", "playButton")));
+ backGroundImg.setScaleType("fitCenter");
+
+ return backGroundImg;
+ }
+
+ private static PlayPojo buildCollectFrame() {
PlayPojo collectCon = new PlayPojo();
collectCon.setType("Container");
collectCon.setLeft("300dp");
@@ -71,7 +118,7 @@ public class PlayUtils {
return collectCon;
}
- public static PlayPojo buildUnCollect() {
+ private static PlayPojo buildUnCollectFrame() {
PlayPojo collectCon = new PlayPojo();
collectCon.setType("Container");
collectCon.setLeft("300dp");
@@ -107,7 +154,7 @@ public class PlayUtils {
return collectCon;
}
- public static PlayPojo buildFlower() {
+ private static PlayPojo buildFlowerFrame() {
PlayPojo flowerCon = new PlayPojo();
flowerCon.setType("Container");
flowerCon.setLeft("600dp");
@@ -142,7 +189,7 @@ public class PlayUtils {
return flowerCon;
}
- public static PlayPojo buildWholeContainer(String audioSrc, String textContent) {
+ private static PlayPojo buildWholeContainer(String audioSrc, String textContent) {
PlayPojo whole = new PlayPojo();
whole.setType("Container");
whole.setHeight("100%");
@@ -153,7 +200,7 @@ public class PlayUtils {
textContainer.setType("Container");
textContainer.setPadding("35dp");
textContainer.setPosition("absolute");
- textContainer.setTop("140dp");
+ textContainer.setBottom("250dp");
PlayPojo text = new PlayPojo();
text.setType("Text");
@@ -206,8 +253,8 @@ public class PlayUtils {
logo.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/logo.png");
logo.setWidth("200dp");
logo.setHeight("60dp");
- logo.setTop("10dp");
- logo.setRight("10dp");
+ logo.setTop("20dp");
+ logo.setLeft("10dp");
return logo;
}
@@ -215,11 +262,12 @@ public class PlayUtils {
PlayPojo asideContainer = new PlayPojo();
asideContainer.setType("Container");
asideContainer.setPosition("absolute");
- asideContainer.setLeft("130dp");
- asideContainer.setTop("135dp");
+ asideContainer.setLeft("115dp");
+ asideContainer.setTop("185dp");
PlayPojo frame = new PlayPojo();
frame.setType("Frame");
+ frame.setWidth("70dp");
frame.setPaddingLeft("50dp");
frame.setPaddingRight("15dp");
frame.setPaddingVertical("10dp");
@@ -241,8 +289,8 @@ public class PlayUtils {
PlayPojo asideContainer = new PlayPojo();
asideContainer.setType("Container");
asideContainer.setPosition("absolute");
- asideContainer.setLeft("60dp");
- asideContainer.setTop("120dp");
+ asideContainer.setLeft("35dp");
+ asideContainer.setTop("167dp");
PlayPojo frame = new PlayPojo();
frame.setType("Frame");
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java
index 84bc5d7..9b4304f 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java
@@ -46,7 +46,7 @@ public class ProductInfoUtils {
coverImage.setWidth("280dp");
coverImage.setHeight("280dp");
coverImage.setBorderRadius("30dp");
- coverImage.setScaleType("fitCenter");
+ coverImage.setScaleType("fitXY");
coverImage.setMarginLeft("50dp");
coverImage.setMarginTop("12dp");
coverImage.setComponentId("imgPro");
@@ -153,7 +153,7 @@ public class ProductInfoUtils {
iconCon.setType("Container");
iconCon.setPosition("absolute");
iconCon.setFlexDirection("row");
- iconCon.setBottom("160dp");
+ iconCon.setBottom("170dp");
iconCon.setItems(Arrays.asList(buildStart(startComponId), buildFlower(flowerId, flowerText),
buildCollect(collectId, collectSrc, collectText)));
return iconCon;
@@ -187,7 +187,7 @@ public class ProductInfoUtils {
ProductInfoPojo flowerCon = new ProductInfoPojo();
flowerCon.setType("Container");
flowerCon.setAlignItems("center");
- flowerCon.setMarginLeft("130dp");
+ flowerCon.setMarginLeft("120dp");
flowerCon.setOnClick(Collections.singletonList(new Event("SendEvent", flowerId)));
ProductInfoPojo image = new ProductInfoPojo();
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandPojo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandPojo.java
index fef6137..65d203d 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandPojo.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandPojo.java
@@ -25,6 +25,7 @@ public class RecommandPojo {
private String position;
private String top;
private String left;
+ private String right;
private String src;
private String headerTitle;
private Boolean hasBackIcon;
@@ -53,5 +54,8 @@ public class RecommandPojo {
private String backgroundColor;
@JsonProperty("flex-direction")
private String flexDirection;
-
+ @JsonProperty("justify-content")
+ private String justifyContent;
+ private String looping;
+ private String autoplay;
}
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 9f5c62b..c301735 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
@@ -8,6 +8,8 @@ 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;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
import java.io.File;
import java.util.*;
@@ -18,22 +20,31 @@ import static ai.qiwu.com.xiaoduhome.common.Constants.RE_RA_CA_PAGE_SIZE;
* @author 苗权威
* @dateTime 19-9-5 上午11:25
*/
+@Slf4j
public class RecommendUtil {
private static final RecommandPojo RECOM_BACK_IMG = buildRecomendBackgroundImg();
private static final RecommandPojo RECOM_HEAD = buildRecommendHead();
+ private static final RecommandPojo RANK_HEAD = buildRankHead();
+ private static final RecommandPojo FUNNY_HEAD = buildFunnyHead();
private static final RecommandPojo RECOM_FOOTER = buildRecommendFooter();
+ private static final RecommandPojo RANK_CATEGORY_FOOTER = buildRankCategoryFooter();
+ private static final RecommandPojo FUNNY_FOOTER = buildFunnyFooter();
private static final RecommandPojo RECOM_LIST_CON = buildImgFrmTxtContainer();
+ private static final RecommandPojo FUNNY_LIST_CON = buildImgFrmTxtContainerFunny();
+
+ private static volatile RecommandDocument rankDocument;
public static RecommandDocument getRecommendDocument(int num) {
RecommandDocument document = new RecommandDocument();
+ document.setDuration(120000);
RecommandMainTemplate mainTemplate = new RecommandMainTemplate();
document.setMainTemplate(mainTemplate);
RecommandPojo scrollView = new RecommandPojo();
scrollView.setType("ScrollView");
scrollView.setWidth("100%");
- scrollView.setMarginBottom("93dp");
+ scrollView.setMarginBottom("140dp");
scrollView.setDirection("vertical");
List scrollList = new ArrayList<>();
scrollView.setItems(scrollList);
@@ -64,13 +75,14 @@ public class RecommendUtil {
public static RecommandDocument getCategory(int num, String category) {
RecommandDocument document = new RecommandDocument();
+ document.setDuration(120000);
RecommandMainTemplate mainTemplate = new RecommandMainTemplate();
document.setMainTemplate(mainTemplate);
RecommandPojo scrollView = new RecommandPojo();
scrollView.setType("ScrollView");
scrollView.setWidth("100%");
- scrollView.setMarginBottom("93dp");
+ scrollView.setMarginBottom("140dp");
scrollView.setDirection("vertical");
List scrollList = new ArrayList<>();
scrollView.setItems(scrollList);
@@ -88,32 +100,36 @@ public class RecommendUtil {
String botId = categoryIdList.get(i);
bots.add((ScheduleService.getProductIdDetail().get(botId)));
}
- StringBuilder botIds = new StringBuilder();
+ //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)));
+ scrollList.add(buildRecommendList(getListDataNoIds(count, begin, end, bots)));
count++;
begin = end;
}
- mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,buildRecommendCollectHead(category),scrollView,RECOM_FOOTER));
+ int pageSize = categoryIdList.size() / RE_RA_CA_PAGE_SIZE + (categoryIdList.size()%RE_RA_CA_PAGE_SIZE == 0 ? 0:1);
+ mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,buildRecommendCollectHead(category),
+ scrollView,buildPageButton(num+1, pageSize),RANK_CATEGORY_FOOTER));
- botIds.deleteCharAt(botIds.length()-1);
- String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
- document.setRecommendIdList(idToken);
+// botIds.deleteCharAt(botIds.length()-1);
+// String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
+// document.setRecommendIdList(idToken);
return document;
}
public static RecommandDocument getRankDocumentFirstPage() {
+ if (rankDocument != null) return rankDocument;
RecommandDocument document = new RecommandDocument();
+ document.setDuration(120000);
RecommandMainTemplate mainTemplate = new RecommandMainTemplate();
document.setMainTemplate(mainTemplate);
RecommandPojo scrollView = new RecommandPojo();
scrollView.setType("ScrollView");
scrollView.setWidth("100%");
- scrollView.setMarginBottom("93dp");
+ scrollView.setMarginBottom("140dp");
scrollView.setDirection("vertical");
List scrollList = new ArrayList<>();
scrollView.setItems(scrollList);
@@ -121,27 +137,190 @@ public class RecommendUtil {
RecommandPojo rowContainer = new RecommandPojo();
rowContainer.setType("Container");
rowContainer.setFlexDirection("row");
+ rowContainer.setMarginLeft("20dp");
+ rowContainer.setMarginBottom("55dp");
+ StringBuilder botIds = new StringBuilder();
List list = ScheduleService.getRANK_ORDER_IDs();
+ //log.info("RANK_ORDER_ID_LIST size = "+list.size());
OnProductDetail first = list.get(0);
+ botIds.append(first.getBotAccount()).append(File.separator);
OnProductDetail second = list.get(1);
+ botIds.append(second.getBotAccount()).append(File.separator);
OnProductDetail third = list.get(2);
+ botIds.append(third.getBotAccount()).append(File.separator);
OnProductDetail forth = list.get(3);
+ botIds.append(forth.getBotAccount()).append(File.separator);
RecommandPojo pojoFirst = buildImgFrmTxtContainerFirstRow(new StringBuilder(Constants.IMG_PREFIX).append(first.getBannerImgUrl()).toString(), new StringBuilder(Constants.PRE_PRODUCT_IMG).append(first.getName()).toString(),
TempleUtils.correctName(first.getName()), "first.png");
RecommandPojo pojoSe = buildImgFrmTxtContainerFirstRow(new StringBuilder(Constants.IMG_PREFIX).append(second.getBannerImgUrl()).toString(), new StringBuilder(Constants.PRE_PRODUCT_IMG).append(second.getName()).toString(),
TempleUtils.correctName(second.getName()), "second.png");
RecommandPojo pojoThird = buildImgFrmTxtContainerFirstRow(new StringBuilder(Constants.IMG_PREFIX).append(third.getBannerImgUrl()).toString(), new StringBuilder(Constants.PRE_PRODUCT_IMG).append(third.getName()).toString(),
TempleUtils.correctName(third.getName()), "third.png");
- RecommandPojo pojoFourth = buildImgFrmTxtContainerFourth(new StringBuilder(Constants.IMG_PREFIX).append(forth.getBannerImgUrl()).toString(), new StringBuilder(Constants.PRE_PRODUCT_IMG).append(forth.getName()).toString());
+ RecommandPojo pojoFourth = buildImgFrmTxtContainerFourth(new StringBuilder(Constants.IMG_PREFIX).append(forth.getBannerImgUrl()).toString(), new StringBuilder(Constants.PRE_PRODUCT_IMG).append(forth.getName()).toString(),
+ TempleUtils.correctName(forth.getName()));
rowContainer.setItems(Arrays.asList(pojoFirst, pojoSe, pojoThird, pojoFourth));
- scrollList.add();
+ scrollList.add(rowContainer);
- for (int i = 4; i < ; i++) {
+ scrollList.add(buildRecommendList(getListData(1, 4, 8, list, botIds)));
+ scrollList.add(buildRecommendList(getListData(2, 8, 12, list, botIds)));
+ //scrollList.add(buildRecommendList(getListData(3, 12, 16, list, botIds)));
+
+ mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,RANK_HEAD,scrollView,buildPageButton(1,
+ ScheduleService.getRankPageSize()),RANK_CATEGORY_FOOTER));
+
+ botIds.deleteCharAt(botIds.length()-1);
+ String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
+ document.setRecommendIdList(idToken);
+ rankDocument = document;
+ return document;
+ }
+
+ public static RecommandDocument getRankOtherPageDocument(int num) {
+ RecommandDocument document = new RecommandDocument();
+ document.setDuration(120000);
+ RecommandMainTemplate mainTemplate = new RecommandMainTemplate();
+ document.setMainTemplate(mainTemplate);
+
+ RecommandPojo scrollView = new RecommandPojo();
+ scrollView.setType("ScrollView");
+ scrollView.setWidth("100%");
+ scrollView.setMarginBottom("140dp");
+ scrollView.setDirection("vertical");
+ List scrollList = new ArrayList<>();
+ scrollView.setItems(scrollList);
+
+ List list = ScheduleService.getRANK_ORDER_IDs();
+ int bound = list.size();
+ int begin = num*RE_RA_CA_PAGE_SIZE;
+ int end;
+ if (begin >= bound) return null;
+ bound = begin+RE_RA_CA_PAGE_SIZE <= bound ? begin+RE_RA_CA_PAGE_SIZE : bound;
+
+ StringBuilder botIds = new StringBuilder();
+ int row = 0;
+ while (begin < bound) {
+ end = begin+4 <= bound ? begin+4 : bound;
+ scrollList.add(buildRecommendList(getListData(row, begin, end, list, botIds)));
+ row++;
+ begin = end;
+ }
+ mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,RANK_HEAD,scrollView,
+ buildPageButton(num+1, ScheduleService.getRankPageSize()),RANK_CATEGORY_FOOTER));
+
+ botIds.deleteCharAt(botIds.length()-1);
+ String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
+ document.setRecommendIdList(idToken);
+ return document;
+ }
+
+ public static RecommandDocument getFunnyDocument(List bots, String audio) {
+ RecommandDocument document = new RecommandDocument();
+ document.setDuration(90000);
+ RecommandMainTemplate mainTemplate = new RecommandMainTemplate();
+ document.setMainTemplate(mainTemplate);
+ List data = new ArrayList<>();
+ StringBuilder botIds = new StringBuilder();
+ int num = 0;
+ for (OnProductDetail bot: bots) {
+ String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString();
+ String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
+ RecommandBotInfo detail = new RecommandBotInfo(imgSrc,imageId, TempleUtils.correctName(bot.getName()));
+ detail.setNum(++num);
+ data.add(detail);
+ botIds.append(bot.getBotAccount()).append(File.separator);
}
- getListData()
+ mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG, FUNNY_HEAD, buildFunnyList(data), buildFunnyAudio(audio),FUNNY_FOOTER));
+ botIds.deleteCharAt(botIds.length()-1);
+ String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
+ document.setRecommendIdList(idToken);
+ return document;
+ }
+
+ private static RecommandPojo buildFunnyAudio(String audioSrc) {
+ RecommandPojo audio = new RecommandPojo();
+ audio.setType("Audio");
+ audio.setComponentId("audioCom");
+ audio.setSrc(audioSrc);
+ audio.setLooping("false");
+ audio.setAutoplay("true");
+ return audio;
+ }
+
+ private static RecommandPojo buildFunnyList(List data) {
+// RecommandPojo con = new RecommandPojo();
+// con.setType("Container");
+// con.setHeight("100%");
+// con.setWidth("100%");
+// con.setAlignItems("center");
+
+ RecommandPojo list = new RecommandPojo();
+ list.setType("List");
+ list.setDirection("horizontal");
+ list.setMarginTop("65dp");
+ list.setMarginLeft("25dp");
+ list.setData(data);
+ list.setItems(Collections.singletonList(FUNNY_LIST_CON));
+
+// con.setItems(Collections.singletonList(list));
+
+ return list;
+ }
+
+ private static RecommandPojo buildImgFrmTxtContainerFunny() {
+ RecommandPojo container = new RecommandPojo();
+ container.setType("Container");
+ container.setWidth("275dp");
+ container.setMarginLeft("30dp");
+
+ //image
+ RecommandPojo image = new RecommandPojo();
+ image.setType("Image");
+ image.setWidth("230dp");
+ image.setHeight("230dp");
+ image.setMarginLeft("7dp");
+ image.setMarginTop("7dp");
+ image.setPosition("absolute");
+ image.setScaleType("fitXY");
+ image.setBorderRadius("22dp");
+ image.setSrc("${data.imageSrc}");
+ image.setOnClick(Collections.singletonList(new Event("SendEvent", "${data.imageId}")));
+
+ //frame
+ RecommandPojo frame = new RecommandPojo();
+ frame.setType("Frame");
+ frame.setWidth("40dp");
+ frame.setHeight("40dp");
+ frame.setBackgroundColor("rgba(0,0,0,0.9)");
+ frame.setBorderRadius("15dp");
+
+ RecommandPojo frmCon = new RecommandPojo();
+ frmCon.setType("Container");
+ frmCon.setWidth("100%");
+ frmCon.setHeight("100%");
+ frmCon.setAlignItems("center");
+ frmCon.setJustifyContent("center");
+
+ RecommandPojo frmText = new RecommandPojo();
+ frmText.setType("Text");
+ frmText.setText("${data.num}");
+ frmText.setFontSize("25dp");
+
+ frmCon.setItems(Collections.singletonList(frmText));
+ frame.setItems(Collections.singletonList(frmCon));
+
+ //text
+ RecommandPojo text = new RecommandPojo();
+ text.setType("Text");
+ text.setFontSize("33dp");
+ text.setMarginTop("200dp");
+ text.setMarginLeft("7dp");
+ text.setText("${data.imageName}");
+
+ container.setItems(Arrays.asList(image,frame,text));
+ return container;
}
private static RecommandPojo buildImgFrmTxtContainerFirstRow(String imgSrc, String imgId, String productName, String rankImgSrc) {
@@ -160,21 +339,22 @@ public class RecommendUtil {
image.setPosition("absolute");
image.setScaleType("fitXY");
image.setBorderRadius("15dp");
- image.setSrc(new StringBuilder("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/").append(imgSrc).toString());
+ image.setSrc(imgSrc);
image.setOnClick(Collections.singletonList(new Event("SendEvent", imgId)));
//frame
RecommandPojo rankImg = new RecommandPojo();
rankImg.setType("Image");
- rankImg.setWidth("55dp");
- rankImg.setHeight("55dp");
- image.setSrc(rankImgSrc);
+ rankImg.setScaleType("fitXY");
+ rankImg.setWidth("45dp");
+ rankImg.setHeight("60dp");
+ rankImg.setSrc(new StringBuilder("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/").append(rankImgSrc).toString());
//text
RecommandPojo text = new RecommandPojo();
text.setType("Text");
text.setFontSize("25dp");
- text.setMarginTop("160dp");
+ text.setMarginTop("145dp");
text.setMarginLeft("7dp");
text.setText(productName);
@@ -182,7 +362,7 @@ public class RecommendUtil {
return container;
}
- private static RecommandPojo buildImgFrmTxtContainerFourth(String imgSrc, String imgName) {
+ private static RecommandPojo buildImgFrmTxtContainerFourth(String imgSrc, String imgId, String productName) {
RecommandPojo container = new RecommandPojo();
container.setType("Container");
container.setWidth("220dp");
@@ -198,8 +378,8 @@ public class RecommendUtil {
image.setPosition("absolute");
image.setScaleType("fitXY");
image.setBorderRadius("15dp");
- image.setSrc(new StringBuilder("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/").append(imgSrc).toString());
- image.setOnClick(Collections.singletonList(new Event("SendEvent", "${data.imageId}")));
+ image.setSrc(imgSrc);
+ image.setOnClick(Collections.singletonList(new Event("SendEvent", imgId)));
//frame
RecommandPojo frame = new RecommandPojo();
@@ -227,16 +407,43 @@ public class RecommendUtil {
RecommandPojo text = new RecommandPojo();
text.setType("Text");
text.setFontSize("25dp");
- text.setMarginTop("160dp");
+ text.setMarginTop("165dp");
text.setMarginLeft("7dp");
- text.setText(imgName);
+ text.setText(productName);
container.setItems(Arrays.asList(image,frame,text));
return container;
}
- public static RecommandDocument getRankDocument() {
+ private static RecommandPojo buildPageButton(int curIndex, int num) {
+ RecommandPojo fCon = new RecommandPojo();
+ fCon.setType("Container");
+ fCon.setTop("20dp");
+ fCon.setRight("15dp");
+ fCon.setPosition("absolute");
+
+ RecommandPojo frame = new RecommandPojo();
+ frame.setType("Frame");
+ frame.setBorderRadius("40dp");
+ frame.setBackgroundColor("rgba(0,0,0,0.5)");
+
+ RecommandPojo sCon = new RecommandPojo();
+ sCon.setType("Container");
+ sCon.setWidth("130dp");
+ sCon.setHeight("35dp");
+ sCon.setAlignItems("center");
+ sCon.setJustifyContent("center");
+ RecommandPojo text = new RecommandPojo();
+ text.setType("Text");
+ text.setFontSize("22dp");
+ if (num == 0) text.setText("第"+curIndex+"页");
+ else text.setText(curIndex+"/"+num);
+
+ sCon.setItems(Collections.singletonList(text));
+ frame.setItems(Collections.singletonList(sCon));
+ fCon.setItems(Collections.singletonList(frame));
+ return fCon;
}
private static List getListData(int row,int begin, int end, List bots, StringBuilder botIds) {
@@ -254,13 +461,27 @@ public class RecommendUtil {
return data;
}
+ private static List getListDataNoIds(int row,int begin, int end, List bots) {
+ List data = new ArrayList<>();
+ int n = 1+row*4;
+ for (int i = begin; i < end; i++) {
+ OnProductDetail bot = bots.get(i);
+ String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString();
+ String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
+ RecommandBotInfo detail = new RecommandBotInfo(imgSrc,imageId, TempleUtils.correctName(bot.getName()));
+ detail.setNum(i-begin+n);
+ data.add(detail);
+ }
+ return data;
+ }
+
private static RecommandPojo buildRecommendList(List data) {
RecommandPojo list = new RecommandPojo();
list.setType("List");
list.setWidth("100%");
list.setHeight("240dp");
list.setMarginLeft("20dp");
- list.setMarginBottom("35dp");
+ list.setMarginBottom("55dp");
list.setDirection("horizontal");
list.setData(data);
list.setItems(Collections.singletonList(RECOM_LIST_CON));
@@ -313,7 +534,7 @@ public class RecommendUtil {
RecommandPojo text = new RecommandPojo();
text.setType("Text");
text.setFontSize("25dp");
- text.setMarginTop("160dp");
+ text.setMarginTop("165dp");
text.setMarginLeft("7dp");
text.setText("${data.imageName}");
@@ -338,6 +559,40 @@ public class RecommendUtil {
return footerCon;
}
+ private static RecommandPojo buildRankCategoryFooter() {
+ RecommandPojo footerCon = new RecommandPojo();
+ footerCon.setType("Container");
+ footerCon.setPosition("absolute");
+ footerCon.setWidth("100%");
+ footerCon.setLeft("0");
+ footerCon.setBottom("0");
+
+ RecommandPojo footer = new RecommandPojo();
+ footer.setType("Footer");
+ footer.setHints(Arrays.asList("打开第一个","下一页","上一页","跳到第三页","返回"));
+
+ footerCon.setItems(Collections.singletonList(footer));
+
+ return footerCon;
+ }
+
+ private static RecommandPojo buildFunnyFooter() {
+ RecommandPojo footerCon = new RecommandPojo();
+ footerCon.setType("Container");
+ footerCon.setPosition("absolute");
+ footerCon.setWidth("100%");
+ footerCon.setLeft("0");
+ footerCon.setBottom("0");
+
+ RecommandPojo footer = new RecommandPojo();
+ footer.setType("Footer");
+ footer.setHints(Arrays.asList("打开第一个","返回"));
+
+ footerCon.setItems(Collections.singletonList(footer));
+
+ return footerCon;
+ }
+
private static RecommandPojo buildRecomendBackgroundImg() {
RecommandPojo backGroundImg = new RecommandPojo();
backGroundImg.setType("Image");
@@ -361,6 +616,24 @@ public class RecommendUtil {
return head;
}
+ private static RecommandPojo buildRankHead() {
+ RecommandPojo head = new RecommandPojo();
+ head.setType("Header");
+ head.setHeaderTitle("排行榜");
+ head.setHasBackIcon(false);
+
+ return head;
+ }
+
+ private static RecommandPojo buildFunnyHead() {
+ RecommandPojo head = new RecommandPojo();
+ head.setType("Header");
+ head.setHeaderTitle("精品推荐");
+ head.setHasBackIcon(false);
+
+ return head;
+ }
+
private static RecommandPojo buildRecommendCollectHead(String category) {
RecommandPojo head = new RecommandPojo();
head.setType("Header");
@@ -369,4 +642,12 @@ public class RecommendUtil {
return head;
}
+
+// public static RecommandDocument getRankDocument() {
+// return rankDocument;
+// }
+//
+ public static void setRankDocument(RecommandDocument rankDocument) {
+ RecommendUtil.rankDocument = rankDocument;
+ }
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
index 84f5bd6..9caca18 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
@@ -29,7 +29,7 @@ public class XiaoDuHomeController {
//service.disableVerify();
service.enableVerify();
String str = service.run();
- //log.info("响应信息:{}", str);
+ log.info("响应信息:{}", str);
return str;
} catch (Exception e) {
e.printStackTrace();
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 fdc5480..419857b 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
@@ -85,7 +85,7 @@ public class DplBotService extends BaseBot {
private static final ConcurrentHashMap LAST_OUTTIME_RESULT = new ConcurrentHashMap<>();
- private static volatile FunnyDocument FUNNY_DEFAULT_DOCUMENT;
+ private static volatile RecommandDocument FUNNY_DEFAULT_DOCUMENT;
static {
FIRST_PAGE = JSON.parseObject(DplbotServiceUtil.getDPLTemple("static/json/firstPage.json"), MyDocument.class);
@@ -131,7 +131,7 @@ public class DplBotService extends BaseBot {
Future future = DplbotServiceUtil.getPOOL().submit(new Task(intentRequest));
future.get(2200, TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException e) {
- log.error("获取任务执行结果出错:{}", e.toString());
+ log.error("获取任务执行结果出错:{}", ExceptionUtils.getStackTrace(e));
return buildErrorResponse(SORRY_UNCATCH);
} catch (TimeoutException e) {
log.info("超时,让用户再说一遍:{}",e.toString());
@@ -143,7 +143,7 @@ public class DplBotService extends BaseBot {
return buildErrorResponse(SORRY_UNCATCH);
}
} catch (Exception all) {
- log.error("任务执行发生了错误:{}", all.toString());
+ log.error("任务执行发生了错误:{}", ExceptionUtils.getStackTrace(all));
return buildErrorResponse(SORRY_UNCATCH);
}
return LAST_OUTTIME_RESULT.remove(getUserId()).getResponse();
@@ -177,7 +177,7 @@ public class DplBotService extends BaseBot {
text = text.substring(text.indexOf("】")+1);
log.info("旁白名字:{}",aside);
PlayDocument document = PlayUtils.getPlayDocument(productName, aside, ScheduleService.getAsideImgUrl(botID, aside),
- data.getAudio(), text, DplbotServiceUtil.doesUserCollectThisBot(botID, getAccessToken(), getUserId()));
+ data.getAudio(), text);
RenderDocument render = new RenderDocument(document);
this.setSessionAttribute(PRE_COLLE, null);
@@ -212,7 +212,7 @@ public class DplBotService extends BaseBot {
String productName = componentId.substring(5);
OnProductDetail productDetail = ScheduleService.PRODUCT_NAME_DETAIL.get(productName);
- if (productDetail == null && !productName.equals("清新传")) {
+ if (productDetail == null && !productName.equals("清新传{/zhuan4/}")) {
return buildErrorResponse("目前不支持该作品");
}
String imgUrl = new StringBuilder(Constants.IMG_PREFIX).append(productDetail.getBannerImgUrl()).toString();
@@ -300,8 +300,7 @@ public class DplBotService extends BaseBot {
if (keng.equals("清新传")) keng = "清新传{/zhuan4/}";
String botID = ScheduleService.getProductNameDetail().get(keng).getBotAccount();
PlayDocument document = PlayUtils.getPlayDocument(productName, aside, ScheduleService.getAsideImgUrl(botID, aside),
- data.getAudio(), text, DplbotServiceUtil.didUserCollecThisProduct(botID, getUserId(),
- getAccessToken(), getSessionAttribute("userId")));
+ data.getAudio(), text);
RenderDocument render = new RenderDocument(document);
this.setSessionAttribute(PRE_COLLE, null);
@@ -353,8 +352,8 @@ public class DplBotService extends BaseBot {
RecommandDocument document = RecommendUtil.getCategory(0, category);
if (document == null) return buildErrorResponse("不好意思该分类还没有作品");
RenderDocument render = new RenderDocument(document);
- this.setSessionAttribute("category",category);
this.addDirective(render);
+ this.setSessionAttribute("category",category);
this.setSessionAttribute("trace","05");
} else if ("playButton".equals(componentId)) {
return buildErrorResponse("您可以直接对我说我要送花或者我要收藏或取消收藏");
@@ -387,7 +386,6 @@ public class DplBotService extends BaseBot {
RenderDocument render = new RenderDocument(document);
addDirective(render);
setSessionAttribute(PRE_COLLE,document.getIdToken());
- setSessionAttribute("ranking", null);
setSessionAttribute("recommand", null);
setSessionAttribute("comCnt", null);
setSessionAttribute(BACK_TRACE, "02");
@@ -700,10 +698,60 @@ public class DplBotService extends BaseBot {
dealCollectHistoryJump(index, false, detail, userId);
break;
}
+ case '4' : {
+ dealRankJump(index, detail);
+ break;
+ }
+ case '5' : {
+ dealCategoryJump(index, detail);
+ break;
+ }
+ default : {
+ detail.setResponse(buildErrorResponse("该页面不支持跳转"));
+ }
}
LAST_OUTTIME_RESULT.put(userId,detail);
}
+ private void dealRankJump(int index, OverTimeDetail detail) {
+ index = index == 0 ? index : index-1;
+ RecommandDocument document;
+ if (index == 0) document = RecommendUtil.getRankDocumentFirstPage();
+ else document = RecommendUtil.getRankOtherPageDocument(index);
+ if (document == null) {
+ detail.setResponse(buildErrorResponse("超出了范围,无法跳转"));
+ return;
+ }
+ RenderDocument render = new RenderDocument(document);
+ addDirective(render);
+ detail.getDirectives().add(render);
+ String cmt = String.valueOf(index+1);
+ setSessionAttribute("comCnt",cmt);
+ setSessionAttribute("recommand", document.getRecommendIdList());
+ detail.getAttributes().put("recommand", document.getRecommendIdList());
+ detail.getAttributes().put("comCnt", cmt);
+ }
+
+ private void dealCategoryJump(int index, OverTimeDetail detail) {
+ index = index == 0 ? index : index-1;
+ String category = getSessionAttribute("category");
+ if (category == null) {
+ detail.setResponse(buildErrorResponse("无法跳转,请说返回然后重新进入当前分类"));
+ return;
+ }
+ RecommandDocument document = RecommendUtil.getCategory(index, category);
+ if (document == null) {
+ detail.setResponse(buildErrorResponse("超出了范围,无法跳转"));
+ return;
+ }
+ RenderDocument render = new RenderDocument(document);
+ addDirective(render);
+ detail.getDirectives().add(render);
+ String cmt = String.valueOf(index+1);
+ setSessionAttribute("comCnt",cmt);
+ detail.getAttributes().put("comCnt", cmt);
+ }
+
private void dealCollectHistoryJump(int index, boolean collect, OverTimeDetail detail, String userId) {
index = index == 0 ? index : index-1;
int start = index*CO_HI_PAGE_SIZE;
@@ -894,20 +942,20 @@ public class DplBotService extends BaseBot {
}
private void dealRankIntent(OverTimeDetail detail, String userId) {
- RankingDocument document = RankUtil.getRankDocument();
+ RecommandDocument document = RecommendUtil.getRankDocumentFirstPage();
RenderDocument render = new RenderDocument();
render.setDocument(document);
addDirective(render);
detail.getDirectives().add(render);
- String token = document.getRankBotIds();
+ String token = document.getRecommendIdList();
if (token != null) {
- setSessionAttribute("ranking", token);
- setSessionAttribute("recommand", null);
+ setSessionAttribute("recommand", token);
setSessionAttribute(PRE_COLLE, null);
+ setSessionAttribute("comCnt", null);
- detail.getAttributes().put("ranking", token);
- detail.getAttributes().put("recommand", null);
+ detail.getAttributes().put("recommand", token);
detail.getAttributes().put(PRE_COLLE, null);
+ detail.getAttributes().put("comCnt", null);
}
setSessionAttribute(BACK_TRACE, "04");
detail.getAttributes().put(BACK_TRACE, "04");
@@ -924,15 +972,11 @@ public class DplBotService extends BaseBot {
if (token != null) {
setSessionAttribute("recommand", token);
setSessionAttribute(PRE_COLLE, null);
- setSessionAttribute("ranking", null);
setSessionAttribute("comCnt", null);
- setSessionAttribute("count", recommandDocument.getCount());
detail.getAttributes().put("comCnt", null);
- detail.getAttributes().put("ranking", null);
detail.getAttributes().put("recommand", token);
detail.getAttributes().put(PRE_COLLE, null);
- detail.getAttributes().put("count", recommandDocument.getCount());
}
setSessionAttribute(BACK_TRACE, "03");
detail.getAttributes().put(BACK_TRACE,"03");
@@ -950,14 +994,12 @@ public class DplBotService extends BaseBot {
addDirective(render);
//dplBotService.addDirective(new PushStack());
setSessionAttribute(PRE_COLLE,document.getIdToken());
- setSessionAttribute("ranking", null);
setSessionAttribute("recommand", null);
setSessionAttribute("comCnt", null);
setSessionAttribute(BACK_TRACE, "02");
detail.getDirectives().add(render);
detail.getAttributes().put("comCnt", null);
- detail.getAttributes().put("ranking", null);
detail.getAttributes().put("recommand", null);
detail.getAttributes().put(PRE_COLLE,document.getIdToken());
detail.getAttributes().put(BACK_TRACE, "02");
@@ -973,7 +1015,6 @@ public class DplBotService extends BaseBot {
return;
}
char sign = signPage.charAt(1);
- int index = 0;
switch (sign) {
case '1': {
String recommendNextCount = getSessionAttribute("comCnt");
@@ -1020,17 +1061,6 @@ public class DplBotService extends BaseBot {
}
break;
}
- case '6': {
- ExecuteCommands executeCommands = new ExecuteCommands();
- SetPageCommand setPage = new SetPageCommand();
- setPage.setComponentId("funnyPage");
- setPage.setPosition(SetPageCommand.Position.RELATIVE);
- setPage.setValue(1);
- executeCommands.addCommand(setPage);
- addDirective(executeCommands);
- detail.getDirectives().add(executeCommands);
- break;
- }
case '3': {
String recommendNextCount = getSessionAttribute("comCnt");
int count = 1;
@@ -1051,51 +1081,22 @@ public class DplBotService extends BaseBot {
break;
}
case '4': {
- String pageIndex = getSessionAttribute("pageIndex");
- int count = 15;
- String countStr = getSessionAttribute("count");
- if (countStr != null) count = Integer.parseInt(countStr);
- if (intentRequest.getQuery().getOriginal().contains("页")) {
- //update
- String updateCount = getSessionAttribute("updateCount");
- int update = 1;
- if (updateCount != null) update = Integer.valueOf(updateCount);
- RankingDocument document = RankUtil.updateRankDocument(update);
- if (document == null) {
- detail.setResponse(buildErrorResponse("排行榜已经被您翻到底啦,没有了"));
- break;
- }
- count = Integer.parseInt(document.getCount());
- RenderDocument render = new RenderDocument(document);
- addDirective(render);
- detail.getDirectives().add(render);
- setSessionAttribute("pageIndex",null);
- detail.getAttributes().put("pageIndex",null);
- setSessionAttribute("count", document.getCount());
- detail.getAttributes().put("count", document.getCount());
- setSessionAttribute("updateCount", String.valueOf(update+1));
- detail.getAttributes().put("updateCount", String.valueOf(update+1));
- detail.setResponse(buildErrorResponse(new StringBuilder("为您刷新排行榜,下面是排行")
- .append(update*15).append("到").append(update*15+count).append("的作品").toString()));
- break;
- }
- index = 0;
- if (pageIndex != null) index = Integer.parseInt(pageIndex);
- ExecuteCommands executeCommands = new ExecuteCommands();
- ScrollToIndexCommand scroll = new ScrollToIndexCommand();
- scroll.setComponentId("scrollToIndex");
- index += 4;
- if (index >= count) {
- detail.setResponse(buildErrorResponse("请说下一页刷新榜单"));
+ String recommendNextCount = getSessionAttribute("comCnt");
+ int count = 1;
+ if (recommendNextCount != null) count = Integer.parseInt(recommendNextCount);
+ RecommandDocument document = RecommendUtil.getRankOtherPageDocument(count);
+ if (document == null) {
+ detail.setResponse(buildErrorResponse("客观你已经翻到底了,没有更多了"));
break;
}
- scroll.setIndex(index);
- scroll.setAlign(ScrollToIndexCommand.AlignType.FIRST);
- executeCommands.addCommand(scroll);
- addDirective(executeCommands);
- detail.getDirectives().add(executeCommands);
- setSessionAttribute("pageIndex", String.valueOf(index));
- detail.getAttributes().put("pageIndex", String.valueOf(index));
+ RenderDocument render = new RenderDocument(document);
+ addDirective(render);
+ detail.getDirectives().add(render);
+ String token = document.getRecommendIdList();
+ setSessionAttribute("recommand", token);
+ detail.getAttributes().put("recommand",token);
+ setSessionAttribute("comCnt",String.valueOf(count+1));
+ detail.getAttributes().put("comCnt",String.valueOf(count+1));
break;
}
case '5':{
@@ -1132,7 +1133,6 @@ public class DplBotService extends BaseBot {
return;
}
char sign = signPage.charAt(1);
- int index;
switch (sign) {
case '1':{
String recommendNextCount = getSessionAttribute("comCnt");
@@ -1177,17 +1177,6 @@ public class DplBotService extends BaseBot {
}
break;
}
- case '6': {
- ExecuteCommands executeCommands = new ExecuteCommands();
- SetPageCommand setPage = new SetPageCommand();
- setPage.setComponentId("funnyPage");
- setPage.setPosition(SetPageCommand.Position.RELATIVE);
- setPage.setValue(-1);
- executeCommands.addCommand(setPage);
- addDirective(executeCommands);
- detail.getDirectives().add(executeCommands);
- break;
- }
case '3': {
String recommendNextCount = getSessionAttribute("comCnt");
if (recommendNextCount == null || "1".equals(recommendNextCount)) {
@@ -1207,42 +1196,23 @@ public class DplBotService extends BaseBot {
break;
}
case '4': {
- String pageIndex = getSessionAttribute("pageIndex");
- index = 0;
- if (pageIndex != null) index = Integer.parseInt(pageIndex);
- ExecuteCommands executeCommands = new ExecuteCommands();
- ScrollToIndexCommand scroll = new ScrollToIndexCommand();
- scroll.setComponentId("scrollToIndex");
- String updateCount = getSessionAttribute("updateCount");
- if (intentRequest.getQuery().getOriginal().contains("页") && updateCount != null && !"0".equals(updateCount)) {
- int update = Integer.valueOf(updateCount);
- RankingDocument document = RankUtil.updateRankDocument(update-1);
- if (document == null) {
- detail.setResponse(buildErrorResponse("排行榜已经被您翻到底啦,没有了"));
- break;
- }
- RenderDocument render = new RenderDocument(document);
- addDirective(render);
- detail.getDirectives().add(render);
- setSessionAttribute("pageIndex",null);
- detail.getAttributes().put("pageIndex",null);
- setSessionAttribute("count", document.getCount());
- detail.getAttributes().put("count", document.getCount());
- setSessionAttribute("updateCount", String.valueOf(update-1));
- detail.getAttributes().put("updateCount", String.valueOf(update-1));
- detail.setResponse(buildErrorResponse(new StringBuilder("为您刷新排行榜,下面是排行")
- .append(update*15).append("到").append(update*15+15).append("的作品").toString()));
+ String recommendNextCount = getSessionAttribute("comCnt");
+ if (recommendNextCount == null || "1".equals(recommendNextCount)) {
+ detail.setResponse(buildErrorResponse("客观,前面没啦,没法往前翻了"));
break;
}
- index -= 4;
- if (index < 0) index = 0;
- scroll.setIndex(index);
- scroll.setAlign(ScrollToIndexCommand.AlignType.FIRST);
- executeCommands.addCommand(scroll);
- addDirective(executeCommands);
- detail.getDirectives().add(executeCommands);
- setSessionAttribute("pageIndex", String.valueOf(index));
- detail.getAttributes().put("pageIndex", String.valueOf(index));
+ int count = Integer.parseInt(recommendNextCount);
+ RecommandDocument document;
+ if (count == 2) document = RecommendUtil.getRankDocumentFirstPage();
+ else document = RecommendUtil.getRankOtherPageDocument(count-2);
+ RenderDocument render = new RenderDocument(document);
+ addDirective(render);
+ detail.getDirectives().add(render);
+ String token = document.getRecommendIdList();
+ setSessionAttribute("recommand", token);
+ detail.getAttributes().put("recommand",token);
+ setSessionAttribute("comCnt",String.valueOf(count-1));
+ detail.getAttributes().put("comCnt",String.valueOf(count-1));
break;
}
case '5':{
@@ -1288,8 +1258,9 @@ public class DplBotService extends BaseBot {
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 '4': detail.setResponse(dealOpenNumInRecommend(getSessionAttribute("recommand"),detail)); break;
case '5': detail.setResponse(dealOpenNumInCategory(userId, detail));break;
+ case '6': detail.setResponse(dealOpenNumInRecommend(getSessionAttribute("recommand"), detail));break;
default:{
OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "屏幕上的图标都是可以点击的哦");
detail.getResponse().setOutputSpeech(outputSpeech);
@@ -1323,9 +1294,11 @@ public class DplBotService extends BaseBot {
RenderDocument render = new RenderDocument(document);
addDirective(render);
setSessionAttribute(PRE_COLLE,document.getIdToken());
+ setSessionAttribute("recommand", null);
setSessionAttribute(BACK_TRACE, "01");
setSessionAttribute("comCnt", null);
detail.getAttributes().put("comCnt", null);
+ detail.getAttributes().put("recommand", null);
detail.getAttributes().put(PRE_COLLE, document.getIdToken());
detail.getAttributes().put(BACK_TRACE,"01");
detail.getDirectives().add(render);
@@ -1413,6 +1386,15 @@ public class DplBotService extends BaseBot {
int count = 1;
if (recommendNextCount != null) count = Integer.parseInt(recommendNextCount);
RecommandDocument recommandDocument = RecommendUtil.getRecommendDocument(count-1);
+ if (recommandDocument == null) {
+ RenderDocument render = new RenderDocument();
+ render.setDocument(LunchUtils.getLunchDocument());
+ addDirective(render);
+ detail.getDirectives().add(render);
+ setSessionAttribute(BACK_TRACE, null);
+ detail.getAttributes().put(BACK_TRACE, null);
+ break;
+ }
RenderDocument render = new RenderDocument();
render.setDocument(recommandDocument);
addDirective(render);
@@ -1424,23 +1406,38 @@ public class DplBotService extends BaseBot {
setSessionAttribute(BACK_TRACE, "03");
detail.getAttributes().put(BACK_TRACE, "03");
detail.getDirectives().add(render);
- detail.setResponse(buildErrorResponse(new StringBuilder("已为您返回到推荐页").toString()));
+ detail.setResponse(buildErrorResponse("已为您返回到推荐页"));
break;
}
case '4': {
//rank
- RankingDocument document = RankUtil.getRankDocument();
+ String recommendNextCount = getSessionAttribute("comCnt");
+ int count = 1;
+ if (recommendNextCount != null) count = Integer.parseInt(recommendNextCount);
+ RecommandDocument recommandDocument;
+ if (count == 1) recommandDocument = RecommendUtil.getRankDocumentFirstPage();
+ else recommandDocument = RecommendUtil.getRankOtherPageDocument(count-1);
+ if (recommandDocument == null) {
+ RenderDocument render = new RenderDocument();
+ render.setDocument(LunchUtils.getLunchDocument());
+ addDirective(render);
+ detail.getDirectives().add(render);
+ setSessionAttribute(BACK_TRACE, null);
+ detail.getAttributes().put(BACK_TRACE, null);
+ break;
+ }
RenderDocument render = new RenderDocument();
- render.setDocument(document);
+ render.setDocument(recommandDocument);
addDirective(render);
- detail.getDirectives().add(render);
- String token = document.getRankBotIds();
+ String token = recommandDocument.getRecommendIdList();
if (token != null) {
- setSessionAttribute("ranking", token);
- detail.getAttributes().put("ranking",token);
+ setSessionAttribute("recommand", token);
+ detail.getAttributes().put("recommand",token);
}
setSessionAttribute(BACK_TRACE, "04");
detail.getAttributes().put(BACK_TRACE, "04");
+ detail.getDirectives().add(render);
+ detail.setResponse(buildErrorResponse("已为您返回到排行榜"));
break;
}
case '5':{
@@ -1498,13 +1495,17 @@ public class DplBotService extends BaseBot {
}
String text = data.getText();
if ("funny".equals(intentName) || data.getAipioneerUsername().equals("4151097686")) {
- FunnyDocument document = displayFunnyRecommandPage(text);
+ RecommandDocument document = displayFunnyRecommandPage(text, data.getAudio());
if (document != null) {
document.getMainTemplate().getItems().get(2).setSrc(data.getAudio());
FUNNY_DEFAULT_DOCUMENT = document;
RenderDocument render = new RenderDocument(document);
addDirective(render);
detail.getDirectives().add(render);
+ setSessionAttribute("recommand", document.getRecommendIdList());
+ setSessionAttribute(BACK_TRACE, "06");
+ detail.getAttributes().put(BACK_TRACE, "06");
+ detail.getAttributes().put("recommand", document.getRecommendIdList());
LAST_OUTTIME_RESULT.put(userId, detail);
return;
}
@@ -1534,7 +1535,7 @@ public class DplBotService extends BaseBot {
PlayDocument document = PlayUtils.getPlayDocument(correctName(productName), aside,
ScheduleService.getAsideImgUrl(botAccount, aside),
- data.getAudio(), text,DplbotServiceUtil.doesUserCollectThisBot(botAccount, getAccessToken(), userId));
+ data.getAudio(), text);
RenderDocument render = new RenderDocument(document);
addDirective(render);
detail.getDirectives().add(render);
@@ -1584,7 +1585,7 @@ public class DplBotService extends BaseBot {
String productName = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
PlayDocument document = PlayUtils.getPlayDocument(correctName(productName), aside,
ScheduleService.getAsideImgUrl(botAccount, aside),
- data.getAudio(), text,DplbotServiceUtil.doesUserCollectThisBot(botAccount, getAccessToken(), userId));
+ data.getAudio(), text);
RenderDocument render = new RenderDocument(document);
addDirective(render);
detail.getDirectives().add(render);
@@ -1593,6 +1594,9 @@ public class DplBotService extends BaseBot {
}
private Response dealOpenNumInRecommend(String idsToken, OverTimeDetail overDetail) {
+ if (idsToken == null) {
+ return buildErrorResponse("请重新进入当前页面");
+ }
int collectNum = Integer.parseInt(getSlot("sys.number"));
String[] tokenList = new String(Base64.getDecoder().decode(idsToken)).split(File.separator);
if (collectNum > tokenList.length || collectNum <= 0) return buildErrorResponse("这个数字超出了范围");
@@ -1613,13 +1617,14 @@ public class DplBotService extends BaseBot {
int num = 1;
if (numStr != null) num = Integer.parseInt(numStr);
List categoryBots = ScheduleService.getCategoryProductIdList().get(getSessionAttribute("category"));
- if (num <= 0 || num > categoryBots.size()) {
+ num = pageIndex*RE_RA_CA_PAGE_SIZE+num-1;
+ if (num < 0 || num >= categoryBots.size()) {
Response response = buildErrorResponse("这个数字超出了范围,作品的序号已显示在图片左上角");
detail.setResponse(response);
LAST_OUTTIME_RESULT.put(userId, detail);
return response;
}
- String botId = categoryBots.get(pageIndex*16+num-1);
+ String botId = categoryBots.get(num);
String name = ScheduleService.getProductIdDetail().get(botId).getName();
Response response;
if (DplbotServiceUtil.doesUserPlayed(botId, getUserId(), getAccessToken())) response = directInProduct(correctName(name), botId, detail);
@@ -1674,7 +1679,7 @@ public class DplBotService extends BaseBot {
String aside = DplbotServiceUtil.getAsideText(text);
text = text.substring(text.indexOf("】")+1);
PlayDocument document = PlayUtils.getPlayDocument(productName, aside,ScheduleService.getAsideImgUrl(botId, aside),
- data.getAudio(), text,DplbotServiceUtil.doesUserCollectThisBot(botId, getAccessToken(), getUserId()));
+ data.getAudio(), text);
RenderDocument render = new RenderDocument(document);
this.setSessionAttribute(PRE_COLLE, null);
@@ -1766,7 +1771,7 @@ public class DplBotService extends BaseBot {
return new Response();
}
- private FunnyDocument displayFunnyRecommandPage(String word) {
+ private RecommandDocument displayFunnyRecommandPage(String word, String audio) {
try {
List botNames = Utils.getRecommandBotNames(word);
log.info("botNames:{}",botNames);
@@ -1777,7 +1782,7 @@ public class DplBotService extends BaseBot {
if (detail == null) continue;
bots.add(detail);
}
- if (bots.size() != 0) return TempleUtils.getFunnyDocument(bots);
+ if (bots.size() != 0) return RecommendUtil.getFunnyDocument(bots, audio);
} catch (Exception e) {
log.error("获取funny页出错:{}",e.toString());
}
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 283cd01..536f3ec 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
@@ -4,6 +4,7 @@ import ai.qiwu.com.xiaoduhome.common.BaseHolder;
import ai.qiwu.com.xiaoduhome.common.Config;
import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import ai.qiwu.com.xiaoduhome.common.temple.onLunch.LunchUtils;
+import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommendUtil;
import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryTB;
@@ -29,6 +30,7 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import static ai.qiwu.com.xiaoduhome.common.Constants.DPL_COMPONENT_ID.DEFAULT_ASIDE_IMG_URL;
+import static ai.qiwu.com.xiaoduhome.common.Constants.RE_RA_CA_PAGE_SIZE;
import static ai.qiwu.com.xiaoduhome.common.Constants.UNIT_PRICE;
import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.ASIDE_IMG_URL;
@@ -39,15 +41,16 @@ import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.ASIDE_IMG_URL;
@Slf4j
@Component
public class ScheduleService implements InitializingBean {
- private static int allProductCount;
+ private static volatile int allProductCount;
+ private static volatile int rankPageSize;
private static volatile List RANKING_LIST = new ArrayList<>();
private static volatile List RECOMMEND_LIST = new ArrayList<>();
private static volatile List ALL_ON_PRODUCT = new ArrayList<>();
private static volatile List RANK_ORDER_IDs = new ArrayList<>();
- static final HashMap PRODUCT_NAME_DETAIL = new HashMap<>();
- static final HashMap PRODUCT_ID_DETAIL = new HashMap<>();
+ static volatile HashMap PRODUCT_NAME_DETAIL = new HashMap<>();
+ static volatile HashMap PRODUCT_ID_DETAIL = new HashMap<>();
- private static final HashMap> ASIDE_IMG = new HashMap<>();
+ private static volatile HashMap> ASIDE_IMG = new HashMap<>();
private static final HashMap NX2_BOT_TO_HZ1 = new HashMap<>();
private static final HashMap HZ1_BOT_TO_NX2 = new HashMap<>();
@@ -56,7 +59,7 @@ public class ScheduleService implements InitializingBean {
static final String[] CATEGORY = {"古风", "儿童", "科幻", "占星", "恋爱", "灾难", "架空", "经营", "冒险", "武侠"};
private static final String[] CATEGORY_CHARAC={"gufeng","child","kehuan","zhanxing","lianai","zainan","jiakong","jingying","maoxian","wuxia"};
- private static final HashMap> CATEGORY_PRODUCT_ID_LIST = new HashMap<>();
+ private static volatile HashMap> CATEGORY_PRODUCT_ID_LIST = new HashMap<>();
private final GameProjectTbRepository gameProjectTbRepository;
@@ -151,18 +154,24 @@ public class ScheduleService implements InitializingBean {
new Thread(() -> {
ALL_ON_PRODUCT = allOnProductInfoRepository.findAllByApplyStatus(1);
allProductCount = ALL_ON_PRODUCT.size();
+ rankPageSize = allProductCount / RE_RA_CA_PAGE_SIZE + (allProductCount%RE_RA_CA_PAGE_SIZE == 0 ? 0:1);
TreeMap rankOrder = new TreeMap<>((o1, o2) -> o1-o2 < 0 ? 1 :(o1.equals(o2) ? 0 : -1));
+ HashMap nd = new HashMap<>();
+ HashMap id = new HashMap<>();
for (OnProductDetail item : ALL_ON_PRODUCT) {
String productName = item.getName();
String botAccount = item.getBotAccount();
List labels = projectLabelRepository.productLabels(item.getId());
//PRODUCT_LABELS.put(productName, labels);
item.setLabels(labels);
- PRODUCT_NAME_DETAIL.put(productName, item);
- PRODUCT_ID_DETAIL.put(botAccount, item);
+ nd.put(productName, item);
+ id.put(botAccount, item);
rankOrder.put(item.getWatch(), item);
}
- RANK_ORDER_IDs.addAll(rankOrder.values());
+ PRODUCT_NAME_DETAIL = nd;
+ PRODUCT_ID_DETAIL = id;
+ RANK_ORDER_IDs = new ArrayList<>(rankOrder.values());
+ RecommendUtil.setRankDocument(null);
//log.info("作品详细信息:{}", PRODUCT_NAME_DETAIL);
}).start();
//log.error("更新推荐页出错:{}", e.getMessage());
@@ -171,13 +180,15 @@ public class ScheduleService implements InitializingBean {
@Scheduled(cron = "0 0 1 * * ?")
public void initProductList() {
new Thread(() -> {
+ HashMap> ci = new HashMap<>();
for (String category: CATEGORY) {
//List list = gameProjectTbRepository.categoryProject(category);
List idList = gameProjectTbRepository.categoryProList(category);
- CATEGORY_PRODUCT_ID_LIST.put(category, idList);
+ ci.put(category, idList);
//CATEGORY_PRODUCT_LIST.put(category, list);
//log.info("分类{},作品列表{}", category, list);
}
+ CATEGORY_PRODUCT_ID_LIST = ci;
}).start();
//log.error("更新分类作品列表出错:{}", e.getMessage());
}
@@ -213,6 +224,7 @@ public class ScheduleService implements InitializingBean {
private void getAsideImg() {
DplbotServiceUtil.getPOOL().submit(() -> {
List botIds = gameProjectTbRepository.getAllOnTableProductIds();
+ HashMap> ai = new HashMap<>();
for (String botId: botIds) {
try {
String nxBotId = HZ1_BOT_TO_NX2.get(botId);
@@ -225,11 +237,12 @@ public class ScheduleService implements InitializingBean {
params.put("aipioneerUsername",nxBotId);
String str = OkHttp3Utils.doGet(ASIDE_IMG_URL, params);
AsideImageResponse response = JSON.parseObject(str, AsideImageResponse.class);
- ASIDE_IMG.put(botId, response.getData().getNpcHeadImgUrl());
+ ai.put(botId, response.getData().getNpcHeadImgUrl());
} catch (Exception e) {
log.error("定时获取头像出错:botId:{},{}",botId, ScheduleService.getProductIdDetail().get(botId).getName());
}
}
+ ASIDE_IMG = ai;
});
}
@@ -360,4 +373,8 @@ public class ScheduleService implements InitializingBean {
if (url == null) url = DEFAULT_ASIDE_IMG_URL;
return url;
}
+
+ public static int getRankPageSize() {
+ return rankPageSize;
+ }
}