Commit 57788ede by 苗权威

9.30

parent 5cc34529
......@@ -262,5 +262,12 @@ public class Test {
combineMp3Text2FilePath.put(s, s);
}
System.out.println(combineMp3Text2FilePath.values());
String mr = "igaijgoj©️ge要不断he";
System.out.println(mr.replaceAll("\\p{P}", ""));
System.out.println(mr.replaceAll("\\W", ""));
String ssss = "你当{/dang1/}前分{/fen1/}数{/shu4/}是\uD83C\uDD700\uD83C\uDD71。";
System.out.println(TTSUtils.buildMP3Filename(ssss));
}
}
......@@ -34,7 +34,7 @@ public interface Constants {
String UNIT_PRICE = "1";
Integer CO_HI_PAGE_SIZE = 4;
Integer RE_RA_CA_PAGE_SIZE = 20;
Integer RE_RA_CA_PAGE_SIZE = 16;
interface DPL_COMPONENT_ID {
String FLOWE = "flowe";
......
......@@ -51,5 +51,7 @@ public class RecommandPojo {
private List<RecommandBotInfo> data;
@JsonProperty("background-color")
private String backgroundColor;
@JsonProperty("flex-direction")
private String flexDirection;
}
......@@ -12,6 +12,8 @@ import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import java.io.File;
import java.util.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.RE_RA_CA_PAGE_SIZE;
/**
* @author 苗权威
* @dateTime 19-9-5 上午11:25
......@@ -39,11 +41,11 @@ public class RecommendUtil {
int bound = ScheduleService.getAllProductCount();
List<OnProductDetail> bots = ScheduleService.getAllOnProduct();
StringBuilder botIds = new StringBuilder();
int begin = num*16;
int begin = num*RE_RA_CA_PAGE_SIZE;
int end;
if (begin >= bound) return null;
bound = begin+16 <= bound ? begin+16 : bound;
bound = begin+RE_RA_CA_PAGE_SIZE <= bound ? begin+RE_RA_CA_PAGE_SIZE : bound;
int count = 0;
while (begin < bound) {
......@@ -76,10 +78,10 @@ public class RecommendUtil {
List<String> categoryIdList = ScheduleService.getCategoryProductIdList().get(category);
if (categoryIdList == null || categoryIdList.size() == 0) return null;
int bound = categoryIdList.size();
int begin = num*16;
int begin = num*RE_RA_CA_PAGE_SIZE;
int end;
if (begin >= bound) return null;
bound = begin+16 <= bound ? begin+16 : 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++) {
......@@ -91,7 +93,7 @@ public class RecommendUtil {
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(getListData(count, begin, end, bots, botIds)));
count++;
begin = end;
}
......@@ -103,6 +105,140 @@ public class RecommendUtil {
return document;
}
public static RecommandDocument getRankDocumentFirstPage() {
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);
RecommandPojo rowContainer = new RecommandPojo();
rowContainer.setType("Container");
rowContainer.setFlexDirection("row");
List<OnProductDetail> list = ScheduleService.getRANK_ORDER_IDs();
OnProductDetail first = list.get(0);
OnProductDetail second = list.get(1);
OnProductDetail third = list.get(2);
OnProductDetail forth = list.get(3);
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());
rowContainer.setItems(Arrays.asList(pojoFirst, pojoSe, pojoThird, pojoFourth));
scrollList.add();
for (int i = 4; i < ; i++) {
}
getListData()
}
private static RecommandPojo buildImgFrmTxtContainerFirstRow(String imgSrc, String imgId, String productName, String rankImgSrc) {
RecommandPojo container = new RecommandPojo();
container.setType("Container");
container.setWidth("220dp");
container.setMarginLeft("15dp");
//image
RecommandPojo image = new RecommandPojo();
image.setType("Image");
image.setWidth("190dp");
image.setHeight("190dp");
image.setMarginLeft("7dp");
image.setMarginTop("7dp");
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", imgId)));
//frame
RecommandPojo rankImg = new RecommandPojo();
rankImg.setType("Image");
rankImg.setWidth("55dp");
rankImg.setHeight("55dp");
image.setSrc(rankImgSrc);
//text
RecommandPojo text = new RecommandPojo();
text.setType("Text");
text.setFontSize("25dp");
text.setMarginTop("160dp");
text.setMarginLeft("7dp");
text.setText(productName);
container.setItems(Arrays.asList(image,rankImg,text));
return container;
}
private static RecommandPojo buildImgFrmTxtContainerFourth(String imgSrc, String imgName) {
RecommandPojo container = new RecommandPojo();
container.setType("Container");
container.setWidth("220dp");
container.setMarginLeft("15dp");
//image
RecommandPojo image = new RecommandPojo();
image.setType("Image");
image.setWidth("190dp");
image.setHeight("190dp");
image.setMarginLeft("7dp");
image.setMarginTop("7dp");
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}")));
//frame
RecommandPojo frame = new RecommandPojo();
frame.setType("Frame");
frame.setWidth("40dp");
frame.setHeight("40dp");
frame.setBackgroundColor("rgba(0,0,0,0.9)");
frame.setBorderRadius("12dp");
RecommandPojo frmCon = new RecommandPojo();
frmCon.setType("Container");
frmCon.setWidth("100%");
frmCon.setHeight("100%");
frmCon.setAlignItems("center");
RecommandPojo frmText = new RecommandPojo();
frmText.setType("Text");
frmText.setText("4");
frmText.setFontSize("28dp");
frmCon.setItems(Collections.singletonList(frmText));
frame.setItems(Collections.singletonList(frmCon));
//text
RecommandPojo text = new RecommandPojo();
text.setType("Text");
text.setFontSize("25dp");
text.setMarginTop("160dp");
text.setMarginLeft("7dp");
text.setText(imgName);
container.setItems(Arrays.asList(image,frame,text));
return container;
}
public static RecommandDocument getRankDocument() {
}
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;
......
......@@ -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();
......
......@@ -383,8 +383,12 @@ public class TestBuild {
//csvUtil(target1, src, srcModify, v2);
//check(src, srcModify, target);
test4();
//csvUtilByCommon(target2, src, srcModify, v2);
//test4();
String tomTarget = "/home/yf01/下载/tts/tom.csv";
String tomSrc = "/home/yf01/下载/汤姆OldFresh.csv";
String tomSrcModify = "/home/yf01/下载/tomFilled.csv";
String tomV2 = "/home/yf01/下载/汤姆NewFresh.csv";
csvUtilByCommon(tomTarget, tomSrc, tomSrcModify, tomV2);
//System.out.println(test5(target1, target2));
//System.out.println(test6(target2, v2));
......
......@@ -15,9 +15,9 @@ import java.util.List;
@Repository
public interface GameProjectTbRepository extends JpaRepository<GameProjectTb, Integer> {
List<GameProjectTb> findFirst10ByApplyStatusOrderByWatchDesc(Integer applyStatus);
List<GameProjectTb> findFirst8ByApplyStatusOrderByWatchDesc(Integer applyStatus);
@Query(value = "select id,intro,name,watch,banner_img_url,apply_status,bot_account,user_nickname from game_project_tb where apply_status = 1 and id >= (select floor(RAND()*(select MAX(id) from game_project_tb))) order by id limit 10", nativeQuery = true)
@Query(value = "select id,intro,name,watch,banner_img_url,apply_status,bot_account,user_nickname from game_project_tb where apply_status = 1 and id >= (select floor(RAND()*(select MAX(id) from game_project_tb))) order by id limit 8", nativeQuery = true)
List<GameProjectTb> recommendList();
@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)
......
......@@ -383,12 +383,13 @@ public class DplBotService extends BaseBot {
private Response dealHistoryClick() {
CollectHistoryDocument document = DplbotServiceUtil.getHistory(getUserId(), getAccessToken(), 0);
if (document == null) return new Response();
if (document == null) return buildErrorResponse("不好意思,您太久没玩记录被清空了");
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");
OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "正在为您打开历史记录");
return new Response(outputSpeech);
......@@ -410,6 +411,7 @@ public class DplBotService extends BaseBot {
if (document != null) {
RenderDocument render = new RenderDocument(document);
addDirective(render);
setSessionAttribute("comCnt", null);
setSessionAttribute(PRE_COLLE,document.getIdToken());
setSessionAttribute(BACK_TRACE, "01");
OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "正在为您打开收藏夹");
......@@ -709,8 +711,13 @@ public class DplBotService extends BaseBot {
if (collect) document = DplbotServiceUtil.getCollectPage(userId, getAccessToken(), getSessionAttribute("userId"), start);
else document = DplbotServiceUtil.getHistory(userId, getAccessToken(), start);
if (document != null) {
RenderDocument render = new RenderDocument(document);
addDirective(render);
detail.getDirectives().add(render);
String cmt = String.valueOf(index+1);
setSessionAttribute("comCnt",cmt);
setSessionAttribute(PRE_COLLE, document.getIdToken());
detail.getAttributes().put(PRE_COLLE, document.getIdToken());
detail.getAttributes().put("comCnt", cmt);
} else {
detail.setResponse(buildErrorResponse("超出了范围无法跳到那一页"));
......@@ -918,8 +925,10 @@ public class DplBotService extends BaseBot {
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);
......@@ -943,9 +952,11 @@ public class DplBotService extends BaseBot {
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());
......@@ -974,8 +985,13 @@ public class DplBotService extends BaseBot {
CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(userId, getAccessToken(),
getSessionAttribute("userId"), start);
if (document != null) {
RenderDocument render = new RenderDocument(document);
addDirective(render);
detail.getDirectives().add(render);
String cmt = String.valueOf(count+1);
setSessionAttribute("comCnt",cmt);
setSessionAttribute(PRE_COLLE, document.getIdToken());
detail.getAttributes().put(PRE_COLLE,document.getIdToken());
detail.getAttributes().put("comCnt", cmt);
} else {
detail.setResponse(buildErrorResponse("已经到最后一页了"));
......@@ -991,8 +1007,13 @@ public class DplBotService extends BaseBot {
int start = count*CO_HI_PAGE_SIZE;
CollectHistoryDocument document = DplbotServiceUtil.getHistory(userId, getAccessToken(), start);
if (document != null) {
RenderDocument render = new RenderDocument(document);
addDirective(render);
detail.getDirectives().add(render);
String cmt = String.valueOf(count+1);
setSessionAttribute("comCnt",cmt);
setSessionAttribute(PRE_COLLE, document.getIdToken());
detail.getAttributes().put(PRE_COLLE,document.getIdToken());
detail.getAttributes().put("comCnt", cmt);
} else {
detail.setResponse(buildErrorResponse("已经到最后一页了"));
......@@ -1124,8 +1145,13 @@ public class DplBotService extends BaseBot {
CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(userId, getAccessToken(),
getSessionAttribute("userId"), start);
if (document != null) {
RenderDocument render = new RenderDocument(document);
addDirective(render);
detail.getDirectives().add(render);
String cmt = String.valueOf(count-1);
setSessionAttribute("comCnt",cmt);
setSessionAttribute(PRE_COLLE, document.getIdToken());
detail.getAttributes().put(PRE_COLLE, document.getIdToken());
detail.getAttributes().put("comCnt", cmt);
}
break;
......@@ -1140,8 +1166,13 @@ public class DplBotService extends BaseBot {
int start = (count-2)*CO_HI_PAGE_SIZE;
CollectHistoryDocument document = DplbotServiceUtil.getHistory(userId, getAccessToken(), start);
if (document != null) {
RenderDocument render = new RenderDocument(document);
addDirective(render);
detail.getDirectives().add(render);
String cmt = String.valueOf(count-1);
setSessionAttribute("comCnt",cmt);
setSessionAttribute(PRE_COLLE, document.getIdToken());
detail.getAttributes().put(PRE_COLLE, document.getIdToken());
detail.getAttributes().put("comCnt", cmt);
}
break;
......@@ -1293,6 +1324,8 @@ public class DplBotService extends BaseBot {
addDirective(render);
setSessionAttribute(PRE_COLLE,document.getIdToken());
setSessionAttribute(BACK_TRACE, "01");
setSessionAttribute("comCnt", null);
detail.getAttributes().put("comCnt", null);
detail.getAttributes().put(PRE_COLLE, document.getIdToken());
detail.getAttributes().put(BACK_TRACE,"01");
detail.getDirectives().add(render);
......
......@@ -513,6 +513,7 @@ public class DplbotServiceUtil {
return null;
}
pageNum = bound/CO_HI_PAGE_SIZE + (bound%CO_HI_PAGE_SIZE == 0 ? 0 : 1);
log.info("collect/history: pagesize:{},bound{}",pageNum,bound);
TreeMap<Long, String> order = new TreeMap<>((o1, o2) -> (o1 < o2) ? 1 : ((o1.equals(o2)) ? 0 : -1));
for (Map.Entry<String, Long> entry: behaviorData.getUserBotId2Collected().entrySet()) {
order.put(entry.getValue(), entry.getKey());
......@@ -525,6 +526,7 @@ public class DplbotServiceUtil {
}
}
}
log.info("favoriteProducts length:{}, start:{}", favoriteProducts.size(), start);
if (favoriteProducts.size() == 0) return null;
ArrayList<HistoryData> projectInfoList = new ArrayList<>();
int i = 1;
......
......@@ -39,23 +39,24 @@ import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.ASIDE_IMG_URL;
@Slf4j
@Component
public class ScheduleService implements InitializingBean {
static int allProductCount;
static volatile List<GameProjectTb> RANKING_LIST = new ArrayList<>();
static volatile List<GameProjectTb> RECOMMEND_LIST = new ArrayList<>();
static volatile List<OnProductDetail> ALL_ON_PRODUCT = new ArrayList<>();
private static int allProductCount;
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 final HashMap<String, Map<String,String>> ASIDE_IMG = new HashMap<>();
private static final HashMap<String, Map<String,String>> ASIDE_IMG = new HashMap<>();
static final HashMap<String, String> NX2_BOT_TO_HZ1 = new HashMap<>();
static final HashMap<String, String> HZ1_BOT_TO_NX2 = new HashMap<>();
static final List<String> EXCEPT_BOT_ACCOUNT = new ArrayList<>();
private static final HashMap<String, String> NX2_BOT_TO_HZ1 = new HashMap<>();
private static final HashMap<String, String> HZ1_BOT_TO_NX2 = new HashMap<>();
private static final List<String> EXCEPT_BOT_ACCOUNT = new ArrayList<>();
static final String[] CATEGORY = {"古风", "儿童", "科幻", "占星", "恋爱", "灾难", "架空", "经营", "冒险", "武侠"};
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 static final HashMap<String,List<String>> CATEGORY_PRODUCT_ID_LIST = new HashMap<>();
private final GameProjectTbRepository gameProjectTbRepository;
......@@ -128,7 +129,7 @@ public class ScheduleService implements InitializingBean {
@Scheduled(cron = "0 0 19 * * ?")
public void initRankingList() {
new Thread(() -> {
RANKING_LIST = gameProjectTbRepository.findFirst10ByApplyStatusOrderByWatchDesc(1);
RANKING_LIST = gameProjectTbRepository.findFirst8ByApplyStatusOrderByWatchDesc(1);
LunchUtils.setLunchDocument(LunchUtils.buildLunchDocument());
//log.info("排行榜:{}", RANKING_LIST);
}).start();
......@@ -150,6 +151,7 @@ public class ScheduleService implements InitializingBean {
new Thread(() -> {
ALL_ON_PRODUCT = allOnProductInfoRepository.findAllByApplyStatus(1);
allProductCount = ALL_ON_PRODUCT.size();
TreeMap<Long, OnProductDetail> rankOrder = new TreeMap<>((o1, o2) -> o1-o2 < 0 ? 1 :(o1.equals(o2) ? 0 : -1));
for (OnProductDetail item : ALL_ON_PRODUCT) {
String productName = item.getName();
String botAccount = item.getBotAccount();
......@@ -158,7 +160,9 @@ public class ScheduleService implements InitializingBean {
item.setLabels(labels);
PRODUCT_NAME_DETAIL.put(productName, item);
PRODUCT_ID_DETAIL.put(botAccount, item);
rankOrder.put(item.getWatch(), item);
}
RANK_ORDER_IDs.addAll(rankOrder.values());
//log.info("作品详细信息:{}", PRODUCT_NAME_DETAIL);
}).start();
//log.error("更新推荐页出错:{}", e.getMessage());
......@@ -297,6 +301,10 @@ public class ScheduleService implements InitializingBean {
EXCEPT_BOT_ACCOUNT.add("6823941516");
}
public static List<OnProductDetail> getRANK_ORDER_IDs() {
return RANK_ORDER_IDs;
}
public static HashMap<String, OnProductDetail> getProductIdDetail() {
return PRODUCT_ID_DETAIL;
}
......
......@@ -15,6 +15,7 @@
"src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/Loading.png",
"height": "100%",
"width": "100%",
"scale-type": "fitXY",
"onLoaded": [
{
"type": "SendEvent",
......
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