Commit 4f01d931 by 苗权威

10.9

parent 57788ede
......@@ -232,6 +232,9 @@ public class TTService {
}
List<Future<ResponseCodeWithData>> futures = new ArrayList<>();
List<String> 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);
......
......@@ -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"));
}
}
......@@ -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";
......
......@@ -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;
......
......@@ -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();
......
......@@ -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<LunchBotData> buildCategoryDataList() {
ArrayList<LunchBotData> 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);
......
......@@ -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");
......
......@@ -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;
......
......@@ -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");
......
......@@ -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();
......
......@@ -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;
}
......@@ -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();
......
......@@ -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<GameProjectTb> RANKING_LIST = new ArrayList<>();
private static volatile List<GameProjectTb> RECOMMEND_LIST = new ArrayList<>();
private static volatile List<OnProductDetail> ALL_ON_PRODUCT = new ArrayList<>();
private static volatile List<OnProductDetail> RANK_ORDER_IDs = new ArrayList<>();
static final HashMap<String, OnProductDetail> PRODUCT_NAME_DETAIL = new HashMap<>();
static final HashMap<String, OnProductDetail> PRODUCT_ID_DETAIL = new HashMap<>();
static volatile HashMap<String, OnProductDetail> PRODUCT_NAME_DETAIL = new HashMap<>();
static volatile HashMap<String, OnProductDetail> PRODUCT_ID_DETAIL = new HashMap<>();
private static final HashMap<String, Map<String,String>> ASIDE_IMG = new HashMap<>();
private static volatile HashMap<String, Map<String,String>> ASIDE_IMG = new HashMap<>();
private static final HashMap<String, String> NX2_BOT_TO_HZ1 = new HashMap<>();
private static final HashMap<String, String> 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<String,List<String>> CATEGORY_PRODUCT_ID_LIST = new HashMap<>();
private static volatile HashMap<String,List<String>> 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<Long, OnProductDetail> rankOrder = new TreeMap<>((o1, o2) -> o1-o2 < 0 ? 1 :(o1.equals(o2) ? 0 : -1));
HashMap<String, OnProductDetail> nd = new HashMap<>();
HashMap<String, OnProductDetail> id = new HashMap<>();
for (OnProductDetail item : ALL_ON_PRODUCT) {
String productName = item.getName();
String botAccount = item.getBotAccount();
List<String> 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<String,List<String>> ci = new HashMap<>();
for (String category: CATEGORY) {
//List<GameProjectTb> list = gameProjectTbRepository.categoryProject(category);
List<String> 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<String> botIds = gameProjectTbRepository.getAllOnTableProductIds();
HashMap<String, Map<String,String>> 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;
}
}
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