From f5bb94869e19a2aae051ddb97b5c777b2970fd4a Mon Sep 17 00:00:00 2001 From: 苗权威 <1160292058@qq.com> Date: Sun, 19 Jan 2020 17:56:32 +0800 Subject: [PATCH] 2.19 --- .idea/workspace.xml | 656 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/XiaoduhomeApplication.java | 5 +++-- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Config.java | 8 +++++++- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java | 6 +++--- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java | 29 +++++++++++++++++++++++++++++ xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java | 8 ++++++-- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java | 2 +- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java | 3 +-- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchPojo.java | 5 +++++ xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++------------------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java | 7 ++++--- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java | 3 ++- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java | 41 ++++++++++++++++++++--------------------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java | 9 +++++---- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java | 2 ++ xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ProjectDataResult.java | 18 ++++++++++++++++++ xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ResultData.java | 21 +++++++++++++++++++++ xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/UpdateUserCollectData.java | 20 ++++++++++++++++++++ xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java | 69 +++++++++++++++++++++++++++------------------------------------------ xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java | 62 +------------------------------------------------------------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleServiceNew.java | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------- xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiTestService.java | 3 ++- xiaoduhome/src/main/resources/application.yml | 2 ++ xiaoduhome/src/main/resources/static/json/firstPage.json | 2 +- xiaoduhome/src/main/resources/xiaodu.properties | 3 ++- 26 files changed, 712 insertions(+), 574 deletions(-) create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ProjectDataResult.java create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ResultData.java create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/UpdateUserCollectData.java diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5259ab0..4485c42 100755 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -10,36 +10,28 @@ - - - - - + + + + + + + + - - - - - + - - - - - - - - - + + @@ -86,37 +78,32 @@ - - + + + - + - - - - - - - - + + - + - - + + @@ -125,10 +112,10 @@ - + - - + + @@ -137,44 +124,48 @@ - + - - + + - - + + + - + - - - - - + + - + - - + + - + - - + + + + + + + + @@ -194,36 +185,36 @@ - dealNextPageIntent - dealLastPageIntent - channelId - backToBotIntro - dealBackIntent - dealStartIntent - OnProductDetail - s1 - dealOpenNum - jytId - dealCollectHistoryJump - dealJumpIntent - userId - baidu-screen-jiaoyou-audio-test - null - DplbotServiceUtil.sendOneFlowerByCharge - PlayUtils.getPlayDocument - XIAOAI_MP3_MARK - RequestTerminal - DplbotServiceUtil.doesUserCollectThisBot - curTime - userU - dealCollectOrUnCollectIntent - jytUserId onInte - onIn requestTerminate - ScheduleService - Task lunchDocument + Task + 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 OPENID_CACHE @@ -243,19 +234,6 @@ @@ -311,15 +302,6 @@ - - - - - - - - - @@ -335,8 +317,8 @@ - @@ -492,7 +474,7 @@ - + @@ -500,9 +482,7 @@ - - - + @@ -511,6 +491,7 @@ + @@ -520,6 +501,7 @@ + @@ -547,7 +529,8 @@ - + + @@ -599,7 +582,7 @@ - + - - @@ -1185,7 +1168,7 @@ - + @@ -1195,7 +1178,7 @@ - @@ -1207,7 +1190,7 @@ - + @@ -1218,7 +1201,7 @@ - + @@ -1234,7 +1217,7 @@ - + @@ -1258,429 +1241,424 @@ - + - - + + + + + + + + + - + - - + + + + + + - + - - + + - + - - - - - + + - + - - + + - + - + - - + + + + + - + - - + + - + - - + + + + + - + - - + + - + - - + + - + - - + + + + + - + - - + + - + - - + + - + - - + + - - - - + - - + + - - - - - - - - - - - - - - - - + - - + + - + - - + + - + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - - - - + - + - - + + - + - - + + - + - - + + + + + - + - - + + - + - - - - - + + - + + + + + + + + - - - - + - + - - + + - + - - + + - + - - - - - + + - + - - + + - - + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + - + - - + + + + + + + + + - + - - + + - + - - + + - + + + + - + - - - - - - + + - + - - - - - + + - + - - + + - - + + - + - - + + + + + - + - - - - - - - - + + diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/XiaoduhomeApplication.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/XiaoduhomeApplication.java index edc2911..6ebce52 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/XiaoduhomeApplication.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/XiaoduhomeApplication.java @@ -2,9 +2,8 @@ package ai.qiwu.com.xiaoduhome; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.autoconfigure.domain.EntityScan; +import org.springframework.boot.context.ApplicationPidFileWriter; import org.springframework.data.jpa.repository.config.EnableJpaAuditing; -import org.springframework.data.jpa.repository.config.EnableJpaRepositories; import org.springframework.scheduling.annotation.EnableScheduling; @SpringBootApplication @@ -13,6 +12,8 @@ import org.springframework.scheduling.annotation.EnableScheduling; public class XiaoduhomeApplication { public static void main(String[] args) { + SpringApplication application = new SpringApplication(XiaoduhomeApplication.class); + application.addListeners(new ApplicationPidFileWriter()); SpringApplication.run(XiaoduhomeApplication.class, args); } diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Config.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Config.java index 6767a02..4cbfa40 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Config.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Config.java @@ -3,6 +3,8 @@ package ai.qiwu.com.xiaoduhome.common; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import java.io.File; +import java.io.FileInputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.Properties; @@ -19,7 +21,11 @@ public class Config { String filename = "xiaodu.properties"; properties = new Properties(); try { - properties.load(new InputStreamReader(Config.class.getClassLoader().getResourceAsStream(filename), StandardCharsets.UTF_8)); + String path = System.getProperty("java.class.path"); + path = path.substring(0, path.lastIndexOf(File.separator)+1) + filename; + log.warn("配置文件:{}",path); + properties.load(new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8)); +// properties.load(new InputStreamReader(Config.class.getClassLoader().getResourceAsStream(filename), StandardCharsets.UTF_8)); } catch (Exception e) { log.error("获取配置文件对象出错:{}", e.toString()); System.exit(1); diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java index 451e7fa..76cba36 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java @@ -62,7 +62,7 @@ public interface Constants { String COLLECTED_IMG_URL = "https://didi-gz5.jiaoyou365.com/duai/image/collec.png"; String UN_COLLECTED_IMG_URL = "https://didi-gz5.jiaoyou365.com/duai/image/uncollec.png"; - String DEFAULT_ASIDE_IMG_URL = "http://didi-gz4.jiaoyou365.com/Editor/upload/img/npc/2019/02/19174004213.png"; + String DEFAULT_ASIDE_IMG_URL = "http://didi-gz5.jiaoyou365.com/Editor/upload/img/npc/2019/02/19174004213.png"; } interface PRODUCT_INTRO { @@ -96,8 +96,8 @@ public interface Constants { } interface SKILL_SECURITY { - String REDIRECT_URI = "https://xiaodu.baidu.com/saiya/auth/15966f1c8158104bd82712f95d8a1150"; - String REDIRECT_URI_TEST = "https://xiaodu-dbp.baidu.com/saiya/auth/15966f1c8158104bd82712f95d8a1150"; + String REDIRECT_URI = "https://xiaodu.baidu.com/saiya/auth/3a0610f8af67a3c92d803a80a1c8976c"; + String REDIRECT_URI_TEST = "https://xiaodu-dbp.baidu.com/saiya/auth/3a0610f8af67a3c92d803a80a1c8976c"; String CLIENT_ID = "aiqiwucom"; String CLIENT_SECRET = "miaoquanwei"; } diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java index fd34d50..70ffa87 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java @@ -143,6 +143,7 @@ public class OkHttp3Utils { case 3 : header = "jiaoyou-audio-child-test";break; case 2 : case 4 : header = "jiaoyou-audio-adult-test";break; + case 6 : header = "baidu-screen-jiaoyou-audio-test";break; default: header = "jiaoyou-audio-test"; } } @@ -304,6 +305,34 @@ public class OkHttp3Utils { } } + public static void doPutAsy(String url, String requestJsonStr) { + Request request = new Request.Builder() + .url(url) + .put(RequestBody.create(requestJsonStr,MediaType.parse("application/json; charset=utf-8"))) + .build(); + client.newCall(request).enqueue(new Callback() { + @Override + public void onFailure(@NotNull Call call, @NotNull IOException e) { + log.info("天猫精灵发送无音频数据失败"); + } + + @Override + public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException { + try (ResponseBody body = response.body()){ + body.string(); + } catch (SocketTimeoutException e) { + log.error("捕获到SocketTimeoutException:{}", e.toString()); + client.dispatcher().cancelAll(); + client.connectionPool().evictAll(); + } catch (Exception e) { + log.error(ExceptionUtils.getStackTrace(e)); + } + } + }); + } + + + public static String doDelete(String url, Map headers, String jsonStr) throws IOException { Request.Builder builder = new Request.Builder(); Request request = builder.url(url).build(); diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java index eff4d57..15cac0e 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java @@ -256,11 +256,15 @@ public class Utils { List list = Arrays.asList(s1); StringBuilder num = new StringBuilder(); boolean first = true; - for (String str: numStr.split("")) { + String[] arr = numStr.split(""); + for (String str: arr) { int i; if (first) { first = false; - if (str.equals("十")) num.append(1); + if (str.equals("十")) { + if (arr.length == 1) return 10; + num.append(1); + } else if ((i = list.indexOf(str)) != -1) num.append(i); } else if ((i = list.indexOf(str)) != -1) num.append(i); diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java index 4979121..dfb7677 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java @@ -174,7 +174,7 @@ public class CollectHistoryUtils { backGroundImg.setPosition("absolute"); backGroundImg.setTop("0dp"); backGroundImg.setLeft("0dp"); - backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backend.jpg"); + backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backNew.jpg"); backGroundImg.setHeight("100%"); backGroundImg.setScaleType("fitXY"); backGroundImg.setWidth("100%"); 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 9256f04..abd9b89 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 @@ -260,8 +260,7 @@ public class TempleUtils { for (ProjectData projectInfo : list) { String productName = correctName(projectInfo.getName()); String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(projectInfo.getName()).toString(); - String src = new StringBuilder(IMG_PREFIX).append(projectInfo.getBannerImgUrl()).toString(); - LunchBotData data = new LunchBotData(src, imageId,productName); + LunchBotData data = new LunchBotData(projectInfo.getBannerImgUrl(), imageId,productName); data.setNum(begin++); dataList.add(data); } diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchPojo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchPojo.java index 3eae042..11338b0 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchPojo.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchPojo.java @@ -25,6 +25,7 @@ public class LunchPojo { private String width; private String left; private String top; + private String bottom; private String right; private String src; private List items; @@ -58,6 +59,10 @@ public class LunchPojo { private String text; @JsonProperty("font-size") private String fontSize; + @JsonProperty("justify-content") + private String justifyContent; private List data; private List firstItem; + private String headerImage; + private List hints; } 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 533bf79..f152523 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 @@ -1,6 +1,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.dpl.Event; import ai.qiwu.com.xiaoduhome.service.ScheduleService; import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew; @@ -19,9 +20,10 @@ public class LunchUtils { private static final LunchPojo LUNCH_LIST_CATEGORY_CON = buildCategoryList(); private static final LunchPojo LUNCH_HEAD = buildLunchHead(); private static final LunchPojo LUNCH_BACK_IMG = buildLunchBackgroundImg(); - 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 static final LunchPojo FOOTER = buildHomeFooter(); +// 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(); @@ -47,7 +49,8 @@ public class LunchUtils { LunchPojo scroll = buildLunchScroll(); scroll.setItems(list); - 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,LUNCH_LOGO_IMG,LUNCH_HSITORY_IMG,LUNCH_COLLECT_IMG,scroll)); + mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll,FOOTER)); return document; } @@ -70,7 +73,7 @@ public class LunchUtils { LunchPojo scroll = buildLunchScroll(); // scroll.setItems(Arrays.asList(conRecommend,conRanking,conCategory)); - 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,LUNCH_LOGO_IMG,LUNCH_HSITORY_IMG,LUNCH_COLLECT_IMG,scroll)); return document; } @@ -78,8 +81,10 @@ public class LunchUtils { LunchPojo scroll = new LunchPojo(); scroll.setType("ScrollView"); scroll.setDirection("vertical"); + scroll.setMarginTop("180dp"); scroll.setWidth("100%"); - scroll.setMarginBottom("10dp"); + scroll.setPaddingBottom("20dp"); +// scroll.setMarginBottom("10dp"); return scroll; } @@ -105,12 +110,13 @@ public class LunchUtils { private static LunchPojo buildLunchList(List data) { LunchPojo container = new LunchPojo(); container.setType("Container"); - container.setMarginBottom("28dp"); + container.setMarginBottom("45dp"); + container.setAlignItems("center"); container.setWidth("100%"); LunchPojo list = new LunchPojo(); list.setType("List"); - list.setMarginLeft("30dp"); + list.setMarginLeft("20dp"); // list.setMarginRight("15dp"); list.setDirection("horizontal"); list.setData(data); @@ -137,8 +143,8 @@ public class LunchUtils { //image LunchPojo image = new LunchPojo(); image.setType("Image"); - image.setWidth("210dp"); - image.setHeight("210dp"); + image.setWidth("200dp"); + image.setHeight("200dp"); image.setMarginLeft("7dp"); image.setMarginTop("7dp"); image.setPosition("absolute"); @@ -150,16 +156,17 @@ public class LunchUtils { //frame LunchPojo frame = new LunchPojo(); frame.setType("Frame"); - frame.setWidth("35dp"); - frame.setHeight("35dp"); - frame.setBackgroundColor("rgba(0,0,0,0.8)"); - frame.setBorderRadius("13dp"); + frame.setWidth("45dp"); + frame.setHeight("45dp"); + frame.setBackgroundColor("rgb(30,144,255)"); + frame.setBorderRadius("25dp"); LunchPojo frmCon = new LunchPojo(); frmCon.setType("Container"); frmCon.setWidth("100%"); frmCon.setHeight("100%"); frmCon.setAlignItems("center"); + frmCon.setJustifyContent("center"); LunchPojo frmText = new LunchPojo(); frmText.setType("Text"); @@ -191,7 +198,7 @@ public class LunchUtils { backGroundImg.setPosition("absolute"); backGroundImg.setTop("0dp"); backGroundImg.setLeft("0dp"); - backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backend.jpg"); + backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backNew.jpg"); backGroundImg.setHeight("100%"); backGroundImg.setScaleType("fitXY"); backGroundImg.setWidth("100%"); @@ -200,14 +207,40 @@ public class LunchUtils { } private static LunchPojo buildLunchHead() { +// LunchPojo head = new LunchPojo(); +// head.setType("Header"); +// //head.setHeaderTitle("交游天下"); +// head.setHasBackIcon(false); +// return head; LunchPojo head = new LunchPojo(); - head.setType("Header"); - //head.setHeaderTitle("交游天下"); - head.setHasBackIcon(false); - + head.setType("Image"); + head.setPosition("absolute"); + head.setTop("0dp"); + head.setLeft("0dp"); + head.setWidth("100%"); + head.setHeight("100%"); + head.setScaleType("centerCrop"); + head.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/heaImg.png"); return head; } + private static LunchPojo buildHomeFooter() { + LunchPojo footerCon = new LunchPojo(); + footerCon.setType("Container"); + footerCon.setPosition("absolute"); + footerCon.setWidth("100%"); + footerCon.setLeft("0"); + footerCon.setBottom("0"); + + LunchPojo footer = new LunchPojo(); + footer.setType("Footer"); + footer.setHints(Arrays.asList("推荐作品","打开第一个","打开排行榜","打开历史记录","打开收藏")); + + footerCon.setItems(Collections.singletonList(footer)); + + return footerCon; + } + private static LunchPojo buildLogoImage() { LunchPojo logoCon = new LunchPojo(); logoCon.setType("Container"); 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 6942d1c..ec871ad 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 @@ -4,6 +4,7 @@ import ai.qiwu.com.xiaoduhome.pojo.ActorWithWord; import ai.qiwu.com.xiaoduhome.pojo.dpl.Event; import ai.qiwu.com.xiaoduhome.pojo.playAside.PlayPageData; import ai.qiwu.com.xiaoduhome.service.ScheduleService; +import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew; import java.util.*; @@ -18,7 +19,7 @@ public class PlayUtils { private static final PlayPojo PLAY_FLOWER = buildFlower(); private static final PlayPojo PLAY_LOGO = buildLogoImage(); private static final PlayPojo PLAY_COLLECT = buildCollect(); - private static final PlayPojo PLAY_UN_COLLECT = buildUnCollect(); +// private static final PlayPojo PLAY_UN_COLLECT = buildUnCollect(); private static final PlayPojo PLAY_LIST_ITEM = buildContent(); @@ -31,7 +32,7 @@ public class PlayUtils { List dataList = new ArrayList<>(); for (ActorWithWord aw: aws) { - PlayPageData data = new PlayPageData(aw.getActor(), ScheduleService.getAsideImgUrl(botAccount, aw.getActor()), + PlayPageData data = new PlayPageData(aw.getActor(), ScheduleServiceNew.getAsideImgUrl(botAccount, aw.getActor()), aw.getText().replaceAll("
","\n")); dataList.add(data); } @@ -355,7 +356,7 @@ public class PlayUtils { backGroundImg.setPosition("absolute"); backGroundImg.setTop("0dp"); backGroundImg.setLeft("0dp"); - backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backend.jpg"); + backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backNew.jpg"); backGroundImg.setHeight("100%"); backGroundImg.setWidth("100%"); backGroundImg.setScaleType("fitXY"); diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java index 41feea7..45f88ee 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java @@ -119,6 +119,7 @@ public class ProductInfoUtils { ProductInfoPojo label = new ProductInfoPojo(); label.setType("Text"); label.setMarginLeft("5%"); + label.setTextOverflow("ellipsis"); label.setFontSize("22dp"); label.setMaxLines(1); label.setText(labelText); @@ -260,7 +261,7 @@ public class ProductInfoUtils { backGroundImg.setPosition("absolute"); backGroundImg.setTop("0dp"); backGroundImg.setLeft("0dp"); - backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backend.jpg"); + backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backNew.jpg"); backGroundImg.setHeight("100%"); backGroundImg.setWidth("100%"); backGroundImg.setScaleType("fitXY"); 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 7fe25d2..90f0c15 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 @@ -150,17 +150,13 @@ public class RecommendUtil { botIds.append(third.getBotAccount()).append(File.separator); ProjectData forth = list.get(3); botIds.append(forth.getBotAccount()).append(File.separator); - RecommandPojo pojoFirst = buildImgFrmTxtContainerFirstRow(new StringBuilder(Constants.IMG_PREFIX) - .append(first.getBannerImgUrl()).toString(), new StringBuilder(Constants.PRE_PRODUCT_IMG).append(first.getName()).toString(), + RecommandPojo pojoFirst = buildImgFrmTxtContainerFirstRow(first.getBannerImgUrl(), 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(), + RecommandPojo pojoSe = buildImgFrmTxtContainerFirstRow(second.getBannerImgUrl(), 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(), + RecommandPojo pojoThird = buildImgFrmTxtContainerFirstRow(third.getBannerImgUrl(), 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(), + RecommandPojo pojoFourth = buildImgFrmTxtContainerFourth(forth.getBannerImgUrl(), new StringBuilder(Constants.PRE_PRODUCT_IMG).append(forth.getName()).toString(), TempleUtils.correctName(forth.getName())); rowContainer.setItems(Arrays.asList(pojoFirst, pojoSe, pojoThird, pojoFourth)); @@ -171,7 +167,7 @@ public class RecommendUtil { //scrollList.add(buildRecommendList(getListData(3, 12, 16, list, botIds))); mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,RANK_HEAD,scrollView,buildPageButton(1, - list.size()),RANK_CATEGORY_FOOTER)); + list.size()/12 + list.size()%12==0?0:1),RANK_CATEGORY_FOOTER)); botIds.deleteCharAt(botIds.length()-1); String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes()); @@ -210,7 +206,7 @@ public class RecommendUtil { begin = end; } mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,RANK_HEAD,scrollView, - buildPageButton(num+1, list.size()),RANK_CATEGORY_FOOTER)); + buildPageButton(num+1, list.size()/12 + list.size()%12==0?0:1),RANK_CATEGORY_FOOTER)); botIds.deleteCharAt(botIds.length()-1); String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes()); @@ -228,9 +224,8 @@ public class RecommendUtil { StringBuilder botIds = new StringBuilder(); int num = 0; for (ProjectData bot: bots) { - String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString(); String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString(); - RecommandBotInfo detail = new RecommandBotInfo(imgSrc,imageId, TempleUtils.correctName(bot.getName())); + RecommandBotInfo detail = new RecommandBotInfo(bot.getBannerImgUrl(),imageId, TempleUtils.correctName(bot.getName())); detail.setNum(++num); data.add(detail); botIds.append(bot.getBotAccount()).append(File.separator); @@ -294,10 +289,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("15dp"); + frame.setWidth("45dp"); + frame.setHeight("45dp"); + frame.setBackgroundColor("rgb(30,144,255)"); + frame.setBorderRadius("25dp"); RecommandPojo frmCon = new RecommandPojo(); frmCon.setType("Container"); @@ -455,9 +450,8 @@ public class RecommendUtil { for (int i = begin; i < end; i++) { ProjectData bot = bots.get(i); botIds.append(bot.getBotAccount()).append(File.separator); - String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString(); String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString(); - RecommandBotInfo detail = new RecommandBotInfo(imgSrc,imageId, TempleUtils.correctName(bot.getName())); + RecommandBotInfo detail = new RecommandBotInfo(bot.getBannerImgUrl(),imageId, TempleUtils.correctName(bot.getName())); detail.setNum(i-begin+n); data.add(detail); } @@ -469,9 +463,8 @@ public class RecommendUtil { int n = 1+row*4; for (int i = begin; i < end; i++) { ProjectData bot = bots.get(i); - String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString(); String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString(); - RecommandBotInfo detail = new RecommandBotInfo(imgSrc,imageId, TempleUtils.correctName(bot.getName())); + RecommandBotInfo detail = new RecommandBotInfo(bot.getBannerImgUrl(),imageId, TempleUtils.correctName(bot.getName())); detail.setNum(i-begin+n); data.add(detail); } @@ -602,7 +595,7 @@ public class RecommendUtil { backGroundImg.setPosition("absolute"); backGroundImg.setTop("0dp"); backGroundImg.setLeft("0dp"); - backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backend.jpg"); + backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backNew.jpg"); backGroundImg.setHeight("100%"); backGroundImg.setWidth("100%"); backGroundImg.setScaleType("fitXY"); @@ -653,4 +646,10 @@ public class RecommendUtil { public static void setRankDocument(RecommandDocument rankDocument) { RecommendUtil.rankDocument = rankDocument; } + + public static void main(String[] args) { + String s = "sgagoijcue4569kmd9eir8345/234/23526/dfhh/2345345"; + System.out.println(s.length()); + System.out.println(Base64.getEncoder().encodeToString(s.getBytes()).length()); + } } diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java index ecb3199..0cbfbfc 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java @@ -4,6 +4,7 @@ import ai.qiwu.com.xiaoduhome.common.Utils; import ai.qiwu.com.xiaoduhome.pojo.OverTimeDetail; import ai.qiwu.com.xiaoduhome.service.DplBotRedisService; import ai.qiwu.com.xiaoduhome.service.DplBotService; +import ai.qiwu.com.xiaoduhome.service.DplBotServiceBoth; import ai.qiwu.com.xiaoduhome.service.ResponseEncapsulation; import ai.qiwu.com.xiaoduhome.spirit.SpiritService; import ai.qiwu.com.xiaoduhome.xiaoai.model.request.XiaoAiRequest; @@ -119,13 +120,13 @@ public class XiaoDuHomeController { try { //log.info("--------------分界线-------------------"); // DplBotService service = new DplBotService(Utils.getHttpServletRequest(), 5); -// log.info("请求信息中的attributes:{}", service.getRequest().getSession().getAttributes()); - DplBotRedisService service = new DplBotRedisService(request, 5, stringRedisTemplate); -// log.info(service.getStrRequest()); + DplBotServiceBoth service = new DplBotServiceBoth(request, 6, stringRedisTemplate); + log.info("请求信息中的attributes:{}", service.getRequest().getSession().getAttributes()); + log.info(service.getStrRequest()); //service.disableVerify(); service.enableVerify(); String str = service.run(); -// log.info("响应信息:{}", str); + log.info("响应信息:{}", str); return str; } catch (Exception e) { e.printStackTrace(); diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java index e461480..af3312b 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java @@ -26,4 +26,6 @@ public class UserBehaviorData { private volatile Byte mark = 1; private volatile String jytUserId; + + private volatile String channel; } diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ProjectDataResult.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ProjectDataResult.java new file mode 100644 index 0000000..6879251 --- /dev/null +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ProjectDataResult.java @@ -0,0 +1,18 @@ +package ai.qiwu.com.xiaoduhome.pojo.data; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +/** + * @author 苗权威 + * @dateTime 20-1-18 上午11:15 + */ +@Getter +@Setter +@ToString +public class ProjectDataResult { + private Integer code; + private String msg; + private ResultData data; +} diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ResultData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ResultData.java new file mode 100644 index 0000000..9fd71b6 --- /dev/null +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ResultData.java @@ -0,0 +1,21 @@ +package ai.qiwu.com.xiaoduhome.pojo.data; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.List; +import java.util.Map; + +/** + * @author 苗权威 + * @dateTime 20-1-18 上午11:16 + */ +@Getter +@Setter +@ToString +public class ResultData { + private List bots; + private Map> channelAcc; + private Map> headImg; +} diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/UpdateUserCollectData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/UpdateUserCollectData.java new file mode 100644 index 0000000..56c26e0 --- /dev/null +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/UpdateUserCollectData.java @@ -0,0 +1,20 @@ +package ai.qiwu.com.xiaoduhome.pojo.data; + +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; + +import java.util.Map; + +/** + * @author 苗权威 + * @dateTime 20-1-19 下午1:41 + */ +@Getter +@Setter +@ToString +public class UpdateUserCollectData { + private String userId; + private Map collectInfo; + private String channel; +} diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java index beb0904..d881041 100644 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java @@ -13,8 +13,6 @@ import ai.qiwu.com.xiaoduhome.common.temple.productInfo.ProductInfoDocument; import ai.qiwu.com.xiaoduhome.common.temple.productInfo.ProductInfoUtils; import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandDocument; 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.XiaoDuOrderTB; import ai.qiwu.com.xiaoduhome.pojo.*; import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData; @@ -72,6 +70,7 @@ import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.BEARER; import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.FLOWER_INTERFACE; import static ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil.USER_HISTORY; import static ai.qiwu.com.xiaoduhome.service.ScheduleService.*; +import static ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew.curTime; /** * @author mqw @@ -80,7 +79,7 @@ import static ai.qiwu.com.xiaoduhome.service.ScheduleService.*; public class DplBotServiceBoth extends BaseBot { private static final MyDocument FIRST_PAGE; - private static final ConcurrentHashMap LAST_OUTTIME_RESULT = new ConcurrentHashMap<>(); +// private static final ConcurrentHashMap LAST_OUTTIME_RESULT = new ConcurrentHashMap<>(); static { FIRST_PAGE = JSON.parseObject(DplbotServiceUtil.getDPLTemple("static/json/firstPage.json"), MyDocument.class); @@ -203,9 +202,9 @@ public class DplBotServiceBoth extends BaseBot { @Override protected Response onInent(IntentRequest intentRequest) { - final String userId = customUserId(); - String redisId = SpiritRedisService.PREFIX_REDIS+userId; if (getRequest().getContext().getScreen() == null) { + final String userId = customUserId(); + String redisId = SpiritRedisService.PREFIX_REDIS+userId; // final String deviceUserId = PREFIX_USERID + getDeviceId(); try { @@ -264,24 +263,61 @@ public class DplBotServiceBoth extends BaseBot { return buildErrorResponse(SORRY_UNCATCH); } } else { - + String redisId = SpiritRedisService.PREFIX_REDIS+getUserId(); + String lastData; + if ((lastData=stringRedisTemplate.opsForValue().get(redisId))!=null) { + return dealScreenOutTimeResult(lastData, getUserId(), channel); + } try { Future future = DplbotServiceUtil.getPOOL().submit(() -> dealDefaultIntent(intentRequest, getUserId(), null, channel)); - return future.get(2200, TimeUnit.MILLISECONDS); + return future.get(2700, TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException e) { - log.error("获取任务执行结果出错:{}", ExceptionUtils.getStackTrace(e)); + log.warn("获取任务执行结果出错:{}", ExceptionUtils.getStackTrace(e)); return buildErrorResponse(SORRY_UNCATCH); } catch (TimeoutException e) { log.info("超时,让用户再说一遍:{}",e.toString()); + stringRedisTemplate.opsForValue().setIfAbsent(redisId, "out", 10, TimeUnit.SECONDS); return buildErrorResponse(SORRY_UNCATCH); } catch (Exception all) { - log.error("任务执行发生了错误:{}", ExceptionUtils.getStackTrace(all)); + log.warn("任务执行发生了错误:{}", ExceptionUtils.getStackTrace(all)); return buildErrorResponse(SORRY_UNCATCH); } } } + private Response dealScreenOutTimeResult(String data, String userId, String channelId) { + String[] arr = data.split("⧩"); + + JSONObject object = JSON.parseObject(arr[0]); + String path = arr[1]; + String botAccount = object.getString("aipioneerUsername"); + String beforeBotAccount = getSessionAttribute("botAcc"); + if (!botAccount.equals(beforeBotAccount)) { + DplbotServiceUtil.updateTheUserBehaviorDataMark(userId, botAccount, getAccessToken(), getSessionAttribute("userId")); + String productName = ScheduleServiceNew.getProjectByBotAccount(botAccount).getName(); + PlayDocument document = PlayUtils.getPlayDocument(productName, DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs")), + dealAudioUrl(path), botAccount); + + RenderDocument render = new RenderDocument(document); + addDirective(render); + DplbotServiceUtil.updateTheUserHistory(userId, botAccount, getAccessToken(), channelId); + String trace = getSessionAttribute(BACK_TRACE); + if (trace == null || trace.length() != 2) trace = "00"; + trace = new StringBuilder(trace).append(botAccount).append(File.separator).toString(); + setSessionAttribute(BACK_TRACE, trace); + setSessionAttribute("botAcc", botAccount); + } else { + String productName = ScheduleServiceNew.getProjectByBotAccount(botAccount).getName(); + PlayDocument document = PlayUtils.getPlayDocument(productName, + DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs")), dealAudioUrl(path), botAccount); + + RenderDocument render = new RenderDocument(document); + addDirective(render); + } + return new Response(); + } + private Response dealNoScreenIntentTemp(IntentRequest intentRequest, String userId) { String intentName = getIntent().getName(); if ("sendFlower".equals(intentName)) { @@ -449,13 +485,12 @@ public class DplBotServiceBoth extends BaseBot { return new Response(outputSpeech); } else if ("CONFIRMED".equals(confirmationStatus)) { log.info("确认"); - int unitPrice = Integer.parseInt(ScheduleService.FLOWER_UNIT_PRICE); + int unitPrice = Integer.parseInt(ScheduleServiceNew.FLOWER_UNIT_PRICE); String amount = String.valueOf(unitPrice*Integer.parseInt(num)/100.0); String orderId = userId + System.currentTimeMillis(); String appUserId = getSessionAttribute("userId"); if (appUserId == null) { - if (channelId == null) appUserId = DplbotServiceUtil.getUserIdByToken(getAccessToken(), null); - else appUserId = DplbotServiceUtil.getUsUserId(userId,getAccessToken(), channelId); + appUserId = DplbotServiceUtil.getUsUserId(userId,getAccessToken(), channelId); if (appUserId == null) { log.error("送花时获取用户app_user_id失败"); return buildErrorResponse("不好意思出了点问题,请再说一遍吧"); @@ -563,7 +598,6 @@ public class DplBotServiceBoth extends BaseBot { if (productDetail == null) { return buildErrorResponse("目前不支持该作品"); } - String imgUrl = new StringBuilder(Constants.IMG_PREFIX).append(productDetail.getBannerImgUrl()).toString(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String dateString = formatter.format(productDetail.getCreateTime()); @@ -598,7 +632,7 @@ public class DplBotServiceBoth extends BaseBot { collectComId = new StringBuilder(COLLEC_ID).append(productDetail.getBotAccount()).toString(); } } else { - flowers = FLOWE; + flowers = FLOWER; flowerReward = FLOWER_LOAD; collectText = UN_COLLEC; @@ -606,7 +640,7 @@ public class DplBotServiceBoth extends BaseBot { collectComId = FLOWER_LOAD; } - ProductInfoDocument document = ProductInfoUtils.getProductINfoDocument(imgUrl, correctName(productName), time, author, labels.toString(), + ProductInfoDocument document = ProductInfoUtils.getProductINfoDocument(productDetail.getBannerImgUrl(), correctName(productName), time, author, labels.toString(), intro, enterProName, flowerReward, flowers, collectComId, collectUrl, collectText); RenderDocument renderDocument = new RenderDocument(document); @@ -757,10 +791,12 @@ public class DplBotServiceBoth extends BaseBot { // log.warn("用户退出向中控发出退出指令出错"); // } return new Response(outputSpeech); + } else { + String byeWord = EndMsg.END_BYE_JIAOYOU; + OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, byeWord); + RequestTerminal.backRequest(getUserId(), type); + return new Response(outputSpeech); } - DplbotServiceUtil.writeTheUserHistoryInData(getUserId()); -// LAST_OUTTIME_RESULT.remove(getUserId()); - return new Response(); } private void dealWithError(SessionEndedRequest request) { @@ -978,7 +1014,7 @@ public class DplBotServiceBoth extends BaseBot { ListCard listCard = new ListCard(); for (String actor: actors) { StandardCardInfo cardInfo = new StandardCardInfo(actor, actorWord[i++].replaceAll("
","\n")); - cardInfo.setImage(ScheduleService.getAsideImgUrl(botAccount, actor)); + cardInfo.setImage(ScheduleServiceNew.getAsideImgUrl(botAccount, actor)); listCard.getList().add(cardInfo); } // content = buildText(content); @@ -1007,8 +1043,6 @@ public class DplBotServiceBoth extends BaseBot { private void backToBotIntro(String botAccount, String channelId) { ProjectData data = ScheduleServiceNew.getProjectByBotAccount(botAccount); - // product picture - String imgUrl = new StringBuilder(Constants.IMG_PREFIX).append(data.getBannerImgUrl()).toString(); // product name String productName = correctName(data.getName()); @@ -1063,7 +1097,7 @@ public class DplBotServiceBoth extends BaseBot { collectComId = FLOWER_LOAD; // 提示登录 } - ProductInfoDocument document = ProductInfoUtils.getProductINfoDocument(imgUrl, correctName(productName), createTime, author, labels.toString(), + ProductInfoDocument document = ProductInfoUtils.getProductINfoDocument(data.getBannerImgUrl(), correctName(productName), createTime, author, labels.toString(), intro, enterProName, flowerReward, flowers, collectComId, collectUrl, collectText); RenderDocument renderDocument = new RenderDocument(document); this.addDirective(renderDocument); @@ -1086,8 +1120,8 @@ public class DplBotServiceBoth extends BaseBot { char pageSign = trace.charAt(1); Response response; switch (pageSign) { - case '1' : - case '2' : response = dealCollectHistoryJump(index, true, userId, channelId);break; + case '1' : response = dealCollectHistoryJump(index, true, userId, channelId);break; + case '2' : response = dealCollectHistoryJump(index, false, userId, channelId);break; case '4' : response = dealRankJump(index, channelId);break; case '5' : response = dealCategoryJump(index);break; default : response = buildErrorResponse("该页面不支持跳转"); @@ -1165,7 +1199,7 @@ public class DplBotServiceBoth extends BaseBot { return buildErrorResponse("该功能需要登录,请说小度小度,登录"); } int num = extractNum(numStr); - int unitPrice = Integer.parseInt(ScheduleService.FLOWER_UNIT_PRICE); + int unitPrice = Integer.parseInt(ScheduleServiceNew.FLOWER_UNIT_PRICE); String amount = String.valueOf(unitPrice*num/100.0); String orderId = userId + System.currentTimeMillis(); String appUserId = getSessionAttribute("userId"); @@ -1308,12 +1342,17 @@ public class DplBotServiceBoth extends BaseBot { } setSessionAttribute(BACK_TRACE, "03"); detail.getAttributes().put(BACK_TRACE,"03"); - LAST_OUTTIME_RESULT.put(userId, detail); +// LAST_OUTTIME_RESULT.put(userId, detail); } private Response dealHistoryIntent(String channelId) { - CollectHistoryDocument document = DplbotServiceUtil.getHistory(getUserId(), getAccessToken(), - getSessionAttribute("userId"),0, channelId); + CollectHistoryDocument document = null; + try { + document = DplbotServiceUtil.getHistory(getUserId(), getAccessToken(), + getSessionAttribute("userId"),0, channelId); + } catch (Exception e) { + log.error(ExceptionUtils.getStackTrace(e)); + } if (document == null) { return buildErrorResponse("没有更多了"); } @@ -1343,14 +1382,8 @@ public class DplBotServiceBoth extends BaseBot { int start = count*CO_HI_PAGE_SIZE; String jytUserId = getSessionAttribute("userId"); if (StringUtils.isBlank(jytUserId)) { - UserBehaviorData data = USER_HISTORY.get(userId); - if (data != null) { - jytUserId = data.getJytUserId(); - if (StringUtils.isBlank(jytUserId)) { - jytUserId = DplbotServiceUtil.getUserIdByToken(getAccessToken(), null); - data.setJytUserId(jytUserId); - } - } + jytUserId = DplbotServiceUtil.getUsUserId(userId, getAccessToken(), channelId); + setSessionAttribute("userId", jytUserId); } CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(userId,getAccessToken(), jytUserId, start, channelId); @@ -1449,17 +1482,11 @@ public class DplBotServiceBoth extends BaseBot { int start = (count-2)*CO_HI_PAGE_SIZE; String jytUserId = getSessionAttribute("userId"); if (StringUtils.isBlank(jytUserId)) { - UserBehaviorData data = USER_HISTORY.get(userId); - if (data != null) { - jytUserId = data.getJytUserId(); - if (StringUtils.isBlank(jytUserId)) { - jytUserId = DplbotServiceUtil.getUserIdByToken(getAccessToken(), null); - data.setJytUserId(jytUserId); - } - } + jytUserId = DplbotServiceUtil.getUsUserId(userId, getAccessToken(), channelId); + setSessionAttribute("userId", jytUserId); } CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(userId,getAccessToken(), - getSessionAttribute("userId"), start, channelId); + jytUserId, start, channelId); if (document != null) { RenderDocument render = new RenderDocument(document); addDirective(render); @@ -1544,7 +1571,8 @@ public class DplBotServiceBoth extends BaseBot { private Response dealOpenNumIntent(String numStr, String channelId) { String trace = getSessionAttribute("trace"); - int num = extractNum(numStr.replaceAll(" ", "")); + int num = extractNum(numStr); + log.info("dealOpenNumIntent num:"+num); if (trace == null || trace.charAt(1) == '0') { return dealOpenNumInHome(num); } else if (trace.length() > 2) { @@ -1567,6 +1595,7 @@ public class DplBotServiceBoth extends BaseBot { } private Integer extractNum(String numStr) { + numStr = numStr.replaceAll("[ \uD83C\uDD70\uD83C\uDD71]", ""); int num; try { num = Integer.parseInt(numStr); @@ -1593,8 +1622,9 @@ public class DplBotServiceBoth extends BaseBot { } else { String jytId = getSessionAttribute("userId"); if (StringUtils.isBlank(jytId)) { - jytId = DplbotServiceUtil.getUserIdByToken(getAccessToken(), null); + jytId = DplbotServiceUtil.getUsUserId(getUserId(), getAccessToken(), channelId); if (StringUtils.isBlank(jytId)) return buildErrorResponse("不好意思没有获取到您的收藏记录"); + setSessionAttribute("userId", jytId); } CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(getUserId(),getAccessToken(), jytId, 0, channelId); if (document == null) { @@ -1757,6 +1787,7 @@ public class DplBotServiceBoth extends BaseBot { if (StringUtils.isBlank(data)) { return buildErrorResponse(SORRY_UNCATCH); } + log.info("小悟返回:"+data); JSONObject object = JSON.parseObject(data); try { JSONArray commands = object.getJSONArray("commands"); @@ -1923,6 +1954,8 @@ public class DplBotServiceBoth extends BaseBot { RenderDocument render = new RenderDocument(document); addDirective(render); } + stringRedisTemplate.opsForValue().setIfPresent(SpiritRedisService.PREFIX_REDIS+userId, + new StringBuilder(data).append("⧩").append(path).toString(), 10, TimeUnit.SECONDS); return new Response(); } @@ -2030,8 +2063,6 @@ public class DplBotServiceBoth extends BaseBot { private Response enterProductInfo(String productName, String channelId) { ProjectData productDetail = ScheduleServiceNew.getProjectByName(productName); - // product picture - String imgUrl = new StringBuilder(Constants.IMG_PREFIX).append(productDetail.getBannerImgUrl()).toString(); // product create time SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); @@ -2083,7 +2114,7 @@ public class DplBotServiceBoth extends BaseBot { collectComId = FLOWER_LOAD; // 提示登录 } - ProductInfoDocument document = ProductInfoUtils.getProductINfoDocument(imgUrl, correctName(productName), createTime, author, labels.toString(), + ProductInfoDocument document = ProductInfoUtils.getProductINfoDocument(productDetail.getBannerImgUrl(), correctName(productName), createTime, author, labels.toString(), intro, enterProName, flowerReward, flowers, collectComId, collectUrl, collectText); RenderDocument renderDocument = new RenderDocument(document); @@ -2158,7 +2189,7 @@ public class DplBotServiceBoth extends BaseBot { final String botAccount = token.substring(0, sepIndex); String str = "恭喜您支付成功,开始体验吧"; if (getRequest().getContext().getScreen() != null) { - boolean response = DplbotServiceUtil.dealChargeCallback(chargeEvent, customUserId(), getAccessToken(), + boolean response = DplbotServiceUtil.dealChargeCallback(chargeEvent, getUserId(), getAccessToken(), getSessionAttribute("userId"), PRODUCT_ID_DETAIL.get(botAccount).getName(), "xiaodu_screen"); if (response) { Map flowerRecords = USER_HISTORY.get(getUserId()).getUserBotId2Flowers(); @@ -2214,8 +2245,10 @@ public class DplBotServiceBoth extends BaseBot { @Override protected Response onPlaybackStartedEvent(PlaybackStartedEvent playbackStartedEvent) { // setSessionAttribute("botAcc",getSessionAttribute("botAcc")); - Boolean result = stringRedisTemplate.delete(SpiritRedisService.PREFIX_REDIS+customUserId()); - log.info("音频播放事件删除:"+result); + if (getRequest().getContext().getScreen() == null) { + Boolean result = stringRedisTemplate.delete(SpiritRedisService.PREFIX_REDIS+customUserId()); + log.info("音频播放事件删除:"+result); + } waitAnswer(); 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 e138e50..2662255 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 @@ -4,20 +4,15 @@ import ai.qiwu.com.xiaoduhome.common.*; import ai.qiwu.com.xiaoduhome.common.temple.CollectHistoryDocument; import ai.qiwu.com.xiaoduhome.common.temple.CollectHistoryUtils; import ai.qiwu.com.xiaoduhome.entity.primary.AppFavoriteTB; -import ai.qiwu.com.xiaoduhome.entity.primary.AppFlowerTB; -import ai.qiwu.com.xiaoduhome.entity.primary.AppFlowerTBTiny; import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail; import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryBotIdTime; -import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryTB; import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuOrderTB; import ai.qiwu.com.xiaoduhome.pojo.*; import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData; +import ai.qiwu.com.xiaoduhome.pojo.data.UpdateUserCollectData; import ai.qiwu.com.xiaoduhome.pojo.pageData.HistoryData; import ai.qiwu.com.xiaoduhome.repository.primary.AppFavoriteTBRepository; -import ai.qiwu.com.xiaoduhome.repository.primary.AppFlowerTBRepository; import ai.qiwu.com.xiaoduhome.repository.primary.AppFlowerTBTintRepository; -import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryBotTimeRepository; -import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryTBRepository; import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuOrderTbRepository; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -30,14 +25,13 @@ import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.commons.lang3.math.NumberUtils; -import org.springframework.data.domain.Example; import org.springframework.util.CollectionUtils; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.sql.Timestamp; +import java.net.URLEncoder; import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.ArrayBlockingQueue; @@ -46,12 +40,11 @@ import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.util.stream.Collectors; 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.ScheduleService.curTime; +import static ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew.curTime; /** * @author 苗权威 @@ -61,7 +54,7 @@ import static ai.qiwu.com.xiaoduhome.service.ScheduleService.curTime; public class DplbotServiceUtil { final static String HOST_UTL; static { - HOST_UTL = Config.getProperty("requestHost", "http://didi-gz4.jiaoyou365.com:18082/"); + HOST_UTL = Config.getProperty("requestHost", "http://didi-gz5.jiaoyou365.com:18082/"); log.info("hostUrl:"+HOST_UTL); } private static final int CORE = Runtime.getRuntime().availableProcessors(); @@ -146,10 +139,10 @@ public class DplbotServiceUtil { static void onLunchFillUserBehaviorData(final String userId, final String channelId, final String jytUserId) { POOL.submit(() -> { - Map params = new HashMap<>(); - params.put("userId", userId); - params.put("channelId", channelId); try { + Map params = new HashMap<>(); + params.put("userId", URLEncoder.encode(userId, "UTF-8")); + params.put("channelId", channelId); String response = OkHttp3Utils.doGet(HOST_UTL+"/audio_box/behavior", params); if (StringUtils.isNotBlank(response)) { JSONObject result = JSON.parseObject(response); @@ -163,6 +156,7 @@ public class DplbotServiceUtil { if (!CollectionUtils.isEmpty(botAccount2FavoriteTime)) data.setUserBotId2Collected(botAccount2FavoriteTime); if (!CollectionUtils.isEmpty(botAccount2Flowers)) data.setUserBotId2Flowers(botAccount2Flowers); data.setJytUserId(jytUserId); + data.setChannel(channelId); USER_HISTORY.put(userId, data); } } @@ -191,6 +185,7 @@ public class DplbotServiceUtil { if (!CollectionUtils.isEmpty(botAccount2FavoriteTime)) data.setUserBotId2Collected(botAccount2FavoriteTime); if (!CollectionUtils.isEmpty(botAccount2Flowers)) data.setUserBotId2Flowers(botAccount2Flowers); data.setJytUserId(jytUserId); + data.setChannel(channelId); USER_HISTORY.put(userId, data); return data; } @@ -295,7 +290,7 @@ public class DplbotServiceUtil { } static Charge sendOneFlowerByCharge(String userId, String jytUserId, String accessToken, String trace, String channelId) { - String price = ScheduleService.FLOWER_UNIT_PRICE; + String price = ScheduleServiceNew.FLOWER_UNIT_PRICE; int unitPrice = Integer.parseInt(price); String amount = String.valueOf(unitPrice/100.0); String orderId = new StringBuilder(userId).append("_").append(System.currentTimeMillis()).toString(); @@ -315,7 +310,7 @@ public class DplbotServiceUtil { if (response != null && response.getId() != null) { String desc = new StringBuilder("感谢您赏赐给该作品的").append(1).append("朵鲜花").toString(); - String name = ScheduleService.PRODUCT_ID_DETAIL.get(botId).getName(); + String name = ScheduleServiceNew.getProjectByBotAccount(botId).getName(); if (name != null) desc = new StringBuilder("感谢您赏赐给").append(name) .append("的").append(1).append("朵鲜花").toString(); Charge charge = new Charge(amount, orderId, "鲜花", desc); @@ -368,28 +363,19 @@ public class DplbotServiceUtil { }); } - static void writeTheUserHistoryInData(final String userId) { - POOL.submit(() -> { - UserBehaviorData data = USER_HISTORY.remove(userId); - if (data != null) { - XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository"); - for (Map.Entry entry: data.getUserBotId2History().entrySet()) { - String botId = entry.getKey(); - Long time = entry.getValue(); - XiaoDuHistoryTB historyTB = repository.getByXiaoduUserIdAndBotId(userId, botId); - if (historyTB == null) { - historyTB = new XiaoDuHistoryTB(); - historyTB.setLastTime(time); - historyTB.setBotId(botId); - historyTB.setXiaoduUserId(userId); - } else { - if (historyTB.getLastTime().equals(time)) continue; - historyTB.setLastTime(time); - } - repository.save(historyTB); - } + static void updateTheUserCollectData(final String userId, String channelId) { + UserBehaviorData data = USER_HISTORY.remove(userId); + if (data != null) { + try { + UpdateUserCollectData collectData = new UpdateUserCollectData(); + collectData.setChannel(channelId); + collectData.setUserId(URLEncoder.encode(userId, "UTF-8")); + collectData.setCollectInfo(data.getUserBotId2Collected()); + OkHttp3Utils.doPutAsy(HOST_UTL+"audio_box/update", JSON.toJSONString(collectData)); + } catch (Exception e) { + log.warn("更新历史记录信息出错:"+userId); } - }); + } } static boolean dealChargeCallback(ChargeEvent chargeEvent, final String userId, final String accessToken, @@ -565,20 +551,19 @@ public class DplbotServiceUtil { for (XiaoDuHistoryBotIdTime historyInfo: historyProducts) { String botAccount = historyInfo.getBotId(); build.append(botAccount).append(File.separator); - OnProductDetail productDetail = ScheduleService.getProductIdDetail().get(botAccount); + ProjectData productDetail = ScheduleServiceNew.getProjectByBotAccount(botAccount); String intro = productDetail.getIntro(); if (StringUtils.isBlank(intro)) intro = "作者太懒没写介绍"; - String imgUrl = new StringBuilder(IMG_PREFIX).append(productDetail.getBannerImgUrl()).toString(); String botAccountId = new StringBuilder(Constants.PRE_ENTER_PRODUCT).append(correctName(productDetail.getName())).toString(); String lastTime = sdf.format(new java.sql.Date(historyInfo.getLastTime())); String name = productDetail.getName(); - HistoryData data = new HistoryData(botAccountId, i++, imgUrl, correctName(name), intro); + HistoryData data = new HistoryData(botAccountId, i++, productDetail.getBannerImgUrl(), correctName(name), intro); data.setAuthorName(lastTime); projectInfoList.add(data); } CollectHistoryDocument document = CollectHistoryUtils.getDocument(projectInfoList, false, - start/CO_HI_PAGE_SIZE+1, pageNum); + start, pageNum); String idToken; if (build.length() != 0) { build.deleteCharAt(build.length()-1); @@ -616,7 +601,7 @@ public class DplbotServiceUtil { job = (JSONObject)ob; aw = new ActorWithWord(); aw.setActor(job.getString("npcName")); - aw.setText(job.getString("text")); + aw.setText(job.getString("text").replaceAll("\\{/.*?/}|\uD83C\uDD70|\uD83C\uDD71", "")); list.add(aw); } return list; diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java index caa268e..3c9b199 100755 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java @@ -43,7 +43,7 @@ import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.ASIDE_IMG_URL; * @dateTime 19-8-14 下午8:56 */ @Slf4j -@Component +//@Component public class ScheduleService implements InitializingBean { private static volatile int allProductCount; private static volatile int rankPageSize; @@ -54,7 +54,6 @@ public class ScheduleService implements InitializingBean { static volatile HashMap PRODUCT_NAME_DETAIL = new HashMap<>(); static volatile HashMap PRODUCT_ID_DETAIL = new HashMap<>(); - private static volatile HashMap> ASIDE_IMG = new HashMap<>(); private static final List EXCEPT_BOT_ACCOUNT = new ArrayList<>(); static final String[] CATEGORY = {"古风", "儿童", "科幻", "占星", "恋爱", "灾难", "架空", "经营", "冒险", "武侠"}; @@ -72,10 +71,6 @@ public class ScheduleService implements InitializingBean { private final XiaoDuOrderTbRepository xiaoDuOrderTbRepository; - static final String FLOWER_UNIT_PRICE = Config.getProperty("unitPrice", UNIT_PRICE); - - static volatile Long curTime = System.currentTimeMillis(); - public static volatile Map channelId2RecommendBotAcc = new HashMap<>(); public static volatile Map> channel2Bots = new HashMap<>(); @@ -134,28 +129,6 @@ public class ScheduleService implements InitializingBean { //log.error("更新推荐页出错:{}", e.getMessage()); } - @Scheduled(cron = "0 * */1 * * ?") - public void clearUserBehaviorData() { - DplbotServiceUtil.POOL.submit(() -> { - List needClear = new ArrayList<>(); - for (String userId: DplbotServiceUtil.USER_HISTORY.keySet()) { - UserBehaviorData data = DplbotServiceUtil.USER_HISTORY.get(userId); - if (data != null) { - if (data.getMark() == 1) data.setMark((byte) 0); - else { - needClear.add(userId); - } - } - } - for (String userId: needClear) DplbotServiceUtil.USER_HISTORY.remove(userId); - }); - } - - @Scheduled(cron = "*/30 * * * * ?") - public void updateTheCurTime() { - DplbotServiceUtil.POOL.submit(() -> curTime = System.currentTimeMillis()); - } - // @Scheduled(cron = "0 0 19 * * ?") public void initRankingList() { new Thread(() -> { @@ -310,26 +283,6 @@ public class ScheduleService implements InitializingBean { log.info("getChannelAllBots:"+jiaoyouChannel2Bots); } - private void getAsideImg() { - DplbotServiceUtil.getPOOL().submit(() -> { - List botIds = gameProjectTbRepository.getAllOnTableProductIds(); - HashMap> ai = new HashMap<>(); - for (String botId: botIds) { - try { - HashMap params = new HashMap<>(); - params.put("include", "audioNpc"); - params.put("aipioneerUsername",botId); - String str = OkHttp3Utils.doGet(ASIDE_IMG_URL, params); - AsideImageResponse response = JSON.parseObject(str, AsideImageResponse.class); - ai.put(botId, response.getData().getNpcHeadImgUrl()); - } catch (Exception e) { - log.error("定时获取头像出错:botId:{},{}",botId, ScheduleService.getProductIdDetail().get(botId).getName()); - } - } - ASIDE_IMG = ai; - }); - } - @Override public void afterPropertiesSet() throws Exception { initAllOnTableProductInfo(); @@ -339,7 +292,6 @@ public class ScheduleService implements InitializingBean { deleteOverTimeHistory(); deleteUnPayedOrder(); // tian(); - getAsideImg(); getAllChannelRecommendBotAccount(); getChannelAllBots(); getJiaoYouChannelRecordBots(); @@ -397,18 +349,6 @@ public class ScheduleService implements InitializingBean { return CATEGORY_PRODUCT_ID_LIST; } - public static String getAsideImgUrl(String botId, String name) { - String url; - Map imgs = ASIDE_IMG.get(botId); - if (imgs == null) { - url = DEFAULT_ASIDE_IMG_URL; - } else { - url = imgs.get(name); - } - if (url == null) url = DEFAULT_ASIDE_IMG_URL; - return url; - } - public static int getRankPageSize() { return rankPageSize; } diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleServiceNew.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleServiceNew.java index ac74fed..49a50f6 100644 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleServiceNew.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleServiceNew.java @@ -1,18 +1,25 @@ package ai.qiwu.com.xiaoduhome.service; +import ai.qiwu.com.xiaoduhome.common.Config; import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils; +import ai.qiwu.com.xiaoduhome.pojo.UserBehaviorData; import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData; +import ai.qiwu.com.xiaoduhome.pojo.data.ProjectDataResult; +import ai.qiwu.com.xiaoduhome.pojo.playAside.AsideImageResponse; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.InitializingBean; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.*; import java.util.stream.Collectors; +import static ai.qiwu.com.xiaoduhome.common.Constants.DPL_COMPONENT_ID.DEFAULT_ASIDE_IMG_URL; +import static ai.qiwu.com.xiaoduhome.common.Constants.UNIT_PRICE; + /** * @author 苗权威 * @dateTime 20-1-15 下午8:24 @@ -24,10 +31,16 @@ public class ScheduleServiceNew implements InitializingBean { private static volatile Map botAccount2Project = new HashMap<>(); private static volatile Map name2Project = new HashMap<>(); private static volatile Map> channel2BotAccountList = new HashMap<>(); + private static volatile Map> ASIDE_IMG = new HashMap<>(); + + static final String FLOWER_UNIT_PRICE = Config.getProperty("unitPrice", UNIT_PRICE); + + static volatile Long curTime = System.currentTimeMillis(); @Override public void afterPropertiesSet() throws Exception { getAllProjects(); + // buildLunchNewDocument } private void getAllProjects() { @@ -35,30 +48,63 @@ public class ScheduleServiceNew implements InitializingBean { try { String response = OkHttp3Utils.doGet(DplbotServiceUtil.HOST_UTL+"/audio_box/project"); if (StringUtils.isNotBlank(response)) { - JSONObject object = JSON.parseObject(response); - List list = object.getObject("bots", List.class); - Map> map = object.getObject("channelAcc", Map.class); - if (!CollectionUtils.isEmpty(list)) { - final Map botAcc = new HashMap<>(); - final Map name = new HashMap<>(); - list.forEach(projectData -> { - botAcc.put(projectData.getBotAccount(), projectData); - name.put(projectData.getName(), projectData); - }); - botAccount2Project = botAcc; - name2Project = name; - allProjects = list; - } - if (!CollectionUtils.isEmpty(map)) { - channel2BotAccountList = map; + ProjectDataResult result = JSON.parseObject(response, ProjectDataResult.class); + if (new Integer(1).equals(result.getCode())) { + List list = result.getData().getBots(); + Map> map = result.getData().getChannelAcc(); + if (!CollectionUtils.isEmpty(list)) { + final Map botAcc = new HashMap<>(); + final Map name = new HashMap<>(); + list.forEach(projectData -> { + botAcc.put(projectData.getBotAccount(), projectData); + name.put(projectData.getName(), projectData); + }); + botAccount2Project = botAcc; + name2Project = name; + allProjects = list; + } + if (!CollectionUtils.isEmpty(map)) { + channel2BotAccountList = map; + } + if (!CollectionUtils.isEmpty(result.getData().getHeadImg())) { + ASIDE_IMG = result.getData().getHeadImg(); + } } } } catch (Exception e) { log.warn("ScheduleServiceNew#getAllProjects获取所有作品信息失败:"+e); } + log.info("botAccount2Project:"+botAccount2Project.size()); + log.info("name2Project:"+name2Project.size()); + log.info("allProjects:"+allProjects.size()); + log.info("channel2BotAccountList:"+channel2BotAccountList.size()); + log.info("ASIDE_IMG:"+ASIDE_IMG.size()); }).start(); } + @Scheduled(cron = "*/30 * * * * ?") + public void updateTheCurTime() { + curTime = System.currentTimeMillis(); + } + + @Scheduled(cron = "0 * */1 * * ?") + public void clearUserBehaviorData() { + DplbotServiceUtil.POOL.submit(() -> { + List needClear = new ArrayList<>(); + for (String userId: DplbotServiceUtil.USER_HISTORY.keySet()) { + UserBehaviorData data = DplbotServiceUtil.USER_HISTORY.get(userId); + if (data != null) { + if (data.getMark() == 1) data.setMark((byte) 0); + else { + needClear.add(userId); + DplbotServiceUtil.updateTheUserCollectData(userId, data.getChannel()); + } + } + } + for (String userId: needClear) DplbotServiceUtil.USER_HISTORY.remove(userId); + }); + } + static ProjectData getProjectByName(String name) { return name2Project.get(name); } @@ -80,4 +126,16 @@ public class ScheduleServiceNew implements InitializingBean { } return datas; } + + public static String getAsideImgUrl(String botId, String name) { + String url; + Map imgs = ASIDE_IMG.get(botId); + if (imgs == null) { + url = DEFAULT_ASIDE_IMG_URL; + } else { + url = imgs.get(name); + } + if (url == null) url = DEFAULT_ASIDE_IMG_URL; + return url; + } } diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiTestService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiTestService.java index 927ad18..d350dd7 100644 --- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiTestService.java +++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiTestService.java @@ -4,6 +4,7 @@ import ai.qiwu.com.xiaoduhome.common.Constants; import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils; import ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil; import ai.qiwu.com.xiaoduhome.service.ScheduleService; +import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew; import ai.qiwu.com.xiaoduhome.xiaoai.common.RequestTerminal; import ai.qiwu.com.xiaoduhome.xiaoai.common.RequestWordNullException; import ai.qiwu.com.xiaoduhome.xiaoai.common.Utils; @@ -166,7 +167,7 @@ public class XiaoAiTestService { prefix = "box"+i; job = (JSONObject)ob; actor = job.getString("npcName"); - actorUrl = ScheduleService.getAsideImgUrl(job.getString("botAccount"), actor); + actorUrl = ScheduleServiceNew.getAsideImgUrl(job.getString("botAccount"), actor); text = job.getString("text"); if (StringUtils.isNotBlank(text)) { text = text.replaceAll("\\{/.*?/}|\uD83C\uDD70|\uD83C\uDD71", ""); diff --git a/xiaoduhome/src/main/resources/application.yml b/xiaoduhome/src/main/resources/application.yml index 117910d..83c1adb 100755 --- a/xiaoduhome/src/main/resources/application.yml +++ b/xiaoduhome/src/main/resources/application.yml @@ -41,6 +41,8 @@ spring: host: localhost port: 6379 timeout: 1000 + pid: + file: /home/dc2-user/projects/audiobox/duai/app.pid logging: path: /home/dc2-user/projects/audiobox/duai/logs diff --git a/xiaoduhome/src/main/resources/static/json/firstPage.json b/xiaoduhome/src/main/resources/static/json/firstPage.json index 5904c70..b954c68 100755 --- a/xiaoduhome/src/main/resources/static/json/firstPage.json +++ b/xiaoduhome/src/main/resources/static/json/firstPage.json @@ -12,7 +12,7 @@ "componentId": "loadingPage", "top": "0dp", "left": "0dp", - "src": "https://didi-gz5.jiaoyou365.com/duai/image/Loading.png", + "src": "https://didi-gz5.jiaoyou365.com/duai/image/LoadNew.jpg", "height": "100%", "width": "100%", "scale-type": "fitXY", diff --git a/xiaoduhome/src/main/resources/xiaodu.properties b/xiaoduhome/src/main/resources/xiaodu.properties index f6d16f8..92dfedd 100755 --- a/xiaoduhome/src/main/resources/xiaodu.properties +++ b/xiaoduhome/src/main/resources/xiaodu.properties @@ -1,2 +1,3 @@ unitPrice=1 -requestHost=http://didi-gz4.jiaoyou365.com:18082/ \ No newline at end of file +requestHost=http://didi-gz5.jiaoyou365.com:18082/ +pidPath=/home/dc2-user/projects/audiobox/duai/app.pid \ No newline at end of file -- libgit2 0.27.1