Commit bd0298ef by 苗权威

1.19

parent f5bb9486
...@@ -25,8 +25,10 @@ import ai.qiwu.com.xiaoduhome.repository.primary.AppFavoriteTBRepository; ...@@ -25,8 +25,10 @@ import ai.qiwu.com.xiaoduhome.repository.primary.AppFavoriteTBRepository;
import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryBotTimeRepository; import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryBotTimeRepository;
import ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil; import ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil;
import ai.qiwu.com.xiaoduhome.service.ScheduleService; import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -267,15 +269,17 @@ public class TempleUtils { ...@@ -267,15 +269,17 @@ public class TempleUtils {
return dataList; return dataList;
} }
public static List<LunchBotData> buildCategoryDataList() { public static List<LunchBotData> buildCategoryDataList(int row) {
ArrayList<LunchBotData> dataList = new ArrayList<>(); ArrayList<LunchBotData> dataList = new ArrayList<>();
int i = 17; int begin = row*3;
for (String cateName : ScheduleService.getCATEGORY()) { String name, imgId, imgSrc;
String imageId = new StringBuilder(PRE_CATEGORY).append(cateName).toString(); for (int i = begin; i < begin+3; i++) {
String imgSrc = new StringBuilder(IMG_CUSTOM_PREFIX) name = ScheduleServiceNew.CATEGORY[i];
.append(ScheduleService.getCategoryCharac()[i-17]).append(".png").toString(); imgSrc = new StringBuilder(IMG_CUSTOM_PREFIX)
LunchBotData data = new LunchBotData(imgSrc, imageId, cateName); .append(ScheduleServiceNew.CATEGORY_CHARAC[i]).append(".png").toString();
data.setNum(i++); imgId = ScheduleServiceNew.CATEGORY_CHARAC[i];
LunchBotData data = new LunchBotData(imgSrc, imgId, name);
data.setNum(i+1);
dataList.add(data); dataList.add(data);
} }
return dataList; return dataList;
......
package ai.qiwu.com.xiaoduhome.common.temple.onLunch; package ai.qiwu.com.xiaoduhome.common.temple.onLunch;
import com.baidu.dueros.data.response.directive.dpl.Document; import com.baidu.dueros.data.response.directive.dpl.Document;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
......
...@@ -21,6 +21,7 @@ public class LunchUtils { ...@@ -21,6 +21,7 @@ public class LunchUtils {
private static final LunchPojo LUNCH_HEAD = buildLunchHead(); private static final LunchPojo LUNCH_HEAD = buildLunchHead();
private static final LunchPojo LUNCH_BACK_IMG = buildLunchBackgroundImg(); private static final LunchPojo LUNCH_BACK_IMG = buildLunchBackgroundImg();
private static final LunchPojo FOOTER = buildHomeFooter(); private static final LunchPojo FOOTER = buildHomeFooter();
private static final LunchPojo CATEGORY_FOOTER = buildCategoryFooter();
// private static final LunchPojo LUNCH_LOGO_IMG = buildLogoImage(); // private static final LunchPojo LUNCH_LOGO_IMG = buildLogoImage();
// private static final LunchPojo LUNCH_HSITORY_IMG = buildHistoryImg(); // private static final LunchPojo LUNCH_HSITORY_IMG = buildHistoryImg();
// private static final LunchPojo LUNCH_COLLECT_IMG = buildCollectImg(); // private static final LunchPojo LUNCH_COLLECT_IMG = buildCollectImg();
...@@ -67,7 +68,7 @@ public class LunchUtils { ...@@ -67,7 +68,7 @@ public class LunchUtils {
// LunchPojo conRanking = buildLunchList(TempleUtils.buildDataList(ScheduleService.getRankingList(), 9)); // LunchPojo conRanking = buildLunchList(TempleUtils.buildDataList(ScheduleService.getRankingList(), 9));
// conRanking.setFirstItem(Collections.singletonList(TempleUtils.getFrameRakking())); // conRanking.setFirstItem(Collections.singletonList(TempleUtils.getFrameRakking()));
LunchPojo conCategory = buildLunchCategoryList(TempleUtils.buildCategoryDataList()); LunchPojo conCategory = buildLunchCategoryList(TempleUtils.buildCategoryDataList(0));
conCategory.setFirstItem(Collections.singletonList(TempleUtils.getFrameCategory())); conCategory.setFirstItem(Collections.singletonList(TempleUtils.getFrameCategory()));
LunchPojo scroll = buildLunchScroll(); LunchPojo scroll = buildLunchScroll();
...@@ -77,6 +78,21 @@ public class LunchUtils { ...@@ -77,6 +78,21 @@ public class LunchUtils {
return document; return document;
} }
public static LunchDocument buildCategoryDocument() {
LunchDocument document = new LunchDocument();
document.setDuration(90000);
LunchMainTemplate mainTemplate = new LunchMainTemplate();
document.setMainTemplate(mainTemplate);
LunchPojo firstRow = buildLunchCategoryList(TempleUtils.buildCategoryDataList(0));
LunchPojo secondRow = buildLunchCategoryList(TempleUtils.buildCategoryDataList(1));
LunchPojo scroll = buildLunchScroll();
scroll.setItems(Arrays.asList(firstRow,secondRow));
mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll,CATEGORY_FOOTER));
return document;
}
private static LunchPojo buildLunchScroll() { private static LunchPojo buildLunchScroll() {
LunchPojo scroll = new LunchPojo(); LunchPojo scroll = new LunchPojo();
scroll.setType("ScrollView"); scroll.setType("ScrollView");
...@@ -93,6 +109,8 @@ public class LunchUtils { ...@@ -93,6 +109,8 @@ public class LunchUtils {
//container.setMarginTop("25dp"); //container.setMarginTop("25dp");
container.setType("Container"); container.setType("Container");
container.setWidth("100%"); container.setWidth("100%");
container.setMarginTop("180dp");
container.setAlignItems("center");
LunchPojo list = new LunchPojo(); LunchPojo list = new LunchPojo();
list.setType("List"); list.setType("List");
...@@ -241,6 +259,23 @@ public class LunchUtils { ...@@ -241,6 +259,23 @@ public class LunchUtils {
return footerCon; return footerCon;
} }
private static LunchPojo buildCategoryFooter() {
LunchPojo footerCon = new LunchPojo();
footerCon.setType("Container");
footerCon.setPosition("absolute");
footerCon.setWidth("100%");
footerCon.setLeft("0");
footerCon.setBottom("0");
LunchPojo footer = new LunchPojo();
footer.setType("Footer");
footer.setHints(Arrays.asList("打开第一个","返回"));
footerCon.setItems(Collections.singletonList(footer));
return footerCon;
}
private static LunchPojo buildLogoImage() { private static LunchPojo buildLogoImage() {
LunchPojo logoCon = new LunchPojo(); LunchPojo logoCon = new LunchPojo();
logoCon.setType("Container"); logoCon.setType("Container");
......
...@@ -9,6 +9,7 @@ import ai.qiwu.com.xiaoduhome.pojo.dpl.Event; ...@@ -9,6 +9,7 @@ import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
import ai.qiwu.com.xiaoduhome.service.ScheduleService; import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew; import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
...@@ -86,29 +87,25 @@ public class RecommendUtil { ...@@ -86,29 +87,25 @@ public class RecommendUtil {
List<RecommandPojo> scrollList = new ArrayList<>(); List<RecommandPojo> scrollList = new ArrayList<>();
scrollView.setItems(scrollList); scrollView.setItems(scrollList);
List<String> categoryIdList = ScheduleService.getCategoryProductIdList().get(category); List<ProjectData> dataList = ScheduleServiceNew.category2Bots.get(category);
if (categoryIdList == null || categoryIdList.size() == 0) return null;
int bound = categoryIdList.size(); if (CollectionUtils.isEmpty(dataList)) return null;
int bound = dataList.size();
int begin = num*RE_RA_CA_PAGE_SIZE; int begin = num*RE_RA_CA_PAGE_SIZE;
int end; int end;
if (begin >= bound) return null; if (begin >= bound) return null;
bound = begin+RE_RA_CA_PAGE_SIZE <= bound ? begin+RE_RA_CA_PAGE_SIZE : bound; bound = begin+RE_RA_CA_PAGE_SIZE <= bound ? begin+RE_RA_CA_PAGE_SIZE : bound;
List<OnProductDetail> 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(); //StringBuilder botIds = new StringBuilder();
int count = 0; int count = 0;
while (begin < bound) { while (begin < bound) {
end = begin+4 <= bound ? begin+4 : bound; end = begin+4 <= bound ? begin+4 : bound;
scrollList.add(buildRecommendList(getListDataNoIds(count, begin, end, null))); scrollList.add(buildRecommendList(getListDataNoIds(count, begin, end, dataList)));
count++; count++;
begin = end; begin = end;
} }
int pageSize = categoryIdList.size() / RE_RA_CA_PAGE_SIZE + (categoryIdList.size()%RE_RA_CA_PAGE_SIZE == 0 ? 0:1); int pageSize = dataList.size() / RE_RA_CA_PAGE_SIZE + (dataList.size()%RE_RA_CA_PAGE_SIZE == 0 ? 0:1);
mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,buildRecommendCollectHead(category), mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,buildRecommendCollectHead(category),
scrollView,buildPageButton(num+1, pageSize),RANK_CATEGORY_FOOTER)); scrollView,buildPageButton(num+1, pageSize),RANK_CATEGORY_FOOTER));
......
package ai.qiwu.com.xiaoduhome.pojo.data; package ai.qiwu.com.xiaoduhome.pojo.data;
import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
...@@ -14,6 +15,7 @@ import java.util.List; ...@@ -14,6 +15,7 @@ import java.util.List;
@Getter @Getter
@Setter @Setter
@ToString @ToString
@EqualsAndHashCode
public class ProjectData { public class ProjectData {
private String name; private String name;
private String intro; private String intro;
......
...@@ -6,6 +6,7 @@ import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils; ...@@ -6,6 +6,7 @@ import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import ai.qiwu.com.xiaoduhome.common.Utils; import ai.qiwu.com.xiaoduhome.common.Utils;
import ai.qiwu.com.xiaoduhome.common.temple.CollectHistoryDocument; import ai.qiwu.com.xiaoduhome.common.temple.CollectHistoryDocument;
import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils; import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils;
import ai.qiwu.com.xiaoduhome.common.temple.onLunch.LunchDocument;
import ai.qiwu.com.xiaoduhome.common.temple.onLunch.LunchUtils; import ai.qiwu.com.xiaoduhome.common.temple.onLunch.LunchUtils;
import ai.qiwu.com.xiaoduhome.common.temple.play.PlayDocument; import ai.qiwu.com.xiaoduhome.common.temple.play.PlayDocument;
import ai.qiwu.com.xiaoduhome.common.temple.play.PlayUtils; import ai.qiwu.com.xiaoduhome.common.temple.play.PlayUtils;
...@@ -822,6 +823,15 @@ public class DplBotServiceBoth extends BaseBot { ...@@ -822,6 +823,15 @@ public class DplBotServiceBoth extends BaseBot {
return new Response(outputSpeech); return new Response(outputSpeech);
} }
private Response dealOpenCategory() {
LunchDocument document = LunchUtils.buildCategoryDocument();
if (document == null) return new Response();
RenderDocument render = new RenderDocument(document);
this.addDirective(render);
this.setSessionAttribute("trace","07");
return buildErrorResponse("正在为您打开分类页");
}
private Response dealOpenCollectClick() { private Response dealOpenCollectClick() {
if (getAccessToken() == null) { if (getAccessToken() == null) {
OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "该功能需要登录,请说小度小度,登录"); OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "该功能需要登录,请说小度小度,登录");
...@@ -1587,6 +1597,7 @@ public class DplBotServiceBoth extends BaseBot { ...@@ -1587,6 +1597,7 @@ public class DplBotServiceBoth extends BaseBot {
case '4': case '4':
case '6': response = dealOpenNumInRecommend(getSessionAttribute(PRE_COLLE), num, channelId); break; case '6': response = dealOpenNumInRecommend(getSessionAttribute(PRE_COLLE), num, channelId); break;
case '5': response = dealOpenNumInCategory(channelId);break; case '5': response = dealOpenNumInCategory(channelId);break;
case '7': response = dealOpenNumInCategory(channelId);break;
default:{ default:{
response = buildErrorResponse("屏幕上的图标都是可以点击的哦"); response = buildErrorResponse("屏幕上的图标都是可以点击的哦");
} }
...@@ -1870,6 +1881,7 @@ public class DplBotServiceBoth extends BaseBot { ...@@ -1870,6 +1881,7 @@ public class DplBotServiceBoth extends BaseBot {
case "store" : return dealCollectOrUnCollectIntent(userId, "collect"); case "store" : return dealCollectOrUnCollectIntent(userId, "collect");
case "unStore" : return dealCollectOrUnCollectIntent(userId, "unCollect"); case "unStore" : return dealCollectOrUnCollectIntent(userId, "unCollect");
case "flower" : return dealSendFlowerIntent(userId, txt.substring(end+1)); case "flower" : return dealSendFlowerIntent(userId, txt.substring(end+1));
case "category" : return dealOpenCategory();
} }
} }
} }
...@@ -1974,23 +1986,31 @@ public class DplBotServiceBoth extends BaseBot { ...@@ -1974,23 +1986,31 @@ public class DplBotServiceBoth extends BaseBot {
} }
} }
private Response dealOpenNumInCategory(String channelId) { private Response dealOpenCategory(int num) {
if (num > ScheduleServiceNew.CATEGORY.length) return buildErrorResponse(num+"超出了范围");
String category = getSessionAttribute("category");
if (StringUtils.isBlank(category)) return buildErrorResponse("请直接点击进入");
RecommandDocument document = RecommendUtil.getCategory(num, category);
if (document == null) return new
}
private Response dealOpenNumInCategory(String channelId, int num) {
String count = getSessionAttribute("comCnt"); String count = getSessionAttribute("comCnt");
String category = getSessionAttribute("category");
if (StringUtils.isBlank(category)) return buildErrorResponse("请直接点击进入");
int pageIndex = 0; int pageIndex = 0;
if (count != null) pageIndex = Integer.parseInt(count)-1; if (count != null) pageIndex = Integer.parseInt(count)-1;
String numStr = getSlot("sys.number");
int num = 1;
if (numStr != null) num = Integer.parseInt(numStr);
List<String> categoryBots = ScheduleService.getCategoryProductIdList().get(getSessionAttribute("category"));
num = pageIndex*RE_RA_CA_PAGE_SIZE+num-1; num = pageIndex*RE_RA_CA_PAGE_SIZE+num-1;
List<ProjectData> categoryBots = ScheduleServiceNew.category2Bots.get(category);
if (num < 0 || num >= categoryBots.size()) { if (num < 0 || num >= categoryBots.size()) {
return buildErrorResponse("这个数字超出了范围,作品的序号已显示在图片左上角"); return buildErrorResponse("这个数字超出了范围,作品的序号已显示在图片左上角");
} }
String botId = categoryBots.get(num); ProjectData bot = categoryBots.get(num);
String name = ScheduleServiceNew.getProjectByBotAccount(botId).getName();
Response response; Response response;
if (DplbotServiceUtil.doesUserPlayed(botId, getUserId(), getAccessToken())) response = directInProduct(correctName(name), botId); if (DplbotServiceUtil.doesUserPlayed(bot.getBotAccount(), getUserId(), getAccessToken())) {
else response = enterProductInfo(correctName(name), channelId); response = directInProduct(bot.getName(), bot.getBotAccount());
} else response = enterProductInfo(bot.getName(), channelId);
setSessionAttribute("category", category);
return response; return response;
} }
......
...@@ -495,10 +495,9 @@ public class DplbotServiceUtil { ...@@ -495,10 +495,9 @@ public class DplbotServiceUtil {
String intro = productDetail.getIntro(); String intro = productDetail.getIntro();
if (StringUtils.isBlank(intro)) intro = "作者太懒没写介绍"; if (StringUtils.isBlank(intro)) intro = "作者太懒没写介绍";
String imgUrl = new StringBuilder(IMG_PREFIX).append(productDetail.getBannerImgUrl()).toString();
String botAccountId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(correctName(productDetail.getName())).toString(); String botAccountId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(correctName(productDetail.getName())).toString();
String name = productDetail.getName(); String name = productDetail.getName();
HistoryData data = new HistoryData(botAccountId, j++, imgUrl, correctName(name), intro); HistoryData data = new HistoryData(botAccountId, j++, productDetail.getBannerImgUrl(), correctName(name), intro);
data.setAuthorName(productDetail.getAuthorName()); data.setAuthorName(productDetail.getAuthorName());
projectInfoList.add(data); projectInfoList.add(data);
} }
......
...@@ -37,6 +37,11 @@ public class ScheduleServiceNew implements InitializingBean { ...@@ -37,6 +37,11 @@ public class ScheduleServiceNew implements InitializingBean {
static volatile Long curTime = System.currentTimeMillis(); static volatile Long curTime = System.currentTimeMillis();
public static final String[] CATEGORY = {"古风", "言情", "灾难", "冒险", "武侠", "穿越"};
public static final String[] CATEGORY_CHARAC={"gufeng","yanqing","zainan","maoxian","wuxia", "chuanyue"};
public static volatile Map<String, List<ProjectData>> category2Bots = new HashMap<>();
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
getAllProjects(); getAllProjects();
...@@ -58,6 +63,13 @@ public class ScheduleServiceNew implements InitializingBean { ...@@ -58,6 +63,13 @@ public class ScheduleServiceNew implements InitializingBean {
list.forEach(projectData -> { list.forEach(projectData -> {
botAcc.put(projectData.getBotAccount(), projectData); botAcc.put(projectData.getBotAccount(), projectData);
name.put(projectData.getName(), projectData); name.put(projectData.getName(), projectData);
List<ProjectData> bots;
for (int i = 0; i < CATEGORY.length; i++) {
if (projectData.getLabels().contains(CATEGORY[i])) {
bots = category2Bots.computeIfAbsent(CATEGORY_CHARAC[i], s -> new ArrayList<>());
bots.add(projectData);
}
}
}); });
botAccount2Project = botAcc; botAccount2Project = botAcc;
name2Project = name; name2Project = name;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment