Commit 9109fa09 by 苗权威

9.6

parent 75bae4da
......@@ -441,7 +441,7 @@ public class TTService {
/**
* 若文件已存在则不进行覆盖,除非是put更新请求.
* 首先从音频下载地址下载数据到本地,文件地址为filepath(该文件原指的是mp3文件,先改为wav文件),
* 首先从音频下载地址下载数据到本地,文件地址为filepath(该路径以.mp3结尾,先改为wav文件),
* 该下载好的wav文件经过python的change_sound方法生成mp3文件,该文件即filepath.
*
* @param url 音频下载地址
......@@ -468,7 +468,7 @@ public class TTService {
}
//long wavStartTime = System.currentTimeMillis();
//log.info("url:{}", url);
res = requestTemplate(url, data, wavFilename, longTime);
res = requestTemplate(url, data, wavFilename, longTime, true);
//long wavEndTime = System.currentTimeMillis();
//log.info("wav whole time:{}", (wavEndTime-wavStartTime)/1000.0);
if (res.getCode() != 200) {
......@@ -486,7 +486,7 @@ public class TTService {
}else if (!fileExist) {
if (offlineService.equals(url)) {
data.setFormat("mp3");
res = requestTemplate(url , data, filePath, false);
res = requestTemplate(url , data, filePath, false, false);
if (res.getCode() != 200) {
log.error("线下请求音频文件:{},失败:{}",filePath, res);
}
......@@ -571,7 +571,7 @@ public class TTService {
* @param longTime 线下测试超时为3s,线上为12s
* @return 返回状态码,调用方法通过此来判断方法是否成功
*/
private ResponseCodeWithData requestTemplate(String url, GeneralMP3Data data, String filePath, boolean longTime) {
private ResponseCodeWithData requestTemplate(String url, GeneralMP3Data data, String filePath, boolean longTime, boolean getOnline) {
String dataStr = JSON.toJSONString(data);
// log.info("GeneralMP3Data:{}", dataStr);
ResponseCodeWithData res = null;
......@@ -602,6 +602,7 @@ public class TTService {
return res;
}
else if (resCode == 404 && url.equals(offlineService)) {
if (!getOnline) return new ResponseCodeWithData(404, "没有找到该文件");
String person = data.getPerson();
String mood = data.getTone();
try {
......
package ai.qiwu.com.xiaoduhome.common.temple;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Item;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
......@@ -30,14 +31,6 @@ public class FrameTemple implements Agent{
private String fontSize;
@JsonProperty("margin-left")
private String marginLeft;
@JsonProperty("margin-bottom")
private String marginBottom;
@JsonProperty("margin-top")
private String marginTop;
private String width;
private String height;
@JsonProperty("border-width")
private String borderWidth;
@JsonProperty("border-top-left-radius")
private String borderTopLeftRadius;
@JsonProperty("border-top-right-radius")
......@@ -48,10 +41,8 @@ public class FrameTemple implements Agent{
private String paddingVertical;
@JsonProperty("padding-horizontal")
private String paddingHorizontal;
@JsonProperty("border-color")
private String borderColor;
@JsonProperty("background-color")
private String backgroundColor;
private String color;
private String position;
private String height;
}
......@@ -6,10 +6,7 @@ import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.*;
/**
* @author 苗权威
......@@ -62,8 +59,7 @@ public class LunchUtils {
LunchPojo list = new LunchPojo();
list.setType("List");
list.setHeight("310dp");
list.setMarginLeft("15dp");
list.setMarginRight("15dp");
list.setMarginLeft("30dp");
list.setDirection("horizontal");
list.setData(data);
list.setItems(Collections.singletonList(LUNCH_LIST_CATEGORY_CON));
......@@ -80,8 +76,8 @@ public class LunchUtils {
LunchPojo list = new LunchPojo();
list.setType("List");
list.setMarginLeft("15dp");
list.setMarginRight("15dp");
list.setMarginLeft("30dp");
// list.setMarginRight("15dp");
list.setMarginBottom("70dp");
list.setDirection("horizontal");
list.setData(data);
......@@ -101,9 +97,9 @@ public class LunchUtils {
private static LunchPojo buildImgFrmTxtContainer() {
LunchPojo container = new LunchPojo();
container.setType("Container");
container.setMarginTop("40dp");
container.setMarginTop("30dp");
container.setWidth("200dp");
container.setMarginLeft("20dp");
container.setMarginRight("33dp");
//image
LunchPojo image = new LunchPojo();
......@@ -123,7 +119,7 @@ public class LunchUtils {
frame.setType("Frame");
frame.setWidth("35dp");
frame.setHeight("35dp");
frame.setBackgroundColor("rgba(0,0,0,0.9)");
frame.setBackgroundColor("rgba(0,0,0,0.8)");
frame.setBorderRadius("13dp");
LunchPojo frmCon = new LunchPojo();
......@@ -144,7 +140,7 @@ public class LunchUtils {
LunchPojo text = new LunchPojo();
text.setType("Text");
text.setFontSize("23dp");
text.setMarginTop("160dp");
text.setMarginTop("168dp");
text.setMarginLeft("7dp");
text.setText("${data.imageName}");
......
......@@ -5,6 +5,7 @@ import ai.qiwu.com.xiaoduhome.common.Constants;
import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils;
import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Data;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
import ai.qiwu.com.xiaoduhome.service.ScheduleService;
......@@ -59,6 +60,49 @@ public class RecommendUtil {
return document;
}
public static RecommandDocument getCategory(int num, String category) {
RecommandDocument document = new RecommandDocument();
RecommandMainTemplate mainTemplate = new RecommandMainTemplate();
document.setMainTemplate(mainTemplate);
RecommandPojo scrollView = new RecommandPojo();
scrollView.setType("ScrollView");
scrollView.setWidth("100%");
scrollView.setMarginBottom("93dp");
scrollView.setDirection("vertical");
List<RecommandPojo> scrollList = new ArrayList<>();
scrollView.setItems(scrollList);
List<String> categoryIdList = ScheduleService.getCategoryProductIdList().get(category);
if (categoryIdList == null || categoryIdList.size() == 0) return null;
int bound = categoryIdList.size();
int begin = num*16;
int end;
if (begin >= bound) return null;
bound = begin+16 <= bound ? begin+16 : bound;
List<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();
int count = 0;
while (begin < bound) {
end = begin+4 <= bound ? begin+4 : bound;
scrollList.add(buildRecommendList(getListData(count,begin, end, bots, botIds)));
count++;
begin = end;
}
mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,RECOM_HEAD,scrollView,RECOM_FOOTER));
botIds.deleteCharAt(botIds.length()-1);
String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
document.setRecommendIdList(idToken);
return document;
}
private static List<RecommandBotInfo> getListData(int row,int begin, int end, List<OnProductDetail> bots, StringBuilder botIds) {
List<RecommandBotInfo> data = new ArrayList<>();
int n = 1+row*4;
......
......@@ -5,6 +5,8 @@ import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-8-6 下午9:26
......@@ -28,6 +30,7 @@ public class Event {
private String repeatCount;
private String position;
private String value;
private List<Event> onComplete;
public Event() {
}
......
......@@ -23,6 +23,9 @@ public interface GameProjectTbRepository extends JpaRepository<GameProjectTb, In
@Query(value = "select p.id,p.intro,p.name,p.watch,p.banner_img_url,p.apply_status,p.bot_account,p.user_nickname from game_project_tb as p,game_project_label_tb as l where l.name= :category and p.id = l.project_id and p.apply_status=1", nativeQuery = true)
List<GameProjectTb> categoryProject(@Param("category") String category);
@Query(value = "select p.bot_account from game_project_tb as p,game_project_label_tb as l where l.name=?1 and p.apply_status=1 and p.id = l.project_id",nativeQuery = true)
List<String> categoryProList(String category);
@Query(value = "select id,intro,name,watch,banner_img_url,apply_status,bot_account,user_nickname from game_project_tb where apply_status = 1 order by watch desc limit ?1,8", nativeQuery = true)
List<GameProjectTb> postRankBot(Integer begin);
}
......@@ -41,8 +41,9 @@ public class ScheduleService implements InitializingBean {
static final List<String> EXCEPT_BOT_ACCOUNT = new ArrayList<>();
static final String[] CATEGORY = {"古风", "儿童", "科幻", "占星", "恋爱", "灾难", "架空", "经营", "冒险", "武侠"};
static final String[] CATEGORY_CHARAC={"gufeng","child","kehuan","zhanxing","lianai","zainan","jiakong","jingying","maoxian","wuxia"};
static final ConcurrentHashMap<String, List<GameProjectTb>> CATEGORY_PRODUCT_LIST = new ConcurrentHashMap<>();
private static final String[] CATEGORY_CHARAC={"gufeng","child","kehuan","zhanxing","lianai","zainan","jiakong","jingying","maoxian","wuxia"};
static final HashMap<String,List<String>> CATEGORY_PRODUCT_ID_LIST = new HashMap<>();
private final GameProjectTbRepository gameProjectTbRepository;
......@@ -71,6 +72,7 @@ public class ScheduleService implements InitializingBean {
public void initRankingList() {
new Thread(() -> {
RANKING_LIST = gameProjectTbRepository.findFirst10ByApplyStatusOrderByWatchDesc(1);
LunchUtils.setLunchDocument(LunchUtils.buildLunchDocument());
//log.info("排行榜:{}", RANKING_LIST);
}).start();
//log.error("更新排行榜出错:{}", e.getMessage());
......@@ -80,6 +82,7 @@ public class ScheduleService implements InitializingBean {
public void initRecommendList() {
new Thread(() -> {
RECOMMEND_LIST = gameProjectTbRepository.recommendList();
LunchUtils.setLunchDocument(LunchUtils.buildLunchDocument());
//log.info("推荐:{}", RECOMMEND_LIST);
}).start();
//log.error("更新推荐页出错:{}", e.getMessage());
......@@ -104,13 +107,15 @@ public class ScheduleService implements InitializingBean {
//log.error("更新推荐页出错:{}", e.getMessage());
}
@Scheduled(cron = "0 0 1 ? * 7")
@Scheduled(cron = "0 0 1 * * ?")
public void initProductList() {
new Thread(() -> {
for (String category: CATEGORY) {
List<GameProjectTb> list = gameProjectTbRepository.categoryProject(category);
CATEGORY_PRODUCT_LIST.put(category, list);
log.info("分类{},作品列表{}", category, list);
//List<GameProjectTb> list = gameProjectTbRepository.categoryProject(category);
List<String> idList = gameProjectTbRepository.categoryProList(category);
CATEGORY_PRODUCT_ID_LIST.put(category, idList);
//CATEGORY_PRODUCT_LIST.put(category, list);
//log.info("分类{},作品列表{}", category, list);
}
}).start();
//log.error("更新分类作品列表出错:{}", e.getMessage());
......@@ -141,7 +146,6 @@ public class ScheduleService implements InitializingBean {
public void shuffleAllProList() {
new Thread(() -> {
Collections.shuffle(ALL_ON_PRODUCT);
LunchUtils.setLunchDocument(LunchUtils.buildLunchDocument());
}).start();
}
......@@ -222,4 +226,8 @@ public class ScheduleService implements InitializingBean {
public static String[] getCategoryCharac() {
return CATEGORY_CHARAC;
}
public static HashMap<String, List<String>> getCategoryProductIdList() {
return CATEGORY_PRODUCT_ID_LIST;
}
}
......@@ -5,7 +5,7 @@
"items": [
{
"type": "Text",
"font-size": "31dp",
"font-size": "28dp",
"margin-left": "30dp"
},
{
......@@ -20,8 +20,8 @@
"items": [
{
"type": "Text",
"font-size": "23dp",
"color": "rgb(255,255,255)"
"font-size": "22dp",
"color": "rgba(255,255,255,0.8)"
}
]
}
......
......@@ -38,7 +38,13 @@
"attribute": "rotation",
"duration": 3000,
"repeatCount": 4,
"repeatMode": "reverse"
"repeatMode": "reverse",
"onComplete": [
{
"type": "SendEvent",
"componentId": "test2333333"
}
]
}
]
},
......
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