From 7cd517d5f46b3fb5c05ce898b48c98e7ff4fc283 Mon Sep 17 00:00:00 2001 From: 苗权威 <1160292058@qq.com> Date: Sun, 2 Feb 2020 11:34:15 +0800 Subject: [PATCH] 2.2 --- .idea/compiler.xml | 2 +- .idea/workspace.xml | 793 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java | 1 + tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java | 56 +++++++++++++++++++++++++++++++++++++++++++------------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java | 6 +++--- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java | 8 ++++---- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java | 33 +++++++++++++++++---------------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java | 8 -------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java | 4 ++-- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------ xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java | 37 +++++++++++++++++++++---------------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java | 2 +- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleServiceNew.java | 46 ++++++++++++++++++++++++++++++++++++++++------ xiaoduhome/src/main/resources/static/headersimg.png | Bin 0 -> 8477 bytes xiaoduhome/src/main/resources/templates/Login_old.html | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ xiaoduhome/src/main/resources/templates/Oauth2_load.html | 245 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------- 17 files changed, 823 insertions(+), 745 deletions(-) create mode 100644 xiaoduhome/src/main/resources/static/headersimg.png create mode 100755 xiaoduhome/src/main/resources/templates/Login_old.html mode change 100755 => 100644 xiaoduhome/src/main/resources/templates/Oauth2_load.html diff --git a/.idea/compiler.xml b/.idea/compiler.xml index 8982f58..3cb42ad 100755 --- a/.idea/compiler.xml +++ b/.idea/compiler.xml @@ -33,7 +33,7 @@ - + diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 3a81d04..0f412df 100755 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -10,15 +10,21 @@ + + + - + - + + + + @@ -64,13 +70,10 @@ - - + + - - - @@ -79,8 +82,8 @@ - - + + @@ -89,10 +92,40 @@ - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -100,8 +133,8 @@ - - + + @@ -110,19 +143,19 @@ - + - - + + - + - - + + @@ -142,36 +175,36 @@ - StringRedisTemplate - HttpServletRequest - IOException - userId - customUserId - onIn - stringRedisTemplate.opsForValue() - onIN - dealDefaultIntent - path - Sche - imgUrl - buildLogoImage - onIne - buildProductInfoFooter - onI - UserBehaviorData - DplbotServiceUtil.getUserIdByToken - curTime - list - Constants.IMG_PREFIX - response - Schedult - ScheduleService - dealCollectHistoryJump - load - recommend + LUNCH_LIST_CATEGORY_CON + 45 + 45dp + onDefault + onDefaultEvent + Frame + SendPart + onDefaultEven + (BaseBot + NextRequiredEvent + RenderDocument + LunchDocument + LunchUtils.getLunchDocument() + LunchUtils + CATEGORY_CHARAC + CATEGORY category - dealOpenNumInCategory - getCategory + PushStack + buildBeforePayPojo + xiaodu_no_screen + ScheduleService + setDevice + createTimestamp + jiaoyouChannel2Bots + DplbotServiceUtil.onLunchFillUserBehaviorData + DplbotServiceUtil.onLunchFillUserBehaviorDataInMaster + onLunchFillUserBehaviorDataInMaster + data.setUserBotId2Flowers() + sendCancellToTerminate + allProjects OPENID_CACHE @@ -191,26 +224,15 @@ @@ -256,27 +289,17 @@ - - - - - - - - - - - + - @@ -486,7 +336,7 @@ - + @@ -498,6 +348,13 @@ + + + + + + + @@ -505,13 +362,6 @@ - - - - - - - @@ -519,12 +369,12 @@ - - - - + + - + + + @@ -539,9 +389,9 @@ - - - @@ -1135,7 +987,7 @@ - @@ -1147,8 +999,7 @@ - - + @@ -1157,11 +1008,11 @@ - - + + - + @@ -1178,7 +1029,7 @@ - + @@ -1198,413 +1049,345 @@ - + - - + + - + - - + + - + - - - - - + + - + - - - - - + + - + - - + + - + - - - - + - + - - + + + + + + + - + - - + + - + + - - - - - + + - + - - + + - + - - + + - + + - - + + - + - - - - + + + + - - - + - + - - - + - + - - - - - - - + - + - - - + - + - - - + - + - - - + - + - - - + - + - - - - - - + - + - - - - - - + - + - - + + - + - - + + - + + - - + + - + - - + + - + - - + + - + - - + + - + + - + - - - - - - - - - + + - + - - + + - + + - + - + - - - - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - + - - + + + + + - - + + - + - - - - - + + - + - - + + - + - - + + - + - - - - - - - - + + + + + + + + + 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 fc0d96d..03eb7ef 100755 --- 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 @@ -1324,6 +1324,7 @@ public class TTService { } if ((res == null || res.getCode() != 200) && !"mp3".equals(data.getFormat())) { + log.warn("requestTemplate:列户小雅兜底调用"); res = dealThirdParty(data.getText(), "Liehu1", filePath); } return res; 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 c28e5e4..298b175 100755 --- 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 @@ -1,5 +1,6 @@ package ai.qiwu.com.tts_service.service; +import ai.qiwu.com.tts_service.common.OkHttp3Utils; import ai.qiwu.com.tts_service.common.TTSUtils; import ai.qiwu.com.tts_service.common.sound.SampleRateConverter; import ai.qiwu.com.tts_service.pojo.TtsLsAudio; @@ -7,10 +8,14 @@ import ai.qiwu.com.tts_service.pojo.TtsLsResponse; import ai.qiwu.com.tts_service.pojo.TtsLsType; import ai.qiwu.com.tts_service.pojo.upload.UploadOneSenData; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.csvreader.CsvReader; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.springframework.util.CollectionUtils; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -317,6 +322,17 @@ public class Test { return num; } + private static void testLoad(String accessToken){ + try { + HashMap headers = new HashMap<>(); + headers.put("App-Channel-Id", "JIAOYOUTIANXIA"); + headers.put("Authorization", new StringBuilder("Bearer ").append(accessToken).toString()); + String str = OkHttp3Utils.doGet("https://account-center-test.chewrobot.com/api/sdk/user/info", new HashMap<>(), headers); + log.info("getUserIdByToken:{}",str); + } catch (Exception e) { + log.error("获取郊游天下用户id出错:{}", ExceptionUtils.getStackTrace(e)); + } + } public static void main(String[] args) { Date date = new Date(1572522571234L); @@ -325,17 +341,31 @@ public class Test { System.out.println(TTSUtils.buildMP3Filename("\uD83C\uDD70会数学的杰瑞的类型为:儿童、简单、益智、休闲、教育、学生、免费\uD83C\uDD71")); System.out.println(TTSUtils.buildMP3Filename("会数学的杰瑞的类型为:儿童、简单、益智、休闲、教育、学生、免费")); - Pattern pattern = Pattern.compile(TTSUtils.getAbRegex()); - String[] notVariableTextArray = pattern.split("\uD83C\uDD70会数学的杰瑞的类型为:儿童、简单、益智、休闲、教育、学生、免费\uD83C\uDD71"); - - System.out.println(extractNum("27")); - System.out.println(extractNum("二十六")); - System.out.println(extractNum("十六")); - System.out.println(extractNum("六")); - System.out.println(extractNum("第五个")); - System.out.println(extractNum("第十五个")); - System.out.println(extractNum("第二十六个")); - System.out.println(extractNum("第7个")); - System.out.println(extractNum("第17个")); + String sss = "{\n" + + " \"code\": 1,\n" + + " \"msg\": \"成功\",\n" + + " \"data\": {\n" + + " \"flowers\": {\n" + + " \"8343905461\": 1\n" + + " },\n" + + " \"history\": {\n" + + " \"8343905461\": 1579586903000,\n" + + " \"330440914\": 1579586286000,\n" + + " \"652820709\": 1579410432000,\n" + + " \"927936967\": 1579585808000,\n" + + " \"534996073\": 1579524295000,\n" + + " \"225446543\": 1579501308000,\n" + + " \"522878748\": 1579504437000,\n" + + " \"920289968\": 1579499810000\n" + + " },\n" + + " \"favorite\": {}\n" + + " }\n" + + "}"; + JSONObject result = JSON.parseObject(sss); + if (NumberUtils.INTEGER_ONE.equals(result.getInteger("code"))) { + result = result.getJSONObject("data"); + Map botAccount2FavoriteTime = JSON.parseObject(result.getJSONObject("flowers").toJSONString(), new TypeReference>(){}); + log.info(botAccount2FavoriteTime.get("8343905461").getClass().getName()); + } } -} +} \ No newline at end of file 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 36671bc..111dddd 100755 --- 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 @@ -271,13 +271,13 @@ public class TempleUtils { public static List buildCategoryDataList(int row) { ArrayList dataList = new ArrayList<>(); - int begin = row*3; + int begin = row*4; String name, imgId, imgSrc; - for (int i = begin; i < begin+3; i++) { + for (int i = begin; i < begin+4; i++) { name = ScheduleServiceNew.CATEGORY[i]; imgSrc = new StringBuilder(IMG_CUSTOM_PREFIX) .append(ScheduleServiceNew.CATEGORY_CHARAC[i]).append(".png").toString(); - imgId = ScheduleServiceNew.CATEGORY_CHARAC[i]; + imgId = Constants.DPL_COMPONENT_ID.PRE_CATEGORY +ScheduleServiceNew.CATEGORY[i]; LunchBotData data = new LunchBotData(imgSrc, imgId, name); data.setNum(i+1); 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 add843e..d7e31c7 100755 --- 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 @@ -2,6 +2,7 @@ package ai.qiwu.com.xiaoduhome.common.temple.onLunch; import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils; import ai.qiwu.com.xiaoduhome.common.temple.productInfo.ProductInfoPojo; +import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData; import ai.qiwu.com.xiaoduhome.pojo.dpl.Event; import ai.qiwu.com.xiaoduhome.service.ScheduleService; import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew; @@ -25,33 +26,52 @@ public class LunchUtils { // private static final LunchPojo LUNCH_LOGO_IMG = buildLogoImage(); // private static final LunchPojo LUNCH_HSITORY_IMG = buildHistoryImg(); // private static final LunchPojo LUNCH_COLLECT_IMG = buildCollectImg(); - private volatile static LunchDocument lunchDocument = buildLunchNewDocument(); + private volatile static LunchDocument lunchDocument = buildLunchNewDocument(0); + private volatile static LunchDocument lunchDocument_part = buildLunchNewDocument(1); + private volatile static LunchDocument categoryDocument = buildCategoryDocument(); - private static LunchDocument buildLunchNewDocument() { + private static LunchDocument buildLunchNewDocument(int part) { LunchDocument document = new LunchDocument(); document.setDuration(240000); LunchMainTemplate mainTemplate = new LunchMainTemplate(); document.setMainTemplate(mainTemplate); - int size = ScheduleServiceNew.allProjects.size(); + List dataList = ScheduleServiceNew.getTheChannelAllProjectData("baidu-screen-jiaoyou-audio-test"); + int size = dataList.size(); int rows = size/4 + (size%4 == 0?0:1); - int i = 0; + int i, bound; + boolean all; + if ((all = part == 0)) { + i = 0; + bound = rows; + } else { + i = 0; + bound = 1; + } List list = new ArrayList<>(); LunchPojo rowCon; int begin, end; - while (i < rows) { + while (i < bound) { begin = i*4; end = begin+4 > size ? size : begin+4; - rowCon = buildLunchList(TempleUtils.buildDataList(ScheduleServiceNew.allProjects.subList(begin, end),begin+1)); + rowCon = buildLunchList(TempleUtils.buildDataList(dataList.subList(begin, end),begin+1)); list.add(rowCon); i++; } - LunchPojo scroll = buildLunchScroll(); - scroll.setItems(list); + LunchPojo scroll; + if (all) { + scroll = buildLunchScroll(); + scroll.setItems(list); + mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll,FOOTER)); + } else { + scroll = buildLunchPartContainer(); + scroll.setItems(list); + mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll)); + } // mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,LUNCH_LOGO_IMG,LUNCH_HSITORY_IMG,LUNCH_COLLECT_IMG,scroll)); - mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll,FOOTER)); +// mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll,FOOTER)); return document; } @@ -78,7 +98,7 @@ public class LunchUtils { return document; } - public static LunchDocument buildCategoryDocument() { + private static LunchDocument buildCategoryDocument() { LunchDocument document = new LunchDocument(); document.setDuration(90000); LunchMainTemplate mainTemplate = new LunchMainTemplate(); @@ -87,6 +107,7 @@ public class LunchUtils { LunchPojo firstRow = buildLunchCategoryList(TempleUtils.buildCategoryDataList(0)); LunchPojo secondRow = buildLunchCategoryList(TempleUtils.buildCategoryDataList(1)); LunchPojo scroll = buildLunchScroll(); + scroll.setMarginTop("240dp"); scroll.setItems(Arrays.asList(firstRow,secondRow)); mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll,CATEGORY_FOOTER)); @@ -104,18 +125,27 @@ public class LunchUtils { return scroll; } + private static LunchPojo buildLunchPartContainer() { + LunchPojo container = new LunchPojo(); + container.setType("Container"); + container.setMarginTop("180dp"); + container.setWidth("100%"); +// scroll.setMarginBottom("10dp"); + return container; + } + private static LunchPojo buildLunchCategoryList(List data) { LunchPojo container = new LunchPojo(); //container.setMarginTop("25dp"); container.setType("Container"); container.setWidth("100%"); - container.setMarginTop("180dp"); - container.setAlignItems("center"); + container.setMarginBottom("15dp"); +// container.setAlignItems("center"); LunchPojo list = new LunchPojo(); list.setType("List"); - list.setHeight("310dp"); - list.setMarginLeft("30dp"); + list.setHeight("280dp"); + list.setMarginLeft("44dp"); list.setDirection("horizontal"); list.setData(data); list.setItems(Collections.singletonList(LUNCH_LIST_CATEGORY_CON)); @@ -147,7 +177,12 @@ public class LunchUtils { private static LunchPojo buildCategoryList() { LunchPojo category = buildImgFrmTxtContainer(); - category.getItems().remove(2); + category.getItems().get(0).setWidth("170dp"); + category.getItems().get(0).setHeight("170dp"); + category.getItems().get(0).setMarginLeft("1dp"); + category.getItems().get(1).setMarginLeft("15dp"); + category.getItems().get(2).setMarginTop("148dp"); + category.getItems().get(2).setMarginLeft("61dp"); return category; } @@ -174,10 +209,10 @@ public class LunchUtils { //frame LunchPojo frame = new LunchPojo(); frame.setType("Frame"); - frame.setWidth("45dp"); - frame.setHeight("45dp"); + frame.setWidth("35dp"); + frame.setHeight("35dp"); frame.setBackgroundColor("rgb(30,144,255)"); - frame.setBorderRadius("25dp"); + frame.setBorderRadius("20dp"); LunchPojo frmCon = new LunchPojo(); frmCon.setType("Container"); @@ -197,8 +232,8 @@ public class LunchUtils { //text LunchPojo text = new LunchPojo(); text.setType("Text"); - text.setFontSize("28dp"); - text.setMarginTop("188dp"); + text.setFontSize("24dp"); + text.setMarginTop("178dp"); text.setMarginLeft("7dp"); text.setText("${data.imageName}"); @@ -252,7 +287,7 @@ public class LunchUtils { LunchPojo footer = new LunchPojo(); footer.setType("Footer"); - footer.setHints(Arrays.asList("推荐作品","打开第一个","打开排行榜","打开历史记录","打开收藏")); + footer.setHints(Arrays.asList("打开第一个","打开排行榜","打开历史记录","打开分类","打开收藏","推荐作品")); footerCon.setItems(Collections.singletonList(footer)); @@ -323,6 +358,10 @@ public class LunchUtils { return logo; } + public static LunchDocument getLunchDocument_part() { + return lunchDocument_part; + } + public static LunchDocument getLunchDocument() { return lunchDocument; } @@ -330,4 +369,12 @@ public class LunchUtils { public static void setLunchDocument(LunchDocument lunchDocument) { LunchUtils.lunchDocument = lunchDocument; } + + public static LunchDocument getCategoryDocument() { + return categoryDocument; + } + + public static void setCategoryDocument(LunchDocument categoryDocument) { + LunchUtils.categoryDocument = categoryDocument; + } } 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 ec871ad..67eabfe 100755 --- 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 @@ -17,7 +17,7 @@ public class PlayUtils { private static final PlayPojo PLAY_HINT = buildHints(); private static final PlayPojo PLAY_BACK_IMG = buildLunchBackgroundImg(); private static final PlayPojo PLAY_FLOWER = buildFlower(); - private static final PlayPojo PLAY_LOGO = buildLogoImage(); +// private static final PlayPojo PLAY_LOGO = buildLogoImage(); private static final PlayPojo PLAY_COLLECT = buildCollect(); // private static final PlayPojo PLAY_UN_COLLECT = buildUnCollect(); @@ -37,7 +37,7 @@ public class PlayUtils { dataList.add(data); } - mainTemplate.setItems(Arrays.asList(PLAY_BACK_IMG, buildLunchHead(correctName(headerName)), PLAY_LOGO, + mainTemplate.setItems(Arrays.asList(PLAY_BACK_IMG, buildLunchHead(correctName(headerName)), buildConList(audio, dataList), PLAY_COLLECT, PLAY_FLOWER, PLAY_HINT)); return document; } @@ -151,7 +151,7 @@ public class PlayUtils { document.setMainTemplate(mainTemplate); PlayPojo collectComponent = PLAY_COLLECT; //if (!collected) collectComponent = PLAY_UN_COLLECT; - mainTemplate.setItems(Arrays.asList(PLAY_BACK_IMG, buildLunchHead(headerName), PLAY_LOGO, + mainTemplate.setItems(Arrays.asList(PLAY_BACK_IMG, buildLunchHead(headerName), buildAside(aside), buildAsideImage(asideImg), buildWholeContainer(audio, text) ,collectComponent, PLAY_FLOWER, PLAY_HINT)); return document; @@ -448,7 +448,7 @@ public class PlayUtils { PlayPojo footer = new PlayPojo(); footer.setType("Footer"); - footer.setHints(Arrays.asList("我要送花", "收藏", "返回")); + footer.setHints(Arrays.asList("我要送花", "收藏", "退出作品")); footerCon.setItems(Collections.singletonList(footer)); 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 e7e6079..5eae606 100755 --- 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 @@ -203,7 +203,7 @@ public class RecommendUtil { begin = end; } mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,RANK_HEAD,scrollView, - buildPageButton(num+1, list.size()/12 + list.size()%12==0?0:1),RANK_CATEGORY_FOOTER)); + buildPageButton(num+1, list.size()/RE_RA_CA_PAGE_SIZE + list.size()%RE_RA_CA_PAGE_SIZE==0?0:1),RANK_CATEGORY_FOOTER)); botIds.deleteCharAt(botIds.length()-1); String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes()); @@ -286,10 +286,10 @@ public class RecommendUtil { //frame RecommandPojo frame = new RecommandPojo(); frame.setType("Frame"); - frame.setWidth("45dp"); - frame.setHeight("45dp"); + frame.setWidth("35dp"); + frame.setHeight("35dp"); frame.setBackgroundColor("rgb(30,144,255)"); - frame.setBorderRadius("25dp"); + frame.setBorderRadius("20dp"); RecommandPojo frmCon = new RecommandPojo(); frmCon.setType("Container"); @@ -301,7 +301,7 @@ public class RecommendUtil { RecommandPojo frmText = new RecommandPojo(); frmText.setType("Text"); frmText.setText("${data.num}"); - frmText.setFontSize("25dp"); + frmText.setFontSize("22dp"); frmCon.setItems(Collections.singletonList(frmText)); frame.setItems(Collections.singletonList(frmCon)); @@ -379,10 +379,10 @@ public class RecommendUtil { //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"); + frame.setWidth("35dp"); + frame.setHeight("35dp"); + frame.setBackgroundColor("rgb(30,144,255)"); + frame.setBorderRadius("20dp"); RecommandPojo frmCon = new RecommandPojo(); frmCon.setType("Container"); @@ -393,7 +393,7 @@ public class RecommendUtil { RecommandPojo frmText = new RecommandPojo(); frmText.setType("Text"); frmText.setText("4"); - frmText.setFontSize("28dp"); + frmText.setFontSize("22dp"); frmCon.setItems(Collections.singletonList(frmText)); frame.setItems(Collections.singletonList(frmCon)); @@ -444,6 +444,7 @@ public class RecommendUtil { private static List getListData(int row,int begin, int end, List bots, StringBuilder botIds) { List data = new ArrayList<>(); int n = 1+row*4; + end = end > bots.size() ? bots.size() : end; for (int i = begin; i < end; i++) { ProjectData bot = bots.get(i); botIds.append(bot.getBotAccount()).append(File.separator); @@ -461,7 +462,7 @@ public class RecommendUtil { for (int i = begin; i < end; i++) { ProjectData bot = bots.get(i); String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString(); - RecommandBotInfo detail = new RecommandBotInfo(bot.getBannerImgUrl(),imageId, TempleUtils.correctName(bot.getName())); + RecommandBotInfo detail = new RecommandBotInfo(bot.getBannerImgUrl(),imageId, bot.getName()); detail.setNum(i-begin+n); data.add(detail); } @@ -504,10 +505,10 @@ public class RecommendUtil { //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"); + frame.setWidth("35dp"); + frame.setHeight("35dp"); + frame.setBackgroundColor("rgb(30,144,255)"); + frame.setBorderRadius("20dp"); RecommandPojo frmCon = new RecommandPojo(); frmCon.setType("Container"); @@ -518,7 +519,7 @@ public class RecommendUtil { RecommandPojo frmText = new RecommandPojo(); frmText.setType("Text"); frmText.setText("${data.num}"); - frmText.setFontSize("28dp"); + frmText.setFontSize("22dp"); frmCon.setItems(Collections.singletonList(frmText)); frame.setItems(Collections.singletonList(frmCon)); diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java index 4d720ca..9851bda 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java @@ -1,27 +1,19 @@ package ai.qiwu.com.xiaoduhome.pojo; -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.csvreader.CsvReader; import com.csvreader.CsvWriter; -import com.eclipsesource.json.JsonObject; import lombok.*; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVPrinter; import org.apache.commons.csv.CSVRecord; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.exception.ExceptionUtils; import org.springframework.util.DigestUtils; import java.io.*; -import java.net.URLDecoder; import java.nio.ByteBuffer; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; -import java.nio.file.Files; -import java.sql.Timestamp; -import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java index 9329338..a590060 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java @@ -28,8 +28,8 @@ public interface XiaoDuOrderTbRepository extends JpaRepository botList = jiaoyouChannel2Bots.get("jiaoyou-audio-adult-test"); + List botList = ScheduleServiceNew.jiaoyouChannel2Bots.get("jiaoyou-audio-adult-test"); String name = botList.get(Integer.parseInt(num)%botList.size()); welcomeWord = String.format(welcomeWord, name,name); } catch (Exception e) { @@ -188,9 +186,9 @@ public class DplBotServiceBoth extends BaseBot { if (accessToken == null) { DplbotServiceUtil.onLunchFillUserBehaviorData(userId, channel, null); } else { - userId=DplbotServiceUtil.getUserIdByToken(accessToken, channel); - if (StringUtils.isNotBlank(userId)) { - DplbotServiceUtil.onLunchFillUserBehaviorData(userId, channel, userId); + String jytUserId = DplbotServiceUtil.getUserIdByToken(accessToken, channel); + if (StringUtils.isNotBlank(jytUserId)) { + DplbotServiceUtil.onLunchFillUserBehaviorData(userId, channel, jytUserId); } } } else if (accessToken != null && data.getJytUserId() == null){ @@ -719,8 +717,9 @@ public class DplBotServiceBoth extends BaseBot { } } else if ("loadingPage".equals(componentId)) { RenderDocument renderDocument = new RenderDocument(LunchUtils.getLunchDocument()); - this.addDirective(new PushStack()); - this.addDirective(renderDocument); +// this.addDirective(new PushStack()); + addDirective(renderDocument); +// addDirective(new SendPart("lunch")); return new Response(); } else if (PRE_COLLE.equals(componentPrefix)) { boolean isUnCollect = "Un".equals(componentId.substring(5,7)); @@ -742,7 +741,7 @@ public class DplBotServiceBoth extends BaseBot { RenderDocument render = new RenderDocument(document); this.addDirective(render); this.setSessionAttribute("category",category); - this.setSessionAttribute("trace","05"); + this.setSessionAttribute("trace","75"); } else if ("playButton".equals(componentId)) { return buildErrorResponse("您可以直接对我说我要送花或者我要收藏或取消收藏"); } else if ("lunchCollect".equals(componentId)) { @@ -823,13 +822,13 @@ public class DplBotServiceBoth extends BaseBot { return new Response(outputSpeech); } - private Response dealOpenCategory() { - LunchDocument document = LunchUtils.buildCategoryDocument(); + private Response dealOpenCategory(String word) { + LunchDocument document = LunchUtils.getCategoryDocument(); if (document == null) return new Response(); RenderDocument render = new RenderDocument(document); this.addDirective(render); this.setSessionAttribute("trace","07"); - return buildErrorResponse("正在为您打开分类页"); + return buildErrorResponse(word); } private Response dealOpenCollectClick() { @@ -992,13 +991,6 @@ public class DplBotServiceBoth extends BaseBot { return buildErrorResponse("您已登录成功"); } -// @Override -// protected Response onDefaultEvent() { -// log.info("未拦截的事件类型:"+getEventType(this.getStrRequest())); -// this.waitAnswer(); -// return new Response(); -// } - private String getEventType(String requestStr) { int typeIndex = requestStr.lastIndexOf("type"); int comma = requestStr.indexOf(',', typeIndex); @@ -1596,8 +1588,8 @@ public class DplBotServiceBoth extends BaseBot { case '3': case '4': case '6': response = dealOpenNumInRecommend(getSessionAttribute(PRE_COLLE), num, channelId); break; - case '5': response = dealOpenNumInCategory(channelId);break; - case '7': response = dealOpenNumInCategory(channelId);break; + case '5': response = dealOpenNumInCategoryBots(channelId, num);break; + case '7': response = dealOpenNumCategory(num);break; default:{ response = buildErrorResponse("屏幕上的图标都是可以点击的哦"); } @@ -1653,22 +1645,33 @@ public class DplBotServiceBoth extends BaseBot { private Response dealBackIntent(String userId, String channelId) { String trace = getSessionAttribute(BACK_TRACE); char second; - if (trace == null || trace.length() <= 2 || getQuery().contains("首")) { + if (trace == null || getQuery().contains("首")) { // home page backToHome(); - if (trace != null && StringUtils.endsWith(trace,File.separator)) sendCancellToTerminate(userId); - } else if (StringUtils.endsWith(trace,File.separator)){ + if (StringUtils.endsWith(trace,File.separator)) sendCancellToTerminate(userId); + return buildErrorResponse("已为您返回到首页"); + } + else if (trace.length() <= 2) { + if (trace.charAt(1) == '5') { + return dealOpenCategory("已为您返回到分类页"); + } else { + backToHome(); + return buildErrorResponse("已为您返回到首页"); + } + } + else if (StringUtils.endsWith(trace,File.separator)){ String botAccount = trace.substring(2, trace.length()-1); log.info("返回作品的id:{}", botAccount); backToBotIntro(botAccount, channelId); sendCancellToTerminate(userId); + return buildErrorResponse("已为您返回到作品介绍页"); } else { second = trace.charAt(1); switch (second){ // home page case '0':{ backToHome(); - break; + return buildErrorResponse("已为您返回到首页"); } case '1': { //collect @@ -1720,8 +1723,9 @@ public class DplBotServiceBoth extends BaseBot { RecommandDocument recommandDocument = RecommendUtil.getRecommendDocument(count-1, channelId); if (recommandDocument == null) { RenderDocument render = new RenderDocument(); - render.setDocument(LunchUtils.getLunchDocument()); + render.setDocument(LunchUtils.getLunchDocument_part()); addDirective(render); + addDirective(new SendPart("lunch")); setSessionAttribute(BACK_TRACE, null); break; } @@ -1742,8 +1746,9 @@ public class DplBotServiceBoth extends BaseBot { else recommandDocument = RecommendUtil.getRankOtherPageDocument(count-1, channelId); if (recommandDocument == null) { RenderDocument render = new RenderDocument(); - render.setDocument(LunchUtils.getLunchDocument()); + render.setDocument(LunchUtils.getLunchDocument_part()); addDirective(render); + addDirective(new SendPart("lunch")); setSessionAttribute(BACK_TRACE, null); break; } @@ -1775,8 +1780,9 @@ public class DplBotServiceBoth extends BaseBot { } private void backToHome() { - RenderDocument renderDocument = new RenderDocument(LunchUtils.getLunchDocument()); + RenderDocument renderDocument = new RenderDocument(LunchUtils.getLunchDocument_part()); addDirective(renderDocument); + addDirective(new SendPart("lunch")); setSessionAttribute(BACK_TRACE,null); } @@ -1876,12 +1882,12 @@ public class DplBotServiceBoth extends BaseBot { case "load" : return load(); case "start" : return dealStartIntent(userId, intentRequest, channelId); case "openRank" : return dealRankIntent(channelId); - case "openNum" : return dealOpenNumIntent(txt.substring(end+1), channelId); - case "jump" : return dealJumpIntent(userId, txt.substring(end+1), channelId); + case "openNum" : return dealOpenNumIntent(end+1 == txt.length() ? "1" : txt.substring(end+1), channelId); + case "jump" : return dealJumpIntent(userId, end+1 == txt.length() ? "1" : txt.substring(end+1), channelId); case "store" : return dealCollectOrUnCollectIntent(userId, "collect"); case "unStore" : return dealCollectOrUnCollectIntent(userId, "unCollect"); - case "flower" : return dealSendFlowerIntent(userId, txt.substring(end+1)); - case "category" : return dealOpenCategory(); + case "flower" : return dealSendFlowerIntent(userId, end+1 == txt.length() ? "1" : txt.substring(end+1)); + case "category" : return dealOpenCategory("正在为您打开分类页"); } } } @@ -1890,6 +1896,9 @@ public class DplBotServiceBoth extends BaseBot { log.error("推荐bot退出解析出错:"+e); return new Response(); } + if ("exit".equalsIgnoreCase(object.getString("botStatus"))) { + return dealBackIntent(userId, channelId); + } // String aside = DplbotServiceUtil.getAsideText(text); // //log.info("旁白名字:{}",aside); @@ -1986,15 +1995,18 @@ public class DplBotServiceBoth extends BaseBot { } } - private Response dealOpenCategory(int num) { + private Response dealOpenNumCategory(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 + RecommandDocument document = RecommendUtil.getCategory(0, ScheduleServiceNew.CATEGORY[num-1]); + if (document == null) return new Response(); + RenderDocument render = new RenderDocument(document); + addDirective(render); + setSessionAttribute(BACK_TRACE, "75"); + setSessionAttribute("category", ScheduleServiceNew.CATEGORY[num-1]); + return new Response(); } - private Response dealOpenNumInCategory(String channelId, int num) { + private Response dealOpenNumInCategoryBots(String channelId, int num) { String count = getSessionAttribute("comCnt"); String category = getSessionAttribute("category"); if (StringUtils.isBlank(category)) return buildErrorResponse("请直接点击进入"); @@ -2011,12 +2023,14 @@ public class DplBotServiceBoth extends BaseBot { response = directInProduct(bot.getName(), bot.getBotAccount()); } else response = enterProductInfo(bot.getName(), channelId); setSessionAttribute("category", category); + setSessionAttribute("comCnt", count); return response; } private Response dealOpenNumInHome(int num) { - if (num <= ScheduleServiceNew.allProjects.size()) { - ProjectData bot = ScheduleServiceNew.allProjects.get(num-1); + List dataList = ScheduleServiceNew.getTheChannelAllProjectData(channel); + if (num <= dataList.size()) { + ProjectData bot = dataList.get(num-1); if (!DplbotServiceUtil.doesUserPlayed(bot.getBotAccount(), getUserId(), getAccessToken())) return enterProductInfo(bot.getName(), channel); else return directInProduct(bot.getName(), bot.getBotAccount()); } @@ -2210,7 +2224,7 @@ public class DplBotServiceBoth extends BaseBot { String str = "恭喜您支付成功,开始体验吧"; if (getRequest().getContext().getScreen() != null) { boolean response = DplbotServiceUtil.dealChargeCallback(chargeEvent, getUserId(), getAccessToken(), - getSessionAttribute("userId"), PRODUCT_ID_DETAIL.get(botAccount).getName(), "xiaodu_screen"); + getSessionAttribute("userId"), ScheduleServiceNew.getProjectByBotAccount(botAccount).getName(), channel); if (response) { Map flowerRecords = USER_HISTORY.get(getUserId()).getUserBotId2Flowers(); Long before = flowerRecords.get(botAccount); @@ -2220,7 +2234,7 @@ public class DplBotServiceBoth extends BaseBot { SetStateCommand stateCommand = new SetStateCommand(); stateCommand.setComponentId("pft"); stateCommand.setState("text"); - stateCommand.setValue(USER_SEND_FLOWER+before); + stateCommand.setValue(USER_SEND_FLOWER+(before+1)); executeCommands.addCommand(stateCommand); try { addDirective(executeCommands); @@ -2230,6 +2244,10 @@ public class DplBotServiceBoth extends BaseBot { } else { str = "很抱歉,您没有支付成功"; } + String trace = getSessionAttribute(BACK_TRACE); + if (trace.length()>2 && !StringUtils.endsWith(trace, File.separator)) { + backToBotIntro(trace.substring(2, trace.length()-1), channel); + } } else { String userId = customUserId(); String jytUserId = getSessionAttribute("userId"); @@ -2238,7 +2256,7 @@ public class DplBotServiceBoth extends BaseBot { jytUserId = "null"; } boolean response = DplbotServiceUtil.dealChargeCallback(chargeEvent, userId, getAccessToken(), - jytUserId, PRODUCT_ID_DETAIL.get(botAccount).getName(), "xiaodu_no_screen"); + jytUserId, ScheduleServiceNew.getProjectByBotAccount(botAccount).getName(), channel); if (!response) { str = "很抱歉,您没有支付成功"; } @@ -2281,8 +2299,20 @@ public class DplBotServiceBoth extends BaseBot { } @Override + protected Response onNextRequiredEvent(NextRequired nextRequired) { + switch (nextRequired.getToken()) { + case "lunch" : { + RenderDocument renderDocument = new RenderDocument(LunchUtils.getLunchDocument()); + addDirective(renderDocument); + } + } + return new Response(); + } + + @Override protected Response onDefaultEvent() { - if (getRequest().getRequest() instanceof AudioPlayerEvent) { + RequestBody requestBody = getRequest().getRequest(); + if (requestBody instanceof AudioPlayerEvent) { this.setExpectSpeech(true); return new Response(); } diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java index 9aa0a24..630e5f2 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java @@ -17,6 +17,7 @@ import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuOrderTbRepository; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.TypeReference; import com.baidu.dueros.data.request.pay.event.ChargeEvent; import com.baidu.dueros.data.request.pay.event.Payload; import com.baidu.dueros.data.response.directive.pay.Charge; @@ -42,7 +43,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import static ai.qiwu.com.xiaoduhome.common.Constants.CO_HI_PAGE_SIZE; -import static ai.qiwu.com.xiaoduhome.common.Constants.IMG_PREFIX; import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.*; import static ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew.curTime; @@ -106,7 +106,7 @@ public class DplbotServiceUtil { static String getUserIdByToken(String accessToken, String channelId) { try { HashMap headers = new HashMap<>(); -// headers.put("App-Channel-Id", channelId); + headers.put("App-Channel-Id", "JIAOYOUTIANXIA"); headers.put("Authorization", new StringBuilder(BEARER).append(accessToken).toString()); String str = OkHttp3Utils.doGet(USER_ID_BY_TOKEN, new HashMap<>(), headers); log.info("getUserIdByToken:{}",str); @@ -143,20 +143,22 @@ public class DplbotServiceUtil { Map params = new HashMap<>(); params.put("userId", URLEncoder.encode(userId, "UTF-8")); params.put("channelId", channelId); + params.put("jytUserId", jytUserId); String response = OkHttp3Utils.doGet(HOST_UTL+"/audio_box/behavior", params); if (StringUtils.isNotBlank(response)) { JSONObject result = JSON.parseObject(response); if (NumberUtils.INTEGER_ONE.equals(result.getInteger("code"))) { result = result.getJSONObject("data"); - Map botAccount2HistoryTime = result.getObject("history", Map.class); - Map botAccount2Flowers = result.getObject("flowers", Map.class); - Map botAccount2FavoriteTime = result.getObject("favorite", Map.class); + Map botAccount2HistoryTime = JSON.parseObject(result.getJSONObject("history").toJSONString(), new TypeReference>(){}); + Map botAccount2Flowers = JSON.parseObject(result.getJSONObject("flowers").toJSONString(), new TypeReference>(){}); + Map botAccount2FavoriteTime = JSON.parseObject(result.getJSONObject("favorite").toJSONString(), new TypeReference>(){}); UserBehaviorData data = new UserBehaviorData(); - if (!CollectionUtils.isEmpty(botAccount2HistoryTime)) data.setUserBotId2History(botAccount2HistoryTime); - if (!CollectionUtils.isEmpty(botAccount2FavoriteTime)) data.setUserBotId2Collected(botAccount2FavoriteTime); - if (!CollectionUtils.isEmpty(botAccount2Flowers)) data.setUserBotId2Flowers(botAccount2Flowers); + if (!CollectionUtils.isEmpty(botAccount2HistoryTime)) data.getUserBotId2History().putAll(botAccount2HistoryTime); + if (!CollectionUtils.isEmpty(botAccount2FavoriteTime)) data.getUserBotId2Collected().putAll(botAccount2FavoriteTime); + if (!CollectionUtils.isEmpty(botAccount2Flowers)) data.getUserBotId2Flowers().putAll(botAccount2Flowers); data.setJytUserId(jytUserId); data.setChannel(channelId); + log.info("UserBehaviorData:"+data); USER_HISTORY.put(userId, data); } } @@ -171,21 +173,23 @@ public class DplbotServiceUtil { Map params = new HashMap<>(); params.put("userId", userId); params.put("channelId", channelId); + params.put("jytUserId", jytUserId); try { String response = OkHttp3Utils.doGet(HOST_UTL+"/audio_box/behavior", params); if (StringUtils.isNotBlank(response)) { JSONObject result = JSON.parseObject(response); if (NumberUtils.INTEGER_ONE.equals(result.getInteger("code"))) { result = result.getJSONObject("data"); - Map botAccount2HistoryTime = result.getObject("history", Map.class); - Map botAccount2Flowers = result.getObject("flowers", Map.class); - Map botAccount2FavoriteTime = result.getObject("favorite", Map.class); + Map botAccount2HistoryTime = JSON.parseObject(result.getJSONObject("history").toJSONString(), new TypeReference>(){}); + Map botAccount2Flowers = JSON.parseObject(result.getJSONObject("flowers").toJSONString(), new TypeReference>(){}); + Map botAccount2FavoriteTime = JSON.parseObject(result.getJSONObject("favorite").toJSONString(), new TypeReference>(){}); UserBehaviorData data = new UserBehaviorData(); if (!CollectionUtils.isEmpty(botAccount2HistoryTime)) data.setUserBotId2History(botAccount2HistoryTime); if (!CollectionUtils.isEmpty(botAccount2FavoriteTime)) data.setUserBotId2Collected(botAccount2FavoriteTime); if (!CollectionUtils.isEmpty(botAccount2Flowers)) data.setUserBotId2Flowers(botAccount2Flowers); data.setJytUserId(jytUserId); data.setChannel(channelId); + log.info("UserBehaviorData:"+data); USER_HISTORY.put(userId, data); return data; } @@ -336,6 +340,7 @@ public class DplbotServiceUtil { xiaoDuOrderTB.setIsBuy(false); xiaoDuOrderTB.setStatus(false); xiaoDuOrderTB.setChOrderId(orderId); + xiaoDuOrderTB.setDevice(1); xiaoDuOrderTB.setTimeStamp(System.currentTimeMillis()); return xiaoDuOrderTB; } @@ -389,7 +394,7 @@ public class DplbotServiceUtil { // createTimestamp字段与baiduOrderReferenceId字段与之后百度方进行结算使用, // 现在createTimestamp由于百度方的bug需等到九月份才能获取到 final String baiduOrderReferenceId = payload.getBaiduOrderReferenceId(); - final String createTimestamp = ""; + final String createTimestamp = payload.getAuthorizationDetails().getCreationTimestamp(); final String num = token.substring(sepIndex+1); POOL.submit(() -> { XiaoDuOrderTbRepository repository = BaseHolder.getBean("xiaoDuOrderTbRepository"); @@ -397,7 +402,7 @@ public class DplbotServiceUtil { try { XiaoDuOrderTB tb = repository.getByChOrderId(chOrderId); id = tb.getId(); - repository.updateAterSeccessPayed(baiduOrderReferenceId,chOrderId); + repository.updateAterSeccessPayed(baiduOrderReferenceId,chOrderId, createTimestamp); } catch (Exception e) { // StringWriter writer = new StringWriter(); // e.printStackTrace(new PrintWriter(writer,true)); @@ -486,7 +491,7 @@ public class DplbotServiceUtil { log.info("favoriteProducts length:{}, start:{}", favoriteProducts.size(), start); if (favoriteProducts.size() == 0) return null; ArrayList projectInfoList = new ArrayList<>(); - int j = 1; + int j = start+1; //log.info("id list:{}", favoriteProducts); final StringBuilder build = new StringBuilder(); for (String botAccount :favoriteProducts) { @@ -543,7 +548,7 @@ public class DplbotServiceUtil { if (historyProducts.size() == 0) return null; ArrayList projectInfoList = new ArrayList<>(); - int i = 1; + int i = start+1; final StringBuilder build = new StringBuilder(); SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm"); historyProducts.sort((o1, o2) -> (o1.getLastTime() allProjects = new ArrayList<>(); + private static volatile List allProjects = new ArrayList<>(); private static volatile Map botAccount2Project = new HashMap<>(); private static volatile Map name2Project = new HashMap<>(); private static volatile Map> channel2BotAccountList = new HashMap<>(); @@ -37,11 +38,13 @@ public class ScheduleServiceNew implements InitializingBean { 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 final String[] CATEGORY = {"古风", "言情", "灾难", "冒险", "武侠", "穿越", "答题", "经营"}; + public static final String[] CATEGORY_CHARAC={"gufeng","yanqing","zainan","maoxian","wuxia", "chuanyue", "dati", "jingying"}; public static volatile Map> category2Bots = new HashMap<>(); + static volatile Map> jiaoyouChannel2Bots = new HashMap<>(); + @Override public void afterPropertiesSet() throws Exception { getAllProjects(); @@ -64,9 +67,9 @@ public class ScheduleServiceNew implements InitializingBean { botAcc.put(projectData.getBotAccount(), projectData); name.put(projectData.getName(), projectData); List bots; - for (int i = 0; i < CATEGORY.length; i++) { - if (projectData.getLabels().contains(CATEGORY[i])) { - bots = category2Bots.computeIfAbsent(CATEGORY_CHARAC[i], s -> new ArrayList<>()); + for (String s1 : CATEGORY) { + if (projectData.getLabels().contains(s1)) { + bots = category2Bots.computeIfAbsent(s1, s -> new ArrayList<>()); bots.add(projectData); } } @@ -117,6 +120,37 @@ public class ScheduleServiceNew implements InitializingBean { }); } + @Scheduled(cron = "0 */30 * * * ?") + public void getJiaoYouChannelRecordBots() { + String response; + JSONObject jsonObject; + int count = 1; + boolean success = false; + do { + try { + response = OkHttp3Utils.doGet("http://didi-gz5.jiaoyou365.com:18082/api/data/audio/list/jiaoyou"); + jsonObject = JSON.parseObject(response).getJSONObject("data"); + Map> map = jsonObject.toJavaObject(Map.class); + if (map != null && map.size() != 0) { + List jiaoyouList = map.get("jiaoyou-audio-adult-test"); + if (!CollectionUtils.isEmpty(jiaoyouList)) map.get("jiaoyou-audio-adult-test").add("遇见伽利略"); + List xiaoaiJiaoyouList = map.get("xiaoai-jiaoyou-audio-adult-test"); + if (!CollectionUtils.isEmpty(xiaoaiJiaoyouList)) map.get("xiaoai-jiaoyou-audio-adult-test").add("遇见伽利略"); + jiaoyouChannel2Bots = map; + success = true; + } else { + log.info("getChannelAllBots failed count="+count); + Thread.sleep(count*5); + } + } catch (Exception e) { + log.warn("getChannelAllBots: "+e); + } + count++; + } while (!success && count < 5); + log.info("getChannelAllBots:"+jiaoyouChannel2Bots); + } + + static ProjectData getProjectByName(String name) { return name2Project.get(name); } diff --git a/xiaoduhome/src/main/resources/static/headersimg.png b/xiaoduhome/src/main/resources/static/headersimg.png new file mode 100644 index 0000000..a7ae6b9 Binary files /dev/null and b/xiaoduhome/src/main/resources/static/headersimg.png differ diff --git a/xiaoduhome/src/main/resources/templates/Login_old.html b/xiaoduhome/src/main/resources/templates/Login_old.html new file mode 100755 index 0000000..c01d16d --- /dev/null +++ b/xiaoduhome/src/main/resources/templates/Login_old.html @@ -0,0 +1,112 @@ + + + + + 登录 + + + + +
+ +
+

获取验证码

+ + +
+
+

请输入验证码

+ + +
+
+ + \ No newline at end of file diff --git a/xiaoduhome/src/main/resources/templates/Oauth2_load.html b/xiaoduhome/src/main/resources/templates/Oauth2_load.html old mode 100755 new mode 100644 index c01d16d..1ae69d1 --- a/xiaoduhome/src/main/resources/templates/Oauth2_load.html +++ b/xiaoduhome/src/main/resources/templates/Oauth2_load.html @@ -1,112 +1,155 @@ - + + + 登录 - - -
+
+
+ +
+

欢迎来到晓悟

+
-
-

获取验证码

- - +
+
-
-

请输入验证码

- - +
+ +
+ +
- \ No newline at end of file + + + -- libgit2 0.27.1