From a1aa3fa5468254a67394a21bc9c1c5fad6a27d39 Mon Sep 17 00:00:00 2001
From: 苗权威 <1160292058@qq.com>
Date: Thu, 29 Aug 2019 10:34:15 +0800
Subject: [PATCH] 8.29
---
.idea/workspace.xml | 822 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java | 25 ++++++++++++++++++++++---
tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java | 10 ++++++++++
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java | 5 +++++
tts_service/src/main/resources/application.yml | 12 ++++++------
tts_service/src/main/resources/tts.properties | 12 ++++++------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java | 12 ++++++++++--
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java | 46 ++++++++++++++++++++++++++++++++++++++++++----
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/ServiceUtil.java | 43 -------------------------------------------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/Agent.java | 10 ++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryDocument.java | 22 ++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryMainTemplate.java | 27 +++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryPagePojo.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CustomMainTemplateInterface.java | 8 ++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/FrameTemple.java | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java | 235 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/collectIcon.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdateDocument.java | 15 +++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdateMainTemplate.java | 24 ++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdatePojo.java | 38 ++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankBotInfo.java | 20 ++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingDocument.java | 24 ++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingMainTemplate.java | 23 +++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingPojo.java | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandBotInfo.java | 20 ++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandDocument.java | 23 +++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandMainTemplate.java | 23 +++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandPojo.java | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/Oauth2Controller.java | 2 +-
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java | 2 ++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/GameProjectTb.java | 6 ++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/OnProductDetail.java | 4 ++--
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryBotIdTime.java | 28 ++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryTB.java | 40 ++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/OverTimeDetail.java | 21 +++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/QiWuResponse.java | 1 +
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Item.java | 16 ++++++++++------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/MyMainTemplate.java | 4 +++-
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/pageData/HistoryData.java | 32 ++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFavoriteTBRepository.java | 8 ++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java | 6 ++++--
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryBotTimeRepository.java | 14 ++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryTBRepository.java | 34 ++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTBIdRepository.java | 1 -
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java | 1 -
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java | 869 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java | 18 +++++++++++++++---
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
xiaoduhome/src/main/resources/application.yml | 3 +++
xiaoduhome/src/main/resources/static/json/categoryPro.json | 4 +---
xiaoduhome/src/main/resources/static/json/collect.json | 38 ++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/resources/static/json/collectPage.json | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/resources/static/json/frame.json | 31 +++++++++++++++++++++++++++++++
xiaoduhome/src/main/resources/static/json/history.json | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/resources/static/json/onLunch2.json | 9 +++------
xiaoduhome/src/main/resources/static/json/play.json | 29 ++++++++---------------------
xiaoduhome/src/main/resources/static/json/playUpdate.json | 47 +++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/resources/static/json/productInfo.json | 26 +++++++-------------------
xiaoduhome/src/main/resources/static/json/ranking.json | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/resources/static/json/recommand.json | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
60 files changed, 2836 insertions(+), 694 deletions(-)
delete mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/ServiceUtil.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/Agent.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryDocument.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryMainTemplate.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryPagePojo.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CustomMainTemplateInterface.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/FrameTemple.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/collectIcon.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdateDocument.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdateMainTemplate.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdatePojo.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankBotInfo.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingDocument.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingMainTemplate.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingPojo.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandBotInfo.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandDocument.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandMainTemplate.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandPojo.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryBotIdTime.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryTB.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/OverTimeDetail.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/pageData/HistoryData.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryBotTimeRepository.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryTBRepository.java
create mode 100644 xiaoduhome/src/main/resources/static/json/collect.json
create mode 100644 xiaoduhome/src/main/resources/static/json/collectPage.json
create mode 100644 xiaoduhome/src/main/resources/static/json/frame.json
create mode 100644 xiaoduhome/src/main/resources/static/json/history.json
create mode 100644 xiaoduhome/src/main/resources/static/json/playUpdate.json
create mode 100644 xiaoduhome/src/main/resources/static/json/ranking.json
create mode 100644 xiaoduhome/src/main/resources/static/json/recommand.json
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 8ed4749..a5b3dc8 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,41 +3,31 @@
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
+
+
+
-
-
-
-
+
+
+
-
-
-
+
+
+
+
+
-
+
+
@@ -82,110 +72,68 @@
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
@@ -197,36 +145,13 @@
-
+
- max-lines
- log.info
- flower
- getUserIdByToken
- changeIconIdTextAfterCollect
- system
- log
- specing
- align
- margin-right
- align-items
- CATEGORY_PROD_LIST
- line-height
- hasBackIcon
- productName
- hints
- left
- margin-top
- margin
- secondaryDataSource
- entityManagerFactorySecondary
- padding
- text-overflow
letter
margin-bottom
TTSResponse
@@ -234,6 +159,29 @@
componentId
CallP
AUDIO_DIR
+ log.info
+ log.error
+ scale-type
+ first
+ firstItem
+ letter-spacing
+ line-height
+ version
+ ite
+ border-radius
+ position
+ margin
+ padding
+ bottom
+ code
+ flex-direction
+ data.
+ botAccount
+ productDetail
+ BACK_TRACE
+ directives
+ LAST_OUTTIME_RESULT
+ botAcc
OPENID_CACHE
@@ -249,57 +197,57 @@
@@ -317,15 +265,6 @@
-
-
-
-
-
-
-
-
-
@@ -341,10 +280,10 @@
-
-
+
+
-
+
@@ -355,6 +294,7 @@
+
@@ -365,69 +305,36 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
-
-
+
-
-
-
+
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -435,21 +342,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -459,6 +355,8 @@
+
+
@@ -468,7 +366,7 @@
-
+
@@ -478,8 +376,7 @@
-
-
+
@@ -489,7 +386,8 @@
-
+
+
@@ -500,6 +398,7 @@
+
@@ -519,8 +418,7 @@
-
-
+
@@ -531,6 +429,7 @@
+
@@ -583,7 +482,6 @@
-
@@ -597,7 +495,7 @@
-
+
@@ -649,7 +547,7 @@
-
+
@@ -663,12 +561,12 @@
-
-
+
+
-
+
@@ -689,12 +587,12 @@
-
-
-
+
+
+
-
+
@@ -702,12 +600,12 @@
-
-
+
+
-
+
@@ -1024,11 +922,11 @@
-
-
+
+
-
-
+
+
@@ -1052,11 +950,11 @@
-
-
+
-
+
+
@@ -1132,7 +1030,11 @@
-
+
+
+
+
+
@@ -1142,7 +1044,7 @@
-
+
@@ -1154,10 +1056,9 @@
-
-
+
-
+
@@ -1165,10 +1066,10 @@
-
+
-
-
+
+
@@ -1181,11 +1082,11 @@
-
+
-
+
@@ -1199,432 +1100,397 @@
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java
index 0e06b66..35dadf2 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java
@@ -56,6 +56,7 @@ public class CallPython {
StringBuilder builder = new StringBuilder();
Process process = null;
try {
+ //long startTime = System.currentTimeMillis();
process = processBuilder.start();
process.waitFor();
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
@@ -72,8 +73,11 @@ public class CallPython {
while ((line = reader.readLine()) != null) {
builder.append(line);
}
- log.info("sox返回信息:{}", builder.toString());
+ if (builder.length() != 0){
+ log.info("sox返回信息:{}", builder.toString());
+ }
}
+ //log.info(Thread.currentThread().getName()+"耗时:"+(System.currentTimeMillis()-startTime));
} catch (IOException e) {
log.info("Error while running Sox. {}",e.getMessage());
return "0";
@@ -91,6 +95,7 @@ public class CallPython {
InputStream inputStream = null;
InputStream errorStream = null;
try {
+ long startTime = System.currentTimeMillis();
Process process = Runtime.getRuntime().exec(arg);
inputStream = process.getInputStream();
@@ -137,6 +142,7 @@ public class CallPython {
// }
// }).start();
process.waitFor();
+ log.info(Thread.currentThread().getName()+"耗时:"+(System.currentTimeMillis()-startTime));
process.destroy();
} catch (Exception e) {
log.error("调用sox出错:{}",e.toString());
@@ -187,7 +193,9 @@ public class CallPython {
log.error("读取Process error流出错:{}",e.toString());
}
}).start();
+ long startTime = System.currentTimeMillis();
process.waitFor();
+ log.info(Thread.currentThread().getName()+"耗时:"+(System.currentTimeMillis()-startTime));
process.destroy();
} catch (Exception e) {
try {
@@ -200,9 +208,9 @@ public class CallPython {
log.error("关闭Process的流出错:{}",e1.toString());
}
}
- if (successResult.length() != 0) return successResult.toString();
+ if (successResult.length() == 0) return successResult.toString();
else {
- log.error("打印Process的错误流信息:{}", failResult.toString());
+ log.error("打印Process的错误流信息:fsfs-{}-sfs, successResult:sfd-{}-sgs", failResult.toString(), successResult.toString());
return null;
}
}
@@ -259,4 +267,15 @@ public class CallPython {
}
}
+ public static void main(String[] args) {
+ int i = 7;
+// while (i-- >= 0) {
+// new Thread(() -> processUtilInJava("sleep 3")).start();
+// }
+// i = 7;
+ while (i-- >= 0) {
+ new Thread(() -> execute("sleep 3")).start();
+ }
+ }
+
}
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java
index 2d68e24..8d729de 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java
@@ -71,4 +71,14 @@ public class TTSController {
public ChatBotResponse chatbot(@RequestBody ChatBotRequest request) {
return ttService.chatbot(request);
}
+
+ @PostMapping("/api/update_db_var")
+ public void updateCache(HttpServletResponse response) {
+ try {
+ ttService.updateCache();
+ } catch (Exception e) {
+ response.setStatus(555);
+ }
+ response.setStatus(200);
+ }
}
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 0b4bd25..bdaa716 100644
--- 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
@@ -171,6 +171,7 @@ public class TTService {
for (TextInfo info : infoList) {
// person没有值或是不存在则赋予init_person
String person = info.getPerson();
+ //log.info("person:{}", person);
// text 字段不为空
String text = info.getText();
@@ -678,4 +679,8 @@ public class TTService {
}
return new ResponseCodeWithData(555, "调用第三方生成wav文件失败");
}
+
+ public void updateCache() throws Exception {
+ initialize.afterPropertiesSet();
+ }
}
diff --git a/tts_service/src/main/resources/application.yml b/tts_service/src/main/resources/application.yml
index b80ff80..101a10b 100644
--- a/tts_service/src/main/resources/application.yml
+++ b/tts_service/src/main/resources/application.yml
@@ -19,16 +19,16 @@ spring:
ansi:
enabled: detect
logging:
- #path: /home/ubuntu/project/tts/logs
- path: /root/GameEditor/mqw/project/ttsTest/logs
+ path: /home/ubuntu/project/tts/logs
+ #path: /root/GameEditor/mqw/project/ttsTest/logs
level:
root: info
server:
- #port: 9663
- port: 8188
+ port: 9663
+ #port: 8188
tomcat:
accesslog:
enabled: true
pattern: '%h %l %u %t "%r" %s %b bytes %D ms'
- #directory: /home/ubuntu/project/tts/tomcat
- directory: /root/GameEditor/mqw/project/ttsTest/tomcat
\ No newline at end of file
+ directory: /home/ubuntu/project/tts/tomcat
+ #directory: /root/GameEditor/mqw/project/ttsTest/tomcat
\ No newline at end of file
diff --git a/tts_service/src/main/resources/tts.properties b/tts_service/src/main/resources/tts.properties
index 0e39af0..9ccfad7 100644
--- a/tts_service/src/main/resources/tts.properties
+++ b/tts_service/src/main/resources/tts.properties
@@ -1,9 +1,9 @@
-server_name=hz1
-#server_name=aws-nx2
-#server_url=http://aws-nx2.chewrobot.com:9663
-server_url=http://aliyun-hz1.chewrobot.com:9663
-#audio_dir=/root/TTS-service/audio
-audio_dir=/root/GameEditor/mqw/project/tts/audio
+#server_name=hz1
+server_name=aws-nx2
+server_url=http://aws-nx2.chewrobot.com:9663
+#server_url=http://aliyun-hz1.chewrobot.com:9663
+audio_dir=/root/TTS-service/audio
+#audio_dir=/root/GameEditor/mqw/project/tts/audio
online_sever=http://dev01.centaurstech.com
offline_server=http://dev01.centaurstech.com:9001
#offline_server=http://aliyun-hz1.chewrobot.com:9001
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 75c4932..df589a0 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java
@@ -40,10 +40,11 @@ public interface Constants {
String UN_COLLEC_ID = "colleUn";
String COLLECT_IMAGE_ID = "collectImage";
String COLLECT_TEXT_ID = "collectText";
+ String BACK_TRACE = "trace";
String PRE_CATEGORY = "categ";
- String CLICK_PATTERN = "[{\"type\": \"SendEvent\",\"componentId\":\"%s\"}]";
+ String CLICK_PATTERN = "[{type: SendEvent,componentId:%s}]";
String COLLECTED_IMG_URL = "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/collec.png";
String UN_COLLECTED_IMG_URL = "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/uncollec.png";
@@ -60,6 +61,10 @@ public interface Constants {
String UN_COLLEC = "收藏";
String CHAT_COLLECT = "我要收藏";
String CHAT_UN_COLLECT = "取消收藏";
+ String COLLECT_BOT_WORD = "已为您收藏该作品";
+ String COLLECT_BOT_WORD_MG = "已将%s加入您的收藏";
+ String UN_COLLECT_BOT_WORD = "已将该作品移出您的收藏列表";
+ String UN_COLLECT_BOT_WORD_MG = "已将%s移出您的收藏列表";
}
interface CATEGORY_IMG_URL {
@@ -97,11 +102,14 @@ public interface Constants {
}
interface ErrorMsg {
- String SORRY_UNCATCH = "我好意思我没听清,请再说一遍吧";
+ String SORRY_UNCATCH = "不好意思我没听清,请再说一遍吧";
String INTERNAL_ERROR = "其他DuerOS系统错误";
String INVALID_RESPONSE = "技能返回了无效的响应,可能技能响应数据量超过24KB,或是技能在request的dialogState为COMPLETED时仍然发送Dialog.Delegate指令等";
String DEVICE_COMMUNICATION_ERROR = "DuerOS与端通信异常";
+ String COLLECT_FAIL = "你可以在作品介绍页收藏该作品";
+ String UN_COLLECT_FAIL = "你可以在该作品的介绍页进行取消操作";
+
String INTERFACE_ERROR = "终端接口请求出错";
String HTTP_CONNECTION_CLOSE_FAILED = "与终端的链接关闭错误";
}
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 944cdba..3aee0e1 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java
@@ -1,19 +1,27 @@
package ai.qiwu.com.xiaoduhome.common;
+import lombok.extern.slf4j.Slf4j;
import okhttp3.*;
+import org.jetbrains.annotations.NotNull;
import java.io.File;
import java.io.IOException;
+import java.net.SocketTimeoutException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
/**
* @author 苗权威
* @dateTime 19-7-18 上午10:54
*/
+@Slf4j
public class OkHttp3Utils {
- private static OkHttpClient client = new OkHttpClient();
+ private static final OkHttpClient client = new OkHttpClient.Builder()
+ .connectTimeout(15, TimeUnit.SECONDS)
+ .readTimeout(15, TimeUnit.SECONDS)
+ .build();
public static String doGet(String url) throws IOException {
return doGet(url, new HashMap<>());
@@ -53,19 +61,49 @@ public class OkHttp3Utils {
return doPost(url , new HashMap<>(), new HashMap<>(), file);
}
- public static String doPostJsonStr(String url, Map headers, String requestJsonStr) throws IOException {
+ public static String doPostJsonStr(String url, String requestJsonStr) throws IOException {
Request.Builder builder = new Request.Builder();
Request request = builder.url(url).build();
Headers.Builder headBuilder = request.headers().newBuilder();
+ headBuilder.add("Content-Type", "application/json;charset=utf-8");
- Iterator> headIterator = headers.entrySet().iterator();
- headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
+// Iterator> headIterator = headers.entrySet().iterator();
+// headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
builder.headers(headBuilder.build()).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestJsonStr));
try (Response response = client.newCall(builder.build()).execute()){
return response.body().string();
+ }catch (SocketTimeoutException e) {
+ log.error("捕获到SocketTimeoutException:{}", e.toString());
+ client.dispatcher().cancelAll();
+ client.connectionPool().evictAll();
}
+ return null;
+ }
+
+ public static void backPostAsync(String url, String requestJsonStr) {
+ Request.Builder builder = new Request.Builder();
+// builder.url(url);
+// builder.addHeader("Content-Type", "application/json;charset=utf-8");
+
+ Request request = builder.url(url).build();
+ Headers.Builder headBuilder = request.headers().newBuilder();
+ headBuilder.add("Content-Type", "application/json;charset=utf-8");
+
+ //RequestBody requestBody = FormBody.create(MediaType.parse("application/json; charset=utf-8"), requestJsonStr);
+ builder.post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestJsonStr));
+ client.newCall(builder.build()).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 {
+ log.info("退出成功");
+ }
+ });
}
public static String doPost(String url, Map headers, Map params, File file) throws IOException {
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/ServiceUtil.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/ServiceUtil.java
deleted file mode 100644
index 7450293..0000000
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/ServiceUtil.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package ai.qiwu.com.xiaoduhome.common;
-
-import ai.qiwu.com.xiaoduhome.repository.primary.AppFavoriteTBRepository;
-import ai.qiwu.com.xiaoduhome.repository.primary.AppFlowerTBRepository;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-/**
- * @author 苗权威
- * @dateTime 19-8-19 下午9:19
- */
-@Component
-public class ServiceUtil implements InitializingBean {
-
- private final AppFlowerTBRepository appFlowerTBRepository;
-
- private final AppFavoriteTBRepository appFavoriteTBRepository;
-
- @Autowired
- public ServiceUtil(AppFavoriteTBRepository appFavoriteTBRepository, AppFlowerTBRepository appFlowerTBRepository) {
- this.appFavoriteTBRepository = appFavoriteTBRepository;
- this.appFlowerTBRepository = appFlowerTBRepository;
- }
-
- public void insertAfterBuyFlower(String userId, String botId,
- String baiduOrderReferenceId, String timeStamp) {
- new Thread(() -> appFlowerTBRepository.insertOrder(botId, userId, baiduOrderReferenceId, timeStamp)).start();
- }
-
- public void insertAfterCollect(final String userId, final String botId) {
- //new Thread(() -> appFavoriteTBRepository.insertFavorite(botId, userId)).start();
- }
-
- public void deleteAfterUnCollect(final String userId, final String botId) {
- //new Thread(() -> appFavoriteTBRepository.deleteFavorite(botId, userId)).start();
- }
-
- @Override
- public void afterPropertiesSet() throws Exception {
-
- }
-}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/Agent.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/Agent.java
new file mode 100644
index 0000000..f2c34d3
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/Agent.java
@@ -0,0 +1,10 @@
+package ai.qiwu.com.xiaoduhome.common.temple;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-24 下午3:11
+ */
+public interface Agent {
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryDocument.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryDocument.java
new file mode 100644
index 0000000..ddcb523
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryDocument.java
@@ -0,0 +1,22 @@
+package ai.qiwu.com.xiaoduhome.common.temple;
+
+import com.baidu.dueros.data.response.directive.dpl.Document;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-24 下午5:38
+ */
+@Getter
+@Setter
+@ToString
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class CollectHistoryDocument extends Document{
+ private CollectHistoryMainTemplate mainTemplate;
+ @JsonIgnore
+ private String idToken;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryMainTemplate.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryMainTemplate.java
new file mode 100644
index 0000000..e88e04f
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryMainTemplate.java
@@ -0,0 +1,27 @@
+package ai.qiwu.com.xiaoduhome.common.temple;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-24 下午5:42
+ */
+@Getter
+@Setter
+@ToString
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class CollectHistoryMainTemplate implements CustomMainTemplateInterface{
+ private List parameters = new ArrayList<>();
+ private List items;
+
+ public CollectHistoryMainTemplate() {
+ this.parameters.add("payload");
+ this.items = new ArrayList<>();
+ }
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryPagePojo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryPagePojo.java
new file mode 100644
index 0000000..e8b2c20
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryPagePojo.java
@@ -0,0 +1,53 @@
+package ai.qiwu.com.xiaoduhome.common.temple;
+
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
+import ai.qiwu.com.xiaoduhome.pojo.pageData.HistoryData;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-24 下午4:57
+ */
+@Getter
+@Setter
+@ToString
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class CollectHistoryPagePojo {
+ private String type;
+ private String position;
+ private String left;
+ private String width;
+ private String height;
+ private String src;
+ private String top;
+ private String headerImage;
+ private String headerTitle;
+ @JsonProperty("margin-left")
+ private String marginLeft;
+ @JsonProperty("margin-top")
+ private String marginTop;
+ private String padding;
+ private List items;
+ private String direction;
+ @JsonProperty("font-size")
+ private String fontSize;
+ @JsonProperty("flex-direction")
+ private String flexDirection;
+ private String text;
+ @JsonProperty("border-radius")
+ private String borderRadius;
+ private List data;
+ @JsonProperty("text-overflow")
+ private String textOverflow;
+ @JsonProperty("max-lines")
+ private Integer maxLines;
+ private List onClick;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CustomMainTemplateInterface.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CustomMainTemplateInterface.java
new file mode 100644
index 0000000..5decbfc
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CustomMainTemplateInterface.java
@@ -0,0 +1,8 @@
+package ai.qiwu.com.xiaoduhome.common.temple;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-24 下午5:41
+ */
+public interface CustomMainTemplateInterface {
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/FrameTemple.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/FrameTemple.java
new file mode 100644
index 0000000..1b32a0e
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/FrameTemple.java
@@ -0,0 +1,53 @@
+package ai.qiwu.com.xiaoduhome.common.temple;
+
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Item;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-24 下午2:54
+ */
+@Getter
+@Setter
+@ToString
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class FrameTemple implements Agent{
+ private String type;
+ @JsonProperty("flex-direction")
+ private String flexDirection;
+ private List items;
+ private String text;
+ @JsonProperty("font-size")
+ private String fontSize;
+ @JsonProperty("margin-left")
+ private String marginLeft;
+ @JsonProperty("margin-bottom")
+ private String marginBottom;
+ private String width;
+ private String height;
+ @JsonProperty("border-width")
+ private String borderWidth;
+ @JsonProperty("border-top-left-radius")
+ private String borderTopLeftRadius;
+ @JsonProperty("border-top-right-radius")
+ private String borderTopRightRadius;
+ @JsonProperty("border-bottom-right-radius")
+ private String borderBottomRightRadius;
+ @JsonProperty("padding-vertical")
+ private String paddingVertical;
+ @JsonProperty("padding-horizontal")
+ private String paddingHorizontal;
+ @JsonProperty("border-color")
+ private String borderColor;
+ @JsonProperty("background-color")
+ private String backgroundColor;
+ private String color;
+}
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
new file mode 100644
index 0000000..088db81
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
@@ -0,0 +1,235 @@
+package ai.qiwu.com.xiaoduhome.common.temple;
+
+import ai.qiwu.com.xiaoduhome.common.BaseHolder;
+import ai.qiwu.com.xiaoduhome.common.Constants;
+import ai.qiwu.com.xiaoduhome.common.temple.playUpdate.PlayUpdateDocument;
+import ai.qiwu.com.xiaoduhome.common.temple.playUpdate.PlayUpdatePojo;
+import ai.qiwu.com.xiaoduhome.common.temple.rank.RankBotInfo;
+import ai.qiwu.com.xiaoduhome.common.temple.rank.RankingDocument;
+import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandBotInfo;
+import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandDocument;
+import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
+import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
+import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryBotIdTime;
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Item;
+import ai.qiwu.com.xiaoduhome.pojo.dpl.MyDocument;
+import ai.qiwu.com.xiaoduhome.pojo.pageData.HistoryData;
+import ai.qiwu.com.xiaoduhome.repository.primary.AppFavoriteTBRepository;
+import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryBotTimeRepository;
+import ai.qiwu.com.xiaoduhome.service.ScheduleService;
+import com.alibaba.fastjson.JSON;
+import com.baidu.dueros.data.response.directive.dpl.Document;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Component;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-24 下午2:03
+ */
+@Slf4j
+@Component
+public class TempleUtils {
+ private static FrameTemple FRAME_RAKKING;
+ private static FrameTemple FRAME_RECOMMAND;
+ private static FrameTemple FRAME_CATEGORY;
+ private static RankingDocument RANKING_DOCUMENT;
+
+ static {
+ FRAME_RAKKING = JSON.parseObject(getDPLTemple("static/json/frame.json"), FrameTemple.class);
+ FRAME_RAKKING.getItems().get(1).getItems().get(0).setText("小度小度,打开排行榜");
+ FRAME_RECOMMAND = JSON.parseObject(getDPLTemple("static/json/frame.json"), FrameTemple.class);
+ FRAME_RECOMMAND.getItems().get(1).getItems().get(0).setText("小度小度,打开推荐");
+ FRAME_CATEGORY = JSON.parseObject(getDPLTemple("static/json/frame.json"), FrameTemple.class);
+ FRAME_CATEGORY.getItems().get(1).getItems().get(0).setText("小度小度,打开古风");
+ }
+
+ public static PlayUpdateDocument getPlayUpdate(String audio, String text) {
+ PlayUpdateDocument document = JSON.parseObject(getDPLTemple("static/json/playUpdate.json"), PlayUpdateDocument.class);
+ List whole = document.getMainTemplate().getItems().get(0).getItems();
+ whole.get(0).getItems().get(0).setText(text);
+ whole.get(1).setSrc(audio);
+ return document;
+ }
+
+ public static RankingDocument getRanking() {
+ if (RANKING_DOCUMENT != null) {
+ return RANKING_DOCUMENT;
+ }
+ RANKING_DOCUMENT = JSON.parseObject(getDPLTemple("static/json/ranking.json"), RankingDocument.class);
+ List datas = new ArrayList<>();
+ StringBuilder botIds = new StringBuilder();
+ for (GameProjectTb bot:ScheduleService.getRankingList()) {
+ 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();
+ RankBotInfo rankBotInfo = new RankBotInfo(imgSrc, imageId, correctName(bot.getName()));
+ datas.add(rankBotInfo);
+ }
+ if (botIds.length() != 0) {
+ botIds.deleteCharAt(botIds.length()-1);
+ String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
+ RANKING_DOCUMENT.setRankBotIds(idToken);
+ }
+ RANKING_DOCUMENT.getMainTemplate().getItems().get(0).getItems().get(2).getItems().get(0).setData(datas);
+ return RANKING_DOCUMENT;
+ }
+
+ public static RecommandDocument getRecommend() {
+ RecommandDocument document = JSON.parseObject(getDPLTemple("static/json/recommand.json"), RecommandDocument.class);
+ List datas = new ArrayList<>();
+ StringBuilder botIds = new StringBuilder();
+ for (GameProjectTb bot:ScheduleService.getRecommendList()) {
+ 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 recommend = new RecommandBotInfo(imgSrc, imageId, correctName(bot.getName()));
+ datas.add(recommend);
+ }
+ if (botIds.length() != 0) {
+ botIds.deleteCharAt(botIds.length()-1);
+ String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
+ document.setRecommendIdList(idToken);
+ }
+ document.getMainTemplate().getItems().get(0).getItems().get(2).getItems().get(0).setData(datas);
+ return document;
+ }
+
+ public static CollectHistoryDocument getHistory(String userId) {
+ CollectHistoryDocument historyDocument = JSON.parseObject(getDPLTemple("static/json/history.json"), CollectHistoryDocument.class);
+ XiaoDuHistoryBotTimeRepository historyTBRepository = BaseHolder.getBean("xiaoDuHistoryBotTimeRepository");
+ List historyProInfo = historyTBRepository.getByXiaoduUserId(userId);
+ ArrayList projectInfoList = new ArrayList<>();
+ int i = 1;
+ final StringBuilder build = new StringBuilder();
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ for (XiaoDuHistoryBotIdTime historyInfo: historyProInfo) {
+ String botAccount = historyInfo.getBotId();
+ build.append(botAccount).append(File.separator);
+ OnProductDetail productDetail = ScheduleService.getProductIdDetail().get(botAccount);
+
+ String intro = productDetail.getIntro();
+ if (StringUtils.isBlank(intro)) intro = "作者太懒没写介绍";
+ String imgUrl = new StringBuilder(Constants.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);
+ data.setLastTime(lastTime);
+ projectInfoList.add(data);
+ }
+ String idToken;
+ if (build.length() != 0) {
+ build.deleteCharAt(build.length()-1);
+ idToken = Base64.getEncoder().encodeToString(build.toString().getBytes());
+ historyDocument.setIdToken(idToken);
+ }
+ CollectHistoryMainTemplate collectHistoryMainTemplate = historyDocument.getMainTemplate();
+ collectHistoryMainTemplate.getItems().get(2).getItems().get(0).setData(projectInfoList);
+ return historyDocument;
+ }
+
+ public static CollectHistoryDocument getCollectPage(Integer userId) {
+ CollectHistoryDocument collectHistoryDocument = JSON.parseObject(getDPLTemple("static/json/collectPage.json"), CollectHistoryDocument.class);
+ AppFavoriteTBRepository favorite = BaseHolder.getBean("appFavoriteTBRepository");
+ List favoriteProducts = favorite.getFavoriteBotIds(userId);
+ ArrayList projectInfoList = new ArrayList<>();
+ int i = 1;
+ log.info("id list:{}", favoriteProducts);
+ final StringBuilder build = new StringBuilder();
+ for (String botAccount :favoriteProducts) {
+ build.append(botAccount).append(File.separator);
+ OnProductDetail productDetail = ScheduleService.getProductIdDetail().get(botAccount);
+
+ String intro = productDetail.getIntro();
+ if (StringUtils.isBlank(intro)) intro = "作者太懒没写介绍";
+ String imgUrl = new StringBuilder(Constants.IMG_PREFIX).append(productDetail.getBannerImgUrl()).toString();
+ String botAccountId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(correctName(productDetail.getName())).toString();
+ String name = productDetail.getName();
+ HistoryData data = new HistoryData(botAccountId, i++, imgUrl, correctName(name), intro);
+ data.setAuthorName(productDetail.getAuthorName());
+ projectInfoList.add(data);
+ }
+ String idToken;
+ if (build.length() != 0) {
+ build.deleteCharAt(build.length()-1);
+ idToken = Base64.getEncoder().encodeToString(build.toString().getBytes());
+ collectHistoryDocument.setIdToken(idToken);
+ }
+ CollectHistoryMainTemplate collectHistoryMainTemplate = collectHistoryDocument.getMainTemplate();
+ collectHistoryMainTemplate.getItems().get(2).getItems().get(0).setData(projectInfoList);
+ return collectHistoryDocument;
+ }
+
+ private static MyDocument buildCollectTemple() {
+ return JSON.parseObject(getDPLTemple("static/json/collect.json"), MyDocument.class);
+ }
+
+ public static MyDocument getCollectIcon(String componentId, String imgSrc, String txt) {
+ MyDocument collect = buildCollectTemple();
+ Item container = collect.getMainTemplate().getItems().get(0);
+ container.setComponentId(componentId);
+ container.getOnClick().get(0).setComponentId(componentId);
+ Item image = container.getItems().get(0);
+ image.setSrc(imgSrc);
+ Item text = container.getItems().get(1);
+ text.setText(txt);
+ return collect;
+ }
+
+ private static String correctName(String name) {
+ int brace = name.indexOf("{");
+ if (brace != -1) name = name.substring(0, brace);
+ return name;
+ }
+
+ private static String getDPLTemple(String path) {
+ String temple = null;
+ try {
+ temple = getJsonFromName(path);
+ } catch (IOException e) {
+ log.error("没有获取到json字符串:{}", e.toString());
+ }
+ return temple;
+ }
+
+ private static String getJsonFromName(String filename) throws IOException {
+ InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename);
+ InputStreamReader reader = new InputStreamReader(inputStream);
+ char[] buffer = new char[512];
+ int ln;
+ StringBuilder builder = new StringBuilder();
+ while ((ln = reader.read(buffer)) != -1) {
+ builder.append(buffer, 0, ln);
+ }
+ return builder.toString();
+ }
+
+ public static FrameTemple getFrameRakking() {
+ return FRAME_RAKKING;
+ }
+
+ public static FrameTemple getFrameRecommand() {
+ return FRAME_RECOMMAND;
+ }
+
+ public static FrameTemple getFrameCategory() {
+ return FRAME_CATEGORY;
+ }
+
+ public static void main(String[] args) {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+ System.out.println(sdf.format(new java.sql.Date(1566887509312L)));
+ }
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/collectIcon.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/collectIcon.java
new file mode 100644
index 0000000..22f73fb
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/collectIcon.java
@@ -0,0 +1,49 @@
+package ai.qiwu.com.xiaoduhome.common.temple;
+
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Data;
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Item;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-24 下午1:57
+ */
+@Getter
+@Setter
+@ToString
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class collectIcon {
+ private String type;
+ private String width;
+ private String height;
+ private String src;
+ @JsonProperty("scale-type")
+ private String scaleType;
+ private String text;
+ @JsonProperty("margin-left")
+ private String marginLeft;
+ @JsonProperty("align-items")
+ private String alignItems;
+ @JsonProperty("justify-content")
+ private String justify;
+ private List onClick;
+ private List- items;
+ @JsonProperty("margin-bottom")
+ private String marginBo;
+ private String componentId;
+ @JsonProperty("margin-top")
+ private String marginTop;
+ @JsonProperty("font-size")
+ private String fontSize;
+ @JsonProperty("letter-spacing")
+ private String LetterSpace;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdateDocument.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdateDocument.java
new file mode 100644
index 0000000..9b32036
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdateDocument.java
@@ -0,0 +1,15 @@
+package ai.qiwu.com.xiaoduhome.common.temple.playUpdate;
+
+import com.baidu.dueros.data.response.directive.dpl.Document;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-28 下午6:39
+ */
+@Data
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class PlayUpdateDocument extends Document {
+ private PlayUpdateMainTemplate mainTemplate;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdateMainTemplate.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdateMainTemplate.java
new file mode 100644
index 0000000..b1f0967
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdateMainTemplate.java
@@ -0,0 +1,24 @@
+package ai.qiwu.com.xiaoduhome.common.temple.playUpdate;
+
+import ai.qiwu.com.xiaoduhome.common.temple.rank.RankingPojo;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-28 下午6:38
+ */
+@Data
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class PlayUpdateMainTemplate {
+ private List parameters = new ArrayList<>();
+ private List items;
+
+ public PlayUpdateMainTemplate() {
+ this.parameters.add("payload");
+ this.items = new ArrayList<>();
+ }
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdatePojo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdatePojo.java
new file mode 100644
index 0000000..010ccc2
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/playUpdate/PlayUpdatePojo.java
@@ -0,0 +1,38 @@
+package ai.qiwu.com.xiaoduhome.common.temple.playUpdate;
+
+import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandBotInfo;
+import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandPojo;
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-28 下午6:31
+ */
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class PlayUpdatePojo {
+ private String type;
+ private String height;
+ private String width;
+ private String componentId;
+ private List items;
+ private String padding;
+ private String position;
+ private String bottom;
+ private String text;
+ @JsonProperty("font-size")
+ private String fontSize;
+ @JsonProperty("font-style")
+ private String fontStyle;
+ private String looping;
+ private String autoplay;
+ private String src;
+ private List onEnd;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankBotInfo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankBotInfo.java
new file mode 100644
index 0000000..db8bd98
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankBotInfo.java
@@ -0,0 +1,20 @@
+package ai.qiwu.com.xiaoduhome.common.temple.rank;
+
+import lombok.Data;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 上午10:35
+ */
+@Data
+public class RankBotInfo {
+ private String imageSrc;
+ private String imageId;
+ private String imageName;
+
+ public RankBotInfo(String imageSrc, String imageId, String imageName) {
+ this.imageSrc = imageSrc;
+ this.imageId = imageId;
+ this.imageName = imageName;
+ }
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingDocument.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingDocument.java
new file mode 100644
index 0000000..f5229c4
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingDocument.java
@@ -0,0 +1,24 @@
+package ai.qiwu.com.xiaoduhome.common.temple.rank;
+
+import com.baidu.dueros.data.response.directive.dpl.Document;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 上午10:23
+ */
+@Getter
+@Setter
+@ToString
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class RankingDocument extends Document {
+ private RankingMainTemplate mainTemplate;
+
+ @JsonIgnore
+ private String rankBotIds;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingMainTemplate.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingMainTemplate.java
new file mode 100644
index 0000000..9714b45
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingMainTemplate.java
@@ -0,0 +1,23 @@
+package ai.qiwu.com.xiaoduhome.common.temple.rank;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 上午10:21
+ */
+@Data
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class RankingMainTemplate {
+ private List parameters = new ArrayList<>();
+ private List items;
+
+ public RankingMainTemplate() {
+ this.parameters.add("payload");
+ this.items = new ArrayList<>();
+ }
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingPojo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingPojo.java
new file mode 100644
index 0000000..6667fa0
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankingPojo.java
@@ -0,0 +1,52 @@
+package ai.qiwu.com.xiaoduhome.common.temple.rank;
+
+import ai.qiwu.com.xiaoduhome.common.temple.CollectHistoryPagePojo;
+import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandBotInfo;
+import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 上午10:13
+ */
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class RankingPojo {
+ private String type;
+ private String height;
+ private String width;
+ private List items;
+ private String position;
+ private String top;
+ private String left;
+ private String src;
+ private String headerImage;
+ private String headerTitle;
+ private Boolean hasBackIcon;
+ private String componentId;
+ @JsonProperty("margin-top")
+ private String marginTop;
+ private String direction;
+ @JsonProperty("align-items")
+ private String alignItems;
+ @JsonProperty("margin-left")
+ private String marginLeft;
+ @JsonProperty("scale-type")
+ private String scaleType;
+ @JsonProperty("border-radius")
+ private String borderRadius;
+ private List onClick;
+ @JsonProperty("font-size")
+ private String fontSize;
+ private String text;
+ private String bottom;
+ private List hints;
+ private List data;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandBotInfo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandBotInfo.java
new file mode 100644
index 0000000..f457522
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandBotInfo.java
@@ -0,0 +1,20 @@
+package ai.qiwu.com.xiaoduhome.common.temple.recommand;
+
+import lombok.Data;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 上午10:52
+ */
+@Data
+public class RecommandBotInfo {
+ private String imageSrc;
+ private String imageId;
+ private String imageName;
+
+ public RecommandBotInfo(String imageSrc, String imageId, String imageName) {
+ this.imageSrc = imageSrc;
+ this.imageId = imageId;
+ this.imageName = imageName;
+ }
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandDocument.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandDocument.java
new file mode 100644
index 0000000..13cb872
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandDocument.java
@@ -0,0 +1,23 @@
+package ai.qiwu.com.xiaoduhome.common.temple.recommand;
+
+import com.baidu.dueros.data.response.directive.dpl.Document;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 上午10:50
+ */
+@Getter
+@Setter
+@ToString
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class RecommandDocument extends Document {
+ private RecommandMainTemplate mainTemplate;
+
+ @JsonIgnore
+ private String recommendIdList;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandMainTemplate.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandMainTemplate.java
new file mode 100644
index 0000000..9feca44
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandMainTemplate.java
@@ -0,0 +1,23 @@
+package ai.qiwu.com.xiaoduhome.common.temple.recommand;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 上午10:49
+ */
+@Data
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class RecommandMainTemplate {
+ private List parameters = new ArrayList<>();
+ private List items;
+
+ public RecommandMainTemplate() {
+ this.parameters.add("payload");
+ this.items = new ArrayList<>();
+ }
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandPojo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandPojo.java
new file mode 100644
index 0000000..1d30abf
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommandPojo.java
@@ -0,0 +1,51 @@
+package ai.qiwu.com.xiaoduhome.common.temple.recommand;
+
+import ai.qiwu.com.xiaoduhome.common.temple.rank.RankBotInfo;
+import ai.qiwu.com.xiaoduhome.common.temple.rank.RankingPojo;
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 上午10:48
+ */
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class RecommandPojo {
+ private String type;
+ private String height;
+ private String width;
+ private List items;
+ private String position;
+ private String top;
+ private String left;
+ private String src;
+ private String headerImage;
+ private String headerTitle;
+ private Boolean hasBackIcon;
+ private String componentId;
+ @JsonProperty("margin-top")
+ private String marginTop;
+ private String direction;
+ @JsonProperty("align-items")
+ private String alignItems;
+ @JsonProperty("margin-left")
+ private String marginLeft;
+ @JsonProperty("scale-type")
+ private String scaleType;
+ @JsonProperty("border-radius")
+ private String borderRadius;
+ private List onClick;
+ @JsonProperty("font-size")
+ private String fontSize;
+ private String text;
+ private String bottom;
+ private List hints;
+ private List data;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/Oauth2Controller.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/Oauth2Controller.java
index 0a871c1..a68e818 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/Oauth2Controller.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/Oauth2Controller.java
@@ -143,7 +143,7 @@ public class Oauth2Controller {
*/
@RequestMapping("/accessToken")
public @ResponseBody TokenDuerosResponse returnTokenToDueros(@RequestParam String grant_type,
- @RequestParam String code, @RequestParam String client_id,
+ @RequestParam(required = false) String code, @RequestParam String client_id,
@RequestParam String client_secret, @RequestParam String redirect_uri) {
log.info("小度请求Token,client_id:{};client_secret:{};redirect_uri:{};code:{}",
client_id, client_secret, redirect_uri, code);
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 c72a107..f6f99b3 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.File;
+import java.util.Map;
/**
* @author 苗权威
@@ -21,6 +22,7 @@ public class XiaoDuHomeController {
@RequestMapping("/xiaoduhome/chat")
public String chat() {
try {
+ log.info("--------------分界线-------------------");
DplBotService service = new DplBotService(Utils.getHttpServletRequest());
log.info("请求信息中的attributes:{}", service.getRequest().getSession().getAttributes());
//service.disableVerify();
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/GameProjectTb.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/GameProjectTb.java
index f226968..e2f9334 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/GameProjectTb.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/GameProjectTb.java
@@ -35,4 +35,10 @@ public class GameProjectTb {
@Column(name = "apply_status")
private Integer applyStatus;
+
+ @Column(name = "bot_account")
+ private String botAccount;
+
+ @Column(name = "user_nickname")
+ private String authorName;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/OnProductDetail.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/OnProductDetail.java
index dccfe82..b9418f3 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/OnProductDetail.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/OnProductDetail.java
@@ -43,8 +43,8 @@ public class OnProductDetail {
@Column(name = "user_nickname")
private String authorName;
- @Column(name = "bot_id")
- private Integer botId;
+ @Column(name = "bot_account")
+ private String botAccount;
@Transient
private List labels;
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryBotIdTime.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryBotIdTime.java
new file mode 100644
index 0000000..780663d
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryBotIdTime.java
@@ -0,0 +1,28 @@
+package ai.qiwu.com.xiaoduhome.entity.secondary;
+
+import lombok.Data;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 下午5:28
+ */
+@Entity
+@Table(name = "xiaodu_history_tb")
+@Data
+public class XiaoDuHistoryBotIdTime {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ @Column(name = "bot_id")
+ private String botId;
+
+ @Column(name = "last_time")
+ private Long lastTime;
+
+ @Column(name = "xiaodu_user_id")
+ private String xiaoduUserId;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryTB.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryTB.java
new file mode 100644
index 0000000..187fe78
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryTB.java
@@ -0,0 +1,40 @@
+package ai.qiwu.com.xiaoduhome.entity.secondary;
+
+import lombok.Data;
+import org.springframework.data.annotation.CreatedDate;
+import org.springframework.data.annotation.LastModifiedDate;
+import org.springframework.data.jpa.domain.support.AuditingEntityListener;
+
+import javax.persistence.*;
+import java.util.Date;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-26 下午2:19
+ */
+@Entity
+@EntityListeners(AuditingEntityListener.class)
+@Table(name = "xiaodu_history_tb")
+@Data
+public class XiaoDuHistoryTB {
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ private Integer id;
+
+ @Column(name = "bot_id")
+ private String botId;
+
+ @Column(name = "xiaodu_user_id")
+ private String xiaoduUserId;
+
+ @Column(name = "last_time")
+ private Long lastTime;
+
+ @CreatedDate
+ @Column(name = "create_time",nullable = false,updatable = false)
+ private Date createTime;
+
+ @Column(name = "update_time")
+ @LastModifiedDate
+ private Date updateTime;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/OverTimeDetail.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/OverTimeDetail.java
new file mode 100644
index 0000000..cd3894b
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/OverTimeDetail.java
@@ -0,0 +1,21 @@
+package ai.qiwu.com.xiaoduhome.pojo;
+
+import com.baidu.dueros.data.response.directive.Directive;
+import com.baidu.dueros.model.Response;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-28 下午3:22
+ */
+@Data
+public class OverTimeDetail {
+ private final List directives = new ArrayList<>();
+ private final Map attributes = new HashMap<>();
+ private Response response = new Response();
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/QiWuResponse.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/QiWuResponse.java
index 6002807..241c4a1 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/QiWuResponse.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/QiWuResponse.java
@@ -13,4 +13,5 @@ public class QiWuResponse {
private String audio;
private String text;
private String length;
+ private String aipioneerUsername;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Item.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Item.java
index 329dab9..7ec1ee4 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Item.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Item.java
@@ -1,5 +1,6 @@
package ai.qiwu.com.xiaoduhome.pojo.dpl;
+import ai.qiwu.com.xiaoduhome.common.temple.Agent;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@@ -18,7 +19,7 @@ import java.util.List;
@ToString
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
-public class Item {
+public class Item implements Agent {
private Integer duration;
private String type;
private String width;
@@ -27,18 +28,19 @@ public class Item {
@JsonProperty("scale-type")
private String scaleType;
@JsonProperty("border-bottom-right-radius")
- private String borderBrr;
+ private String borderBottomRightRadius;
private Double opacity;
private String text;
@JsonProperty("line-height")
private String lineHeight;
@JsonProperty("letter-spacing")
- private String LetterSpace;
+ private String LetterSpacing;
private String color;
@JsonProperty("padding-left")
private String paddingLeft;
@JsonProperty("padding-right")
private String paddingRight;
+ private String padding;
@JsonProperty("margin-left")
private String marginLeft;
@JsonProperty("margin-right")
@@ -46,7 +48,7 @@ public class Item {
@JsonProperty("margin-top")
private String marginTop;
@JsonProperty("margin-bottom")
- private String marginBo;
+ private String marginBottom;
private Boolean looping;
private Boolean autoPlay;
private String audioType;
@@ -91,7 +93,9 @@ public class Item {
@JsonProperty("align-items")
private String alignItems;
@JsonProperty("justify-content")
- private String justify;
+ private String justifyContent;
@JsonProperty("text-overflow")
- private String overflow;
+ private String textOverflow;
+
+ private List firstItem;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/MyMainTemplate.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/MyMainTemplate.java
index 1e61197..fbefb48 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/MyMainTemplate.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/MyMainTemplate.java
@@ -1,5 +1,7 @@
package ai.qiwu.com.xiaoduhome.pojo.dpl;
+import ai.qiwu.com.xiaoduhome.common.temple.Agent;
+import ai.qiwu.com.xiaoduhome.common.temple.CustomMainTemplateInterface;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -14,7 +16,7 @@ import java.util.List;
@Getter
@Setter
@ToString
-public class MyMainTemplate {
+public class MyMainTemplate implements CustomMainTemplateInterface {
private List parameters = new ArrayList<>();
private List
- items;
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/pageData/HistoryData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/pageData/HistoryData.java
new file mode 100644
index 0000000..d9c0379
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/pageData/HistoryData.java
@@ -0,0 +1,32 @@
+package ai.qiwu.com.xiaoduhome.pojo.pageData;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 下午6:02
+ */
+@Data
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class HistoryData {
+ private String botAccountId;
+ private Integer collectPageLeftNum;
+ private String bannerImgUrl;
+ private String name;
+ private String intro;
+ private String lastTime;
+ private String authorName;
+
+ public HistoryData() {
+ }
+
+ public HistoryData(String botAccountId, Integer collectPageLeftNum,
+ String bannerImgUrl, String name, String intro) {
+ this.botAccountId = botAccountId;
+ this.collectPageLeftNum = collectPageLeftNum;
+ this.bannerImgUrl = bannerImgUrl;
+ this.name = name;
+ this.intro = intro;
+ }
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFavoriteTBRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFavoriteTBRepository.java
index 8cc9c06..195dd5a 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFavoriteTBRepository.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFavoriteTBRepository.java
@@ -7,6 +7,8 @@ import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
+import java.util.List;
+
/**
* @author 苗权威
* @dateTime 19-8-21 下午4:04
@@ -31,4 +33,10 @@ public interface AppFavoriteTBRepository extends JpaRepository getFavoriteBotIds(Integer userId);
+
+ @Override
+
long count(Example example);
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java
index 8dcc5c4..a2e97d0 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java
@@ -17,9 +17,11 @@ public interface GameProjectTbRepository extends JpaRepository findFirst15ByApplyStatusOrderByWatchDesc(Integer applyStatus);
- @Query(value = "select id,intro,name,watch,banner_img_url,apply_status from game_project_tb where apply_status = 1 and id >= (select floor(RAND()*(select MAX(id) from game_project_tb))) order by id limit 10", nativeQuery = true)
+ @Query(value = "select id,intro,name,watch,banner_img_url,apply_status,bot_account,user_nickname from game_project_tb where apply_status = 1 and id >= (select floor(RAND()*(select MAX(id) from game_project_tb))) order by id limit 10", nativeQuery = true)
List recommendList();
- @Query(value = "select p.id,p.intro,p.name,p.watch,p.banner_img_url,p.apply_status from game_project_tb as p,game_project_label_tb as l where l.name= :category and p.id = l.project_id and p.apply_status=1", nativeQuery = true)
+ @Query(value = "select p.id,p.intro,p.name,p.watch,p.banner_img_url,p.apply_status,p.bot_account,p.user_nickname from game_project_tb as p,game_project_label_tb as l where l.name= :category and p.id = l.project_id and p.apply_status=1", nativeQuery = true)
List categoryProject(@Param("category") String category);
+
+ GameProjectTb getByBotAccount(String botAccount);
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryBotTimeRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryBotTimeRepository.java
new file mode 100644
index 0000000..b1a24c4
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryBotTimeRepository.java
@@ -0,0 +1,14 @@
+package ai.qiwu.com.xiaoduhome.repository.secondary;
+
+import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryBotIdTime;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-27 下午5:30
+ */
+public interface XiaoDuHistoryBotTimeRepository extends JpaRepository {
+ List getByXiaoduUserId(String xiaoduUserId);
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryTBRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryTBRepository.java
new file mode 100644
index 0000000..9263162
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryTBRepository.java
@@ -0,0 +1,34 @@
+package ai.qiwu.com.xiaoduhome.repository.secondary;
+
+import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryTB;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-26 下午2:21
+ */
+public interface XiaoDuHistoryTBRepository extends JpaRepository {
+ @Query(value = "SELECT bot_id FROM xiaodu_history_tb WHERE xiaodu_user_id=?1 ORDER BY last_time LIMIT 15", nativeQuery = true)
+ List getHistory(String xiaoduUserId);
+
+ @Query(value = "SELECT DISTINCT xiaodu_user_id FROM xiaodu_history_tb", nativeQuery = true)
+ List getAllUser();
+
+ @Transactional
+ @Query(value = "delete from xiaodu_history_tb where xiaodu_user_id=?1 and last_time < (select last_time from xiaodu_history_tb where xiaodu_user_id=?1 order by last_time limit 14,1)", nativeQuery = true)
+ void deleteOverTime(String userId);
+
+ @Transactional
+ @Query(value = "delete from xiaodu_history_tb where last_time 1", nativeQuery = true)
+ void deletePasted(Long boundTime);
+
+ @Transactional
+ @Override
+ S save(S s);
+
+ XiaoDuHistoryTB getByXiaoduUserIdAndBotId(String xiaoduUserId, String botId);
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTBIdRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTBIdRepository.java
index 1165bab..94072ec 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTBIdRepository.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTBIdRepository.java
@@ -9,7 +9,6 @@ import org.springframework.transaction.annotation.Transactional;
* @author 苗权威
* @dateTime 19-8-22 下午4:28
*/
-@Repository(value = "xiaoDuOrderTBIdRepository")
public interface XiaoDuOrderTBIdRepository extends JpaRepository {
XiaoDuOrderIdTB getByXiaoduUserIdAndBotIdAndUnitPrice(String xiaoduUserId, String botId, Integer unitPrice);
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 e208be4..373ee47 100644
--- 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
@@ -10,7 +10,6 @@ import org.springframework.transaction.annotation.Transactional;
* @author 苗权威
* @dateTime 19-8-22 下午3:59
*/
-@Repository(value = "xiaoDuOrderTbRepository")
public interface XiaoDuOrderTbRepository extends JpaRepository {
@Override
boolean exists(Example example);
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java
index 4b4b780..d44cd64 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java
@@ -1,7 +1,13 @@
package ai.qiwu.com.xiaoduhome.service;
import ai.qiwu.com.xiaoduhome.common.*;
+import ai.qiwu.com.xiaoduhome.common.temple.Agent;
+import ai.qiwu.com.xiaoduhome.common.temple.CollectHistoryDocument;
+import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils;
+import ai.qiwu.com.xiaoduhome.common.temple.rank.RankingDocument;
+import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandDocument;
import ai.qiwu.com.xiaoduhome.entity.primary.*;
+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.dpl.Data;
@@ -10,17 +16,21 @@ import ai.qiwu.com.xiaoduhome.pojo.dpl.MyDocument;
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.XiaoDuHistoryTBRepository;
import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuOrderTbRepository;
import com.alibaba.fastjson.JSON;
import com.baidu.dueros.bot.BaseBot;
import com.baidu.dueros.data.request.IntentRequest;
import com.baidu.dueros.data.request.LaunchRequest;
import com.baidu.dueros.data.request.Query;
+import com.baidu.dueros.data.request.SessionEndedRequest;
import com.baidu.dueros.data.request.buy.event.BuyEvent;
import com.baidu.dueros.data.request.events.LinkAccountSucceededEvent;
import com.baidu.dueros.data.response.OutputSpeech;
import com.baidu.dueros.data.response.card.Card;
import com.baidu.dueros.data.response.card.LinkAccountCard;
+import com.baidu.dueros.data.response.directive.Directive;
+import com.baidu.dueros.data.response.directive.ElicitSlot;
import com.baidu.dueros.data.response.directive.display.Hint;
import com.baidu.dueros.data.response.directive.display.PushStack;
import com.baidu.dueros.data.response.directive.dpl.ExecuteCommands;
@@ -29,19 +39,21 @@ import com.baidu.dueros.data.response.directive.dpl.commands.*;
import com.baidu.dueros.data.response.directive.dpl.event.UserEvent;
import com.baidu.dueros.data.response.directive.pay.Buy;
import com.baidu.dueros.model.Response;
+import com.baidu.dueros.nlu.ConfirmationStatus;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Example;
-import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.CATEGORY_IMG_URL.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.DPL_COMPONENT_ID.*;
+import static ai.qiwu.com.xiaoduhome.common.Constants.ErrorMsg.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.LOAD_INTRO;
import static ai.qiwu.com.xiaoduhome.common.Constants.PRODUCT_INTRO.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.REWARD_FLOWER;
@@ -69,17 +81,33 @@ public class DplBotService extends BaseBot {
private static final Item CATEGORY_PROD_LIST;
private static final Item CATEGORY_PROD_HEAD;
+ private static final int CORE = Runtime.getRuntime().availableProcessors();
+
+ private static final ThreadPoolExecutor POOL = new ThreadPoolExecutor(CORE+1, 1500,
+ 2500, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(CORE), new ThreadPoolExecutor.CallerRunsPolicy());
+
private static final ConcurrentHashMap DU_ID_2_US_ID;
- private static final String[] PRODUCT_INFO_HINTS = {"打开下一个","打开推荐作品","收藏作品","打开排行榜"};
- private static final Hint PRODUCT_INFO_HINT;
+ private static final ConcurrentHashMap LAST_OUTTIME_RESULT = new ConcurrentHashMap<>();
static {
PLAY_DOCUMENT = JSON.parseObject(getDPLTemple("static/json/play.json"), MyDocument.class);
+
LOAD_DOCUMENT = JSON.parseObject(getDPLTemple("static/json/onLunch2.json"), MyDocument.class);
List- thirdRow = LOAD_DOCUMENT.getMainTemplate().getItems().get(1).getItems().get(1).getItems();
+ List l1 = new ArrayList<>();
+ l1.add(TempleUtils.getFrameRakking());
+ thirdRow.get(0).setFirstItem(l1);
thirdRow.get(0).getItems().get(0).setData(buildDataList(ScheduleService.RANKING_LIST));
+
+ List l2 = new ArrayList<>();
+ l2.add(TempleUtils.getFrameRecommand());
+ thirdRow.get(1).setFirstItem(l2);
thirdRow.get(1).getItems().get(0).setData(buildDataList(ScheduleService.RECOMMEND_LIST));
+
+ List l3 = new ArrayList<>();
+ l3.add(TempleUtils.getFrameCategory());
+ thirdRow.get(2).setFirstItem(l3);
thirdRow.get(2).getItems().get(0).setData(buildCategoryDataList());
CATEGORY_PROD = JSON.parseObject(getDPLTemple("static/json/categoryPro.json"), MyDocument.class);
List
- container = CATEGORY_PROD.getMainTemplate().getItems().get(0).getItems();
@@ -88,7 +116,6 @@ public class DplBotService extends BaseBot {
PROD_INFO = JSON.parseObject(getDPLTemple("static/json/productInfo.json"), MyDocument.class);
FIRST_PAGE = JSON.parseObject(getDPLTemple("static/json/firstPage.json"), MyDocument.class);
DU_ID_2_US_ID = new ConcurrentHashMap<>();
- PRODUCT_INFO_HINT = new Hint(new ArrayList<>(Arrays.asList(PRODUCT_INFO_HINTS)));
}
public DplBotService(HttpServletRequest request) throws IOException {
@@ -105,40 +132,206 @@ public class DplBotService extends BaseBot {
@Override
protected Response onInent(IntentRequest intentRequest) {
- if ("load".equals(getIntent().getName())) {
- return load();
+//
+// final String userId = getCustomerId();
+// String intentName = getIntent().getName();
+// log.info("Intent name:{}",intentName);
+// if ("load".equals(intentName)) {
+// return load();
+// } else if ("openCollect".equals(intentName)) {
+// if (getAccessToken() == null) {
+// OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "该功能需要登录,请说小度小度,登录");
+// return new Response(outputSpeech);
+// } else {
+// String appUserId = getSessionAttribute("userId");
+// if (appUserId == null) {
+// try {
+// appUserId = getUserIdByToken(getAccessToken());
+// } catch (IOException e) {
+// log.error("打开收藏页时获取用户的郊游天下端id出错:{}", e.toString());
+// OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, SORRY_UNCATCH);
+// return new Response(outputSpeech);
+// }
+// if (appUserId == null) {
+// OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, SORRY_UNCATCH);
+// return new Response(outputSpeech);
+// }
+// }
+// CollectHistoryDocument document = TempleUtils.getCollectPage(Integer.parseInt(appUserId));
+// RenderDocument render = new RenderDocument(document);
+// this.addDirective(render);
+// this.setSessionAttribute(PRE_COLLE,document.getIdToken());
+// return new Response();
+// }
+// } else if ("openNum".equals(intentName)) {
+// String collectToken = getSessionAttribute(PRE_COLLE);
+// String rankToken = getSessionAttribute("ranking");
+// String recommengToken = getSessionAttribute("recommand");
+// log.info("openNum slot value:{}", getSlot("sys.number"));
+// if (collectToken != null) {
+// return dealOpenNum(collectToken);
+// } else if (rankToken != null){
+// return dealOpenNum(rankToken);
+// } else if (recommengToken != null) {
+// return dealOpenNum(recommengToken);
+// } else {
+// OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "似乎出了什么问题,请点击屏幕吧");
+// return new Response(outputSpeech);
+// }
+// } else if ("history".equals(intentName)) {
+// CollectHistoryDocument document = TempleUtils.getHistory(getUserId());
+// RenderDocument render = new RenderDocument(document);
+// this.addDirective(render);
+// this.setSessionAttribute(PRE_COLLE,document.getIdToken());
+// this.setSessionAttribute("ranking", null);
+// this.setSessionAttribute("recommand", null);
+// return new Response();
+// } else if ("recommand".equals(intentName)) {
+// RecommandDocument recommandDocument = TempleUtils.getRecommend();
+// RenderDocument render = new RenderDocument();
+// render.setDocument(recommandDocument);
+// this.addDirective(render);
+// this.addDirective(new PushStack());
+// String token = recommandDocument.getRecommendIdList();
+// if (token != null) {
+// this.setSessionAttribute("recommand", token);
+// this.setSessionAttribute(PRE_COLLE, null);
+// this.setSessionAttribute("ranking", null);
+// }
+// return new Response();
+// } else if ("ranking".equals(intentName)) {
+// RankingDocument document = TempleUtils.getRanking();
+// RenderDocument render = new RenderDocument();
+// render.setDocument(document);
+// this.addDirective(render);
+// this.addDirective(new PushStack());
+// String token = document.getRankBotIds();
+// if (token != null) {
+// this.setSessionAttribute("ranking", token);
+// this.setSessionAttribute("recommand", null);
+// this.setSessionAttribute(PRE_COLLE, null);
+// }
+// return new Response();
+// }
+// Query query = intentRequest.getQuery();
+// String userWord = null;
+// if (query != null) userWord = query.getOriginal();
+// if (userWord == null){
+// log.info("小度没有传来任何话语");
+// return buildErrorResponse(SORRY_UNCATCH);
+// }
+// QiWuResponse data = null;
+// try {
+// data = RequestTerminal.requestTerminate(userWord, userId);
+// } catch (Exception e) {
+// log.error("请求终端接口出错:", e.toString());
+// }
+// if (data == null) {
+// return buildErrorResponse(SORRY_UNCATCH);
+// }
+// String text = data.getText();
+// log.info("小悟返回:{}", text);
+// final String botAccount = ScheduleService.getNx2BotToHz1().get(data.getAipioneerUsername());
+// String beforeBotAccount = getSessionAttribute("botAcc");
+// if (botAccount == null || ScheduleService.getExceptBotAccount().contains(botAccount)) {
+// OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, text.substring(text.indexOf("】")+1));
+// return new Response(outputSpeech);
+// }
+// else if (!botAccount.equals(beforeBotAccount)) {
+// List
- container = PLAY_DOCUMENT.getMainTemplate().getItems().get(2).getItems();
+// container.get(1).setSrc(data.getAudio());
+// text = text.substring(text.indexOf("】")+1);
+// container.get(0).getItems().get(0).setText(text);
+// RenderDocument render = new RenderDocument(PLAY_DOCUMENT);
+// this.addDirective(render);
+// new Thread(() -> {
+// XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
+// XiaoDuHistoryTB historyTB = repository.getByXiaoduUserIdAndBotId(userId, botAccount);
+// if (historyTB == null) {
+// historyTB = new XiaoDuHistoryTB();
+// historyTB.setLastTime(System.currentTimeMillis());
+// historyTB.setBotId(botAccount);
+// historyTB.setXiaoduUserId(userId);
+// log.info("插入历史数据:{}", botAccount);
+// } else {
+// historyTB.setLastTime(System.currentTimeMillis());
+// log.info("更新历史数据:{}", botAccount);
+// }
+// repository.save(historyTB);
+// }).start();
+// return new Response();
+// } else {
+// ExecuteCommands executeCommands = new ExecuteCommands();
+// SetStateCommand audio = new SetStateCommand();
+// SetStateCommand textState = new SetStateCommand();
+// audio.setComponentId("audio");
+// audio.setState("src");
+// audio.setValue(data.getAudio());
+// textState.setComponentId("text");
+// textState.setState("text");
+// textState.setValue(text);
+//
+// executeCommands.addCommand(audio);
+// executeCommands.addCommand(textState);
+// this.addDirective(executeCommands);
+// this.setSessionAttribute("botAcc", botAccount);
+// return new Response();
+// }
+ String userId = getUserId();
+ OverTimeDetail detail;
+ if ((detail = LAST_OUTTIME_RESULT.remove(userId)) != null) {
+ for (Directive directive : detail.getDirectives()) {
+ this.addDirective(directive);
+ }
+ for (String key : detail.getAttributes().keySet()) {
+ this.setSessionAttribute(key, detail.getAttributes().get(key));
+ }
+ return detail.getResponse();
}
- String userId = getCustomerId();
- Query query = intentRequest.getQuery();
- String userWord = null;
- if (query != null) userWord = query.getOriginal();
- if (userWord == null){
- log.info("小度没有传来任何话语");
- return buildErrorResponse(Constants.ErrorMsg.SORRY_UNCATCH);
+ try {
+ Future future = POOL.submit(new Task(intentRequest, this));
+ future.get(2500, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException | ExecutionException e) {
+ log.error("获取任务执行结果出错:{}", e.toString());
+ return buildErrorResponse(SORRY_UNCATCH);
+ } catch (TimeoutException e) {
+ log.info("超时,让用户再说一遍:{}",e.toString());
+ return buildErrorResponse(SORRY_UNCATCH);
+ } catch (Exception all) {
+ log.error("任务执行发生了错误:{}", all.toString());
+ return buildErrorResponse(SORRY_UNCATCH);
}
+ return LAST_OUTTIME_RESULT.remove(getUserId()).getResponse();
+ }
+
+ private Response dealOpenNum(String idsToken) {
+ int collectNum = Integer.parseInt(getSlot("sys.number"));
+ String[] tokenList = new String(Base64.getDecoder().decode(idsToken)).split(File.separator);
+ OnProductDetail detail = ScheduleService.PRODUCT_ID_DETAIL.get(tokenList[collectNum-1]);
+ String productName = correctName(detail.getName());
+ String enterProductWord = new StringBuilder(Constants.PRE_PRODUCT_PLAY).append(productName).toString();
+ log.info("进入作品语句:{}", enterProductWord);
QiWuResponse data = null;
try {
- data = RequestTerminal.requestTerminate(userWord, userId);
- } catch (Exception e) {
+ data = RequestTerminal.requestTerminate(enterProductWord, getCustomerId());
+ } catch (IOException e) {
log.error("请求终端接口出错:", e.toString());
}
if (data == null) {
- return buildErrorResponse(Constants.ErrorMsg.SORRY_UNCATCH);
+ return buildErrorResponse(SORRY_UNCATCH);
}
-
- //String wait = new BigDecimal(data.getLength()).setScale(0, RoundingMode.DOWN).toString();
String text = data.getText();
- log.info("小悟返回:{}", text);
+ text = text.substring(text.indexOf("】")+1);
+ PLAY_DOCUMENT.getMainTemplate().getItems().get(1).setHeaderTitle(productName);
List
- container = PLAY_DOCUMENT.getMainTemplate().getItems().get(2).getItems();
container.get(1).setSrc(data.getAudio());
- text = text.substring(text.indexOf("】")+1);
- container.get(0).getItems().get(0).getItems().get(0).setText(text);
+ container.get(0).getItems().get(0).setText(text);
-// ExecuteCommands executeCommands = new ExecuteCommands();
-// UpdateComponentCommand update = new UpdateComponentCommand();
-// update.setDocument(PLAY_DOCUMENT);
-// update.setComponentId("whole");
RenderDocument render = new RenderDocument(PLAY_DOCUMENT);
+ this.setSessionAttribute(PRE_COLLE, null);
+ String trace = getSessionAttribute(BACK_TRACE);
+ if (trace == null || trace.length() != 2) trace = "00";
+ this.setSessionAttribute(BACK_TRACE, new StringBuilder(trace).append(detail.getBotAccount()).toString());
this.addDirective(render);
return new Response();
}
@@ -166,7 +359,7 @@ public class DplBotService extends BaseBot {
}
String componentId = userEvent.getPayload().getComponentId();
String componentPrefix;
- if ("continues".equals(componentId)){
+ if ("audio".equals(componentId)){
setExpectSpeech(true);
}
else if (Constants.PRE_PRODUCT_IMG.equals((componentPrefix = componentId.substring(0, 5)))) {
@@ -175,6 +368,7 @@ public class DplBotService extends BaseBot {
String productName = componentId.substring(5);
OnProductDetail productDetail = ScheduleService.PRODUCT_NAME_DETAIL.get(productName);
+ if (productDetail == null) return buildErrorResponse("目前不支持该作品");
String imgUrl = new StringBuilder(Constants.IMG_PREFIX).append(productDetail.getBannerImgUrl()).toString();
List
- content = PROD_INFO.getMainTemplate().getItems().get(2).getItems().get(0).getItems().get(0).getItems();
@@ -215,27 +409,27 @@ public class DplBotService extends BaseBot {
String accessToken = getAccessToken();
if (accessToken != null) {
// flower container button
- Integer count = getUserSendFlowerNum(String.valueOf(productDetail.getBotId()));
+ Integer count = getUserSendFlowerNum(productDetail.getBotAccount());
Item flower = icons.get(1);
flower.getItems().get(1).setText(USER_SEND_FLOWER+count);
- String flowerReward = new StringBuilder(FLOWE).append(productDetail.getBotId()).toString();
+ String flowerReward = new StringBuilder(FLOWE).append(productDetail.getBotAccount()).toString();
flower.setComponentId(flowerReward);
flower.getOnClick().get(0).setComponentId(flowerReward);
// collection container button
- boolean collec = didUserCollecThisProduct(String.valueOf(productDetail.getBotId()));
+ boolean collec = didUserCollecThisProduct(productDetail.getBotAccount());
Item collecButton = icons.get(2);
if (collec) {
collecButton.getItems().get(1).setText(COLLECED);
collecButton.getItems().get(0).setSrc(COLLECTED_IMG_URL);
- String unCollecId = new StringBuilder(UN_COLLEC_ID).append(productDetail.getBotId()).toString();
- //collecButton.setComponentId(unCollecId);
+ String unCollecId = new StringBuilder(UN_COLLEC_ID).append(productDetail.getBotAccount()).toString();
+ collecButton.setComponentId(unCollecId);
collecButton.getOnClick().get(0).setComponentId(unCollecId);
} else {
collecButton.getItems().get(1).setText(UN_COLLEC);
collecButton.getItems().get(0).setSrc(UN_COLLECTED_IMG_URL);
- String collecId = new StringBuilder(COLLEC_ID).append(productDetail.getBotId()).toString();
- //collecButton.setComponentId(collecId);
+ String collecId = new StringBuilder(COLLEC_ID).append(productDetail.getBotAccount()).toString();
+ collecButton.setComponentId(collecId);
collecButton.getOnClick().get(0).setComponentId(collecId);
}
} else {
@@ -254,7 +448,20 @@ public class DplBotService extends BaseBot {
RenderDocument renderDocument = new RenderDocument(PROD_INFO);
this.addDirective(renderDocument);
this.addDirective(new PushStack());
- this.addDirective(PRODUCT_INFO_HINT);
+ String trace = getSessionAttribute(BACK_TRACE);
+ log.info("before trace------------:{}",trace);
+ StringBuilder builder = new StringBuilder();
+ if (trace == null || trace.length() < 2) {
+ builder.append("00");
+ } else if (trace.length()>2) {
+ builder.append(trace, 0, 2);
+ } else {
+ builder.append(trace);
+ }
+
+ trace = builder.append(productDetail.getBotAccount()).toString();
+ log.info("after trace------------:{}",trace);
+ this.setSessionAttribute(BACK_TRACE, trace);
return new Response();
} else if (Constants.PRE_ENTER_PRODUCT.equals(componentPrefix)) {
String productName = componentId.substring(5);
@@ -267,16 +474,23 @@ public class DplBotService extends BaseBot {
log.error("请求终端接口出错:", e.toString());
}
if (data == null) {
- return buildErrorResponse(Constants.ErrorMsg.SORRY_UNCATCH);
+ return buildErrorResponse(SORRY_UNCATCH);
}
String text = data.getText();
text = text.substring(text.indexOf("】")+1);
PLAY_DOCUMENT.getMainTemplate().getItems().get(1).setHeaderTitle(productName);
List
- container = PLAY_DOCUMENT.getMainTemplate().getItems().get(2).getItems();
container.get(1).setSrc(data.getAudio());
- container.get(0).getItems().get(0).getItems().get(0).setText(text);
+ container.get(0).getItems().get(0).setText(text);
RenderDocument render = new RenderDocument(PLAY_DOCUMENT);
+ this.setSessionAttribute(PRE_COLLE, null);
+ String trace = getSessionAttribute(BACK_TRACE);
+ if (trace == null || trace.length()<2) trace = "00";
+ else if (trace.length()>2) trace = trace.substring(0,2);
+ if (productName.equals("清新传")) productName = "清新传{/zhuan4/}";
+ String botAccount = ScheduleService.PRODUCT_NAME_DETAIL.get(productName).getBotAccount();
+ this.setSessionAttribute(BACK_TRACE, new StringBuilder(trace).append(botAccount).append(File.separator).toString());
this.addDirective(render);
} else if (FLOWE.equals(componentPrefix)) {
if (FLOWER_LOAD.equals(componentId)) {
@@ -335,17 +549,17 @@ public class DplBotService extends BaseBot {
RenderDocument render = new RenderDocument(CATEGORY_PROD);
this.addDirective(render);
this.addDirective(new PushStack());
-// ExecuteCommands execute = new ExecuteCommands();
-// UpdateComponentCommand update = new UpdateComponentCommand();
-// update.setComponentId("whole");
-// update.setDocument(CATEGORY_PROD);
-// execute.addCommand(update);
-// this.addDirective(execute);
}
return new Response();
}
@Override
+ protected Response onSessionEnded(SessionEndedRequest sessionEndedRequest) {
+ LAST_OUTTIME_RESULT.remove(getUserId());
+ return new Response();
+ }
+
+ @Override
protected Response onBuyEvent(BuyEvent buyEvent) {
com.baidu.dueros.data.request.buy.event.Payload payload = buyEvent.getPayload();
String result = payload.getPurchaseResult().getPurchaseResult();
@@ -425,12 +639,9 @@ public class DplBotService extends BaseBot {
}
}
- private void changeIconIdTextAfterCollect(boolean collect, String botId) {
+ private ExecuteCommands changeIconIdTextAfterCollect(boolean collect, String botId) {
ExecuteCommands executeCommands = new ExecuteCommands();
- SetStateCommand setText = new SetStateCommand();
- SetStateCommand setImg = new SetStateCommand();
- SetStateCommand setId = new SetStateCommand();
- SetStateCommand setOnclick = new SetStateCommand();
+ UpdateComponentCommand update = new UpdateComponentCommand();
String srcValue;
String textValue;
String idValue;
@@ -440,35 +651,20 @@ public class DplBotService extends BaseBot {
if (collect) {
srcValue = COLLECTED_IMG_URL;
textValue = COLLECED;
- idValue = collectId;
- previousClickId = unCollectId;
+ idValue = unCollectId;
+ previousClickId = collectId;
} else {
srcValue = UN_COLLECTED_IMG_URL;
textValue = UN_COLLEC;
- idValue = unCollectId;
- previousClickId = collectId;
+ idValue = collectId;
+ previousClickId = unCollectId;
}
- setImg.setComponentId(COLLECT_IMAGE_ID);
- setImg.setState("src");
- setImg.setValue(srcValue);
-
- setText.setComponentId(COLLECT_TEXT_ID);
- setText.setState("text");
- setText.setValue(textValue);
-
- setId.setComponentId(previousClickId);
- setId.setState("componentId");
- setId.setValue(idValue);
-// setOnclick.setComponentId(previousClickId);
-// setOnclick.setState("onClick");
-// setOnclick.setValue(String.format(CLICK_PATTERN, idValue));
-
- executeCommands.addCommand(setId);
- executeCommands.addCommand(setImg);
- executeCommands.addCommand(setText);
- executeCommands.addCommand(setOnclick);
+ update.setComponentId(previousClickId);
+ update.setDocument(TempleUtils.getCollectIcon(idValue, srcValue, textValue));
+ executeCommands.addCommand(update);
this.addDirective(executeCommands);
+ return executeCommands;
}
private String getUsUserId() throws IOException {
@@ -727,10 +923,533 @@ public class DplBotService extends BaseBot {
}
}
+ private void backToBotIntro(String botAccount, OverTimeDetail detail) {
+ OnProductDetail productDetail = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount);
+ String imgUrl = new StringBuilder(Constants.IMG_PREFIX).append(productDetail.getBannerImgUrl()).toString();
+
+ List
- content = PROD_INFO.getMainTemplate().getItems().get(2).getItems().get(0).getItems().get(0).getItems();
+
+ // product picture
+ content.get(0).setSrc(imgUrl);
+
+ // text content
+ List
- contentText = content.get(1).getItems();
+ // product name
+ String productName = correctName(productDetail.getName());
+ contentText.get(0).setText(productName);
+
+ // product create time
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+ String dateString = formatter.format(productDetail.getCreateTime());
+ contentText.get(1).getItems().get(0).setText(new StringBuilder(Constants.PRODUCT_INTRO.CREATE_TIME).append(dateString).toString());
+
+ // product author
+ contentText.get(1).getItems().get(1).setText(new StringBuilder(Constants.PRODUCT_INTRO.AUTHOR).append(productDetail.getAuthorName()).toString());
+
+ // product labels
+ StringBuilder labels = new StringBuilder(Constants.PRODUCT_INTRO.LABEL);
+ for (String label: productDetail.getLabels()) {
+ labels.append(Constants.PRODUCT_INTRO.SPACE).append(label);
+ }
+ contentText.get(2).getItems().get(0).setText(labels.toString());
+
+ // product introduction
+ contentText.get(3).getItems().get(0).setText(productDetail.getIntro());
+
+ List
- icons = contentText.get(4).getItems();
+ // "start product" container button
+ String enterProName = new StringBuilder(Constants.PRE_ENTER_PRODUCT).append(productName).toString();
+ icons.get(0).setComponentId(enterProName);
+ icons.get(0).getOnClick().get(0).setComponentId(enterProName);
+
+ String accessToken = getAccessToken();
+ if (accessToken != null) {
+ // flower container button
+ Integer count = getUserSendFlowerNum(productDetail.getBotAccount());
+ Item flower = icons.get(1);
+ flower.getItems().get(1).setText(USER_SEND_FLOWER+count);
+ String flowerReward = new StringBuilder(FLOWE).append(productDetail.getBotAccount()).toString();
+ flower.setComponentId(flowerReward);
+ flower.getOnClick().get(0).setComponentId(flowerReward);
+
+ // collection container button
+ boolean collec = didUserCollecThisProduct(productDetail.getBotAccount());
+ Item collecButton = icons.get(2);
+ if (collec) {
+ collecButton.getItems().get(1).setText(COLLECED);
+ collecButton.getItems().get(0).setSrc(COLLECTED_IMG_URL);
+ String unCollecId = new StringBuilder(UN_COLLEC_ID).append(productDetail.getBotAccount()).toString();
+ collecButton.setComponentId(unCollecId);
+ collecButton.getOnClick().get(0).setComponentId(unCollecId);
+ } else {
+ collecButton.getItems().get(1).setText(UN_COLLEC);
+ collecButton.getItems().get(0).setSrc(UN_COLLECTED_IMG_URL);
+ String collecId = new StringBuilder(COLLEC_ID).append(productDetail.getBotAccount()).toString();
+ collecButton.setComponentId(collecId);
+ collecButton.getOnClick().get(0).setComponentId(collecId);
+ }
+ } else {
+ Item flower = icons.get(1);
+ flower.getItems().get(1).setText(FLOWER);
+ flower.setComponentId(FLOWER_LOAD);
+ flower.getOnClick().get(0).setComponentId(FLOWER_LOAD);
+
+ Item collecButton = icons.get(2);
+ collecButton.getItems().get(1).setText(UN_COLLEC);
+ collecButton.getItems().get(0).setSrc(UN_COLLECTED_IMG_URL);
+ collecButton.setComponentId(FLOWER_LOAD);
+ collecButton.getOnClick().get(0).setComponentId(FLOWER_LOAD);
+ }
+
+ RenderDocument renderDocument = new RenderDocument(PROD_INFO);
+ this.addDirective(renderDocument);
+ this.addDirective(new PushStack());
+ detail.getDirectives().add(renderDocument);
+ detail.getDirectives().add(new PushStack());
+ String trace = getSessionAttribute(BACK_TRACE);
+ trace = trace.substring(0, trace.length()-1);
+ this.setSessionAttribute(BACK_TRACE, trace);
+ detail.getAttributes().put(BACK_TRACE,trace);
+ }
+
+ private void sendCancellToTerminate(String userId){
+ RequestTerminal.backRequest(userId);
+ }
+
+ class Task implements Runnable{
+ IntentRequest intentRequest;
+ DplBotService dplBotService;
+
+ Task(IntentRequest intentRequest, DplBotService dplBotService) {
+ this.intentRequest = intentRequest;
+ this.dplBotService = dplBotService;
+ }
+
+ @Override
+ public void run() {
+ final String userId = getCustomerId();
+ String intentName = getIntent().getName();
+ OverTimeDetail detail = new OverTimeDetail();
+ log.info("Intent name:{}",intentName);
+ if ("load".equals(intentName)) {
+ detail.setResponse(load());
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ } else if ("back".equals(intentName)) {
+ String trace = getSessionAttribute(BACK_TRACE);
+ char second;
+ if (trace == null || trace.length() <= 2 || getQuery().contains("首")) {
+ // home page
+ RenderDocument renderDocument = new RenderDocument(LOAD_DOCUMENT);
+ dplBotService.addDirective(renderDocument);
+ dplBotService.setSessionAttribute(BACK_TRACE,null);
+ detail.getDirectives().add(renderDocument);
+ detail.getAttributes().put(BACK_TRACE, null);
+ } else if (StringUtils.endsWith(trace,File.separator)){
+ String botAccount = trace.substring(2, trace.length()-1);
+ log.info("返回作品的id:{}", botAccount);
+ backToBotIntro(botAccount, detail);
+ //dplBotService.setSessionAttribute(BACK_TRACE,trace.substring(0, trace.length()-1));
+ } else {
+ second = trace.charAt(1);
+ switch (second){
+ case '0':{
+ RenderDocument renderDocument = new RenderDocument(LOAD_DOCUMENT);
+ dplBotService.addDirective(renderDocument);
+ dplBotService.setSessionAttribute(BACK_TRACE,null);
+ detail.getAttributes().put(BACK_TRACE,null);
+ detail.getDirectives().add(renderDocument);
+ break;
+ }
+ case '1': {
+ //collect
+ String appUserId = getSessionAttribute("userId");
+ if (appUserId == null) {
+ RenderDocument renderDocument = new RenderDocument(LOAD_DOCUMENT);
+ dplBotService.addDirective(renderDocument);
+ dplBotService.setSessionAttribute(BACK_TRACE,null);
+ detail.getAttributes().put(BACK_TRACE,null);
+ detail.getDirectives().add(renderDocument);
+ break;
+ }
+ CollectHistoryDocument document = TempleUtils.getCollectPage(Integer.parseInt(appUserId));
+ RenderDocument render = new RenderDocument(document);
+ dplBotService.addDirective(render);
+ dplBotService.setSessionAttribute(BACK_TRACE, "01");
+ dplBotService.setSessionAttribute(PRE_COLLE,document.getIdToken());
+ detail.getAttributes().put(BACK_TRACE,null);
+ detail.getAttributes().put(PRE_COLLE,document.getIdToken());
+ detail.getDirectives().add(render);
+ break;
+ }
+ case '2': {
+ //history
+ CollectHistoryDocument document = TempleUtils.getHistory(getUserId());
+ RenderDocument render = new RenderDocument(document);
+ dplBotService.addDirective(render);
+ dplBotService.setSessionAttribute(PRE_COLLE,document.getIdToken());
+ dplBotService.setSessionAttribute(BACK_TRACE, "02");
+ detail.getAttributes().put(BACK_TRACE,"02");
+ detail.getAttributes().put(PRE_COLLE,document.getIdToken());
+ detail.getDirectives().add(render);
+ break;
+ }
+ case '3': {
+ //recommend
+ RecommandDocument recommandDocument = TempleUtils.getRecommend();
+ RenderDocument render = new RenderDocument();
+ render.setDocument(recommandDocument);
+ dplBotService.addDirective(render);
+ String token = recommandDocument.getRecommendIdList();
+ if (token != null) {
+ dplBotService.setSessionAttribute("recommand", token);
+ detail.getAttributes().put("recommand",token);
+ }
+ dplBotService.setSessionAttribute(BACK_TRACE, "03");
+ detail.getAttributes().put(BACK_TRACE, "03");
+ detail.getDirectives().add(render);
+ break;
+ }
+ case '4': {
+ //rank
+ RankingDocument document = TempleUtils.getRanking();
+ RenderDocument render = new RenderDocument();
+ render.setDocument(document);
+ dplBotService.addDirective(render);
+ detail.getDirectives().add(render);
+ String token = document.getRankBotIds();
+ if (token != null) {
+ dplBotService.setSessionAttribute("ranking", token);
+ detail.getAttributes().put("ranking",token);
+ }
+ dplBotService.setSessionAttribute(BACK_TRACE, "04");
+ detail.getAttributes().put(BACK_TRACE, "04");
+ break;
+ }
+ }
+ }
+ sendCancellToTerminate(userId);
+ dplBotService.setSessionAttribute(BACK_TRACE,null);
+ detail.getAttributes().put(BACK_TRACE,null);
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ } else if ("openCollect".equals(intentName)) {
+ if (getAccessToken() == null) {
+ OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "该功能需要登录,请说小度小度,登录");
+ detail.setResponse(new Response(outputSpeech));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ } else {
+ String appUserId = getSessionAttribute("userId");
+ if (appUserId == null) {
+ try {
+ appUserId = getUserIdByToken(getAccessToken());
+ } catch (IOException e) {
+ log.error("打开收藏页时获取用户的郊游天下端id出错:{}", e.toString());
+ OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, SORRY_UNCATCH);
+ //LAST_OUTTIME_RESULT.put(userId, new Response(outputSpeech));
+ detail.setResponse(new Response(outputSpeech));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ }
+ if (appUserId == null) {
+ OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, SORRY_UNCATCH);
+ //LAST_OUTTIME_RESULT.put(userId, new Response(outputSpeech));
+ detail.setResponse(new Response(outputSpeech));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ }
+ }
+ CollectHistoryDocument document = TempleUtils.getCollectPage(Integer.parseInt(appUserId));
+ RenderDocument render = new RenderDocument(document);
+ dplBotService.addDirective(render);
+ dplBotService.addDirective(new PushStack());
+ dplBotService.setSessionAttribute(PRE_COLLE,document.getIdToken());
+ dplBotService.setSessionAttribute(BACK_TRACE, "01");
+ detail.getAttributes().put(PRE_COLLE, document.getIdToken());
+ detail.getAttributes().put(BACK_TRACE,"01");
+ detail.getDirectives().add(render);
+ detail.getDirectives().add(new PushStack());
+ //LAST_OUTTIME_RESULT.put(userId, new Response());
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ }
+ } else if ("openNum".equals(intentName)) {
+ String collectToken = getSessionAttribute(PRE_COLLE);
+ String rankToken = getSessionAttribute("ranking");
+ String recommengToken = getSessionAttribute("recommand");
+ log.info("openNum slot value:{}", getSlot("sys.number"));
+ if (collectToken != null) {
+ detail.setResponse(dealOpenNum(collectToken));
+ //LAST_OUTTIME_RESULT.put(userId, dealOpenNum(collectToken));
+ } else if (rankToken != null){
+ detail.setResponse(dealOpenNum(rankToken));
+ //LAST_OUTTIME_RESULT.put(userId, dealOpenNum(rankToken));
+ } else if (recommengToken != null) {
+ detail.setResponse(dealOpenNum(recommengToken));
+ //LAST_OUTTIME_RESULT.put(userId, dealOpenNum(recommengToken));
+ } else {
+ OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "似乎出了什么问题,请点击屏幕吧");
+ detail.getResponse().setOutputSpeech(outputSpeech);
+ //LAST_OUTTIME_RESULT.put(userId, new Response(outputSpeech));
+ }
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ } else if ("history".equals(intentName)) {
+ CollectHistoryDocument document = TempleUtils.getHistory(getUserId());
+ RenderDocument render = new RenderDocument(document);
+ dplBotService.addDirective(render);
+ dplBotService.addDirective(new PushStack());
+ dplBotService.setSessionAttribute(PRE_COLLE,document.getIdToken());
+ dplBotService.setSessionAttribute("ranking", null);
+ dplBotService.setSessionAttribute("recommand", null);
+ dplBotService.setSessionAttribute(BACK_TRACE, "02");
+
+ detail.getDirectives().add(render);
+ detail.getDirectives().add(new PushStack());
+ detail.getAttributes().put("ranking", null);
+ detail.getAttributes().put("recommand", null);
+ detail.getAttributes().put(PRE_COLLE,document.getIdToken());
+ detail.getAttributes().put(BACK_TRACE, "02");
+
+ //LAST_OUTTIME_RESULT.put(userId, new Response());
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ } else if ("recommand".equals(intentName)) {
+ RecommandDocument recommandDocument = TempleUtils.getRecommend();
+ RenderDocument render = new RenderDocument();
+ render.setDocument(recommandDocument);
+ dplBotService.addDirective(render);
+ dplBotService.addDirective(new PushStack());
+ detail.getDirectives().add(new PushStack());
+ detail.getDirectives().add(render);
+ String token = recommandDocument.getRecommendIdList();
+ if (token != null) {
+ dplBotService.setSessionAttribute("recommand", token);
+ dplBotService.setSessionAttribute(PRE_COLLE, null);
+ dplBotService.setSessionAttribute("ranking", null);
+
+ detail.getAttributes().put("ranking", null);
+ detail.getAttributes().put("recommand", token);
+ detail.getAttributes().put(PRE_COLLE, null);
+ }
+ dplBotService.setSessionAttribute(BACK_TRACE, "03");
+ detail.getAttributes().put(BACK_TRACE,"03");
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, new Response());
+ return;
+ } else if ("ranking".equals(intentName)) {
+ RankingDocument document = TempleUtils.getRanking();
+ RenderDocument render = new RenderDocument();
+ render.setDocument(document);
+ dplBotService.addDirective(render);
+ dplBotService.addDirective(new PushStack());
+ detail.getDirectives().add(render);
+ detail.getDirectives().add(new PushStack());
+ String token = document.getRankBotIds();
+ if (token != null) {
+ dplBotService.setSessionAttribute("ranking", token);
+ dplBotService.setSessionAttribute("recommand", null);
+ dplBotService.setSessionAttribute(PRE_COLLE, null);
+
+ detail.getAttributes().put("ranking", token);
+ detail.getAttributes().put("recommand", null);
+ detail.getAttributes().put(PRE_COLLE, null);
+ }
+ dplBotService.setSessionAttribute(BACK_TRACE, "04");
+ detail.getAttributes().put(BACK_TRACE, "04");
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, new Response());
+ return;
+ } else if ("collect".equals(intentName) || "unCollect".equals(intentName)) {
+ boolean collect = "collect".equals(intentName);
+ String botAccount;
+ String trace = dplBotService.getSessionAttribute("trace");
+ if (trace == null || trace.length() <= 2) {
+ botAccount = dplBotService.getSessionAttribute("botAcc");
+ if(botAccount == null) {
+ String word = COLLECT_FAIL;
+ if (collect) word = UN_COLLECT_FAIL;
+ detail.setResponse(buildErrorResponse(word));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ }
+ } else {
+ if (StringUtils.endsWith(trace, File.separator)) botAccount = trace.substring(2, trace.length()-1);
+ else botAccount = trace.substring(2);
+ }
+ try {
+ boolean alreadyCollected;
+ String appUserId = dplBotService.getSessionAttribute("userId");
+ if (appUserId == null) appUserId = getUserIdByToken(getAccessToken());
+ if (appUserId != null) {
+ AppFavoriteTBRepository repository = BaseHolder.getBean("appFavoriteTBRepository");
+ AppFavoriteTB entity = new AppFavoriteTB();
+ entity.setBotId(botAccount);
+ entity.setUserId(Integer.parseInt(appUserId));
+ Example example = Example.of(entity);
+ alreadyCollected = repository.exists(example);
+ if (alreadyCollected) {
+ if (collect) detail.setResponse(buildErrorResponse("您之前就已经收藏过该作品啦,看来你真的很喜欢它"));
+ else {
+ new UnCollectThread(botAccount, userId).start();
+ String botName = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
+ ExecuteCommands commands = changeIconIdTextAfterCollect(false, botAccount);
+ detail.getDirectives().add(commands);
+ if (botName == null) detail.setResponse(buildErrorResponse(UN_COLLECT_BOT_WORD));
+ else detail.setResponse(buildErrorResponse(String.format(UN_COLLECT_BOT_WORD_MG,botName)));
+ }
+ }else {
+ if (collect) {
+ new CollectThread(botAccount, userId).start();
+ String word = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
+ ExecuteCommands commands = changeIconIdTextAfterCollect(true, botAccount);
+ detail.getDirectives().add(commands);
+ if (word == null) detail.setResponse(buildErrorResponse(COLLECT_BOT_WORD));
+ else detail.setResponse(buildErrorResponse(String.format(COLLECT_BOT_WORD_MG, correctName(word))));
+ }else {
+ detail.setResponse(buildErrorResponse("您还未收藏过该作品,它不在您的收藏列表内"));
+ }
+ }
+ }else {
+ detail.setResponse(buildErrorResponse(SORRY_UNCATCH));
+ }
+ } catch (Exception e) {
+ log.error("");
+ detail.setResponse(buildErrorResponse(SORRY_UNCATCH));
+ }
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ } else if ("sendFlower".equals(intentName)) {
+ String num = getSlot("sys.number");
+ OutputSpeech outputSpeech;
+ String confirmationStatus = dplBotService.getIntent().getConfirmationStatus().name();
+ log.info("槽位确认状态:{}",confirmationStatus);
+ if ("NONE".equals(confirmationStatus)) {
+ if (num == null) {
+ log.info("确认送花个数");
+ dplBotService.ask("sys.number");
+ outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "请问您要送几朵花");
+ } else {
+ log.info("确认最终送花意图");
+ dplBotService.setConfirmIntent();
+ outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText,
+ new StringBuilder("您要送").append(num).append("朵花是吗").toString());
+ }
+ detail.getResponse().setOutputSpeech(outputSpeech);
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ } else if ("CONFIRMED".equals(confirmationStatus)) {
+ log.info("确认");
+ } else {
+ log.info("否定");
+ }
+ return;
+ }
+ Query query = intentRequest.getQuery();
+ String userWord = null;
+ if (query != null) userWord = query.getOriginal();
+ if (userWord == null){
+ log.info("小度没有传来任何话语");
+ detail.setResponse(buildErrorResponse(SORRY_UNCATCH));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, buildErrorResponse(SORRY_UNCATCH));
+ return;
+ }
+ QiWuResponse data = null;
+ try {
+ data = RequestTerminal.requestTerminate(userWord, userId);
+ } catch (Exception e) {
+ log.error("请求终端接口出错:", e.toString());
+ }
+ if (data == null) {
+ detail.setResponse(buildErrorResponse(SORRY_UNCATCH));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, buildErrorResponse(SORRY_UNCATCH));
+ return;
+ }
+ String text = data.getText();
+ //log.info("小悟返回:{}", text);
+ text = text.substring(text.indexOf("】")+1);
+ final String botAccount = ScheduleService.getNx2BotToHz1().get(data.getAipioneerUsername());
+ if (botAccount == null) {
+ detail.setResponse(buildErrorResponse("不支持该作品换一个吧"));
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, buildErrorResponse("不支持该作品换一个吧"));
+ return;
+ }
+ String beforeBotAccount = getSessionAttribute("botAcc");
+ if (ScheduleService.getExceptBotAccount().contains(botAccount)) {
+ OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, text.substring(text.indexOf("】")+1));
+ detail.getResponse().setOutputSpeech(outputSpeech);
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, new Response(outputSpeech));
+ }
+ else if (!botAccount.equals(beforeBotAccount)) {
+ List
- container = PLAY_DOCUMENT.getMainTemplate().getItems().get(2).getItems();
+ container.get(1).setSrc(data.getAudio());
+ container.get(0).getItems().get(0).setText(text);
+ RenderDocument render = new RenderDocument(PLAY_DOCUMENT);
+ dplBotService.addDirective(render);
+ detail.getDirectives().add(render);
+ new Thread(() -> {
+ XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
+ XiaoDuHistoryTB historyTB = repository.getByXiaoduUserIdAndBotId(userId, botAccount);
+ if (historyTB == null) {
+ historyTB = new XiaoDuHistoryTB();
+ historyTB.setLastTime(System.currentTimeMillis());
+ historyTB.setBotId(botAccount);
+ historyTB.setXiaoduUserId(userId);
+ log.info("插入历史数据:{}", botAccount);
+ } else {
+ historyTB.setLastTime(System.currentTimeMillis());
+ log.info("更新历史数据:{}", botAccount);
+ }
+ repository.save(historyTB);
+ }).start();
+ String trace = dplBotService.getSessionAttribute(BACK_TRACE);
+ if (trace == null || trace.length() != 2) trace = "00";
+ trace = new StringBuilder(trace).append(botAccount).append(File.separator).toString();
+ dplBotService.setSessionAttribute(BACK_TRACE, trace);
+ dplBotService.setSessionAttribute("botAcc", botAccount);
+ detail.getAttributes().put("botAcc", botAccount);
+ detail.getAttributes().put(BACK_TRACE,trace);
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, new Response());
+ } else {
+// ExecuteCommands executeCommands = new ExecuteCommands();
+// SetStateCommand audio = new SetStateCommand();
+// SetStateCommand textState = new SetStateCommand();
+// audio.setComponentId("audioCom");
+// audio.setState("src");
+// audio.setValue(data.getAudio());
+// textState.setComponentId("text");
+// textState.setState("text");
+// textState.setValue(text);
+//
+// executeCommands.addCommand(textState);
+// executeCommands.addCommand(audio);
+
+// UpdateComponentCommand update = new UpdateComponentCommand();
+// update.setComponentId("whole");
+// update.setDocument(TempleUtils.getPlayUpdate(data.getAudio(), text));
+// executeCommands.addCommand(update);
+// dplBotService.addDirective(executeCommands);
+// detail.getDirectives().add(executeCommands);
+ List
- container = PLAY_DOCUMENT.getMainTemplate().getItems().get(2).getItems();
+ container.get(1).setSrc(data.getAudio());
+ container.get(0).getItems().get(0).setText(text);
+ RenderDocument document = new RenderDocument(PLAY_DOCUMENT);
+ dplBotService.addDirective(document);
+ detail.getDirectives().add(document);
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ //LAST_OUTTIME_RESULT.put(userId, new Response());
+ }
+ }
+ }
+
public static void main(String[] args) throws IOException {
-// System.out.println(new BigDecimal("14.836").setScale(0, RoundingMode.DOWN).toString());
-// System.out.println(Math.pow(10,2));
-// System.out.println(correctName("清新传{/zhuan4/}"));
- //getUserIdByToken("a6b78cc5-55f6-456a-a6f1-6254d677d952");
+ String s = "NDM4MTU1MzY3NDU3NzIwMTM2NDY0MDIxNjQ3NTMzODk5NzYxODgxMTAyOTU1ODY4ODc5MDc3MjA4NjIyMTM5NjM1NjU3Mjc3MDA5MjgzOTM2OTQ5MzQ4Mjk3Mjc0MzI0MjY5ODI4MTM3MzkwNDczMTc3OTM2NTY1NTkwNTMzMTk2MTI1MzU0NTU3NjY3MzkxOTY=";
+ String[] tokenList = new String(Base64.getDecoder().decode(s)).split(File.separator);
+ System.out.println(Arrays.toString(tokenList));
}
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java
index 1048947..761415b 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java
@@ -25,11 +25,23 @@ class RequestTerminal {
requestPojo.setAccess(Constants.SERVICE_NAME);
requestPojo.setText(userWord);
String requestJsonStr = JSON.toJSONString(requestPojo);
- HashMap headers = new HashMap<>();
- headers.put("Content-Type", "application/json;charset=utf-8");
log.info("向小悟发送的请求信息:{}", requestJsonStr);
- String resStr = OkHttp3Utils.doPostJsonStr(Constants.QI_WU_INTERFACE, headers, requestJsonStr);
+ String resStr = OkHttp3Utils.doPostJsonStr(Constants.QI_WU_INTERFACE, requestJsonStr);
+ if (resStr == null) return null;
log.info("返回信息:{}", resStr);
return JSON.parseObject(resStr, QiWuResponse.class);
}
+
+ static void backRequest(String userId) {
+ QiWuRequest requestPojo = new QiWuRequest();
+ requestPojo.setUser_id(userId);
+ requestPojo.setAccess(Constants.SERVICE_NAME);
+ requestPojo.setText("退出");
+ String requestJsonStr = JSON.toJSONString(requestPojo);
+ OkHttp3Utils.backPostAsync(Constants.QI_WU_INTERFACE, requestJsonStr);
+ }
+
+ public static void main(String[] args) throws IOException {
+ backRequest("2353461");
+ }
}
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 8190923..b4b24be 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
@@ -5,6 +5,7 @@ import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
import ai.qiwu.com.xiaoduhome.repository.primary.AllOnProductInfoRepository;
import ai.qiwu.com.xiaoduhome.repository.primary.GameProjectTbRepository;
import ai.qiwu.com.xiaoduhome.repository.primary.ProjectLabelRepository;
+import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryTBRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +28,11 @@ public class ScheduleService implements InitializingBean {
static volatile List RECOMMEND_LIST = new ArrayList<>();
static volatile List ALL_ON_PRODUCT = new ArrayList<>();
static final HashMap PRODUCT_NAME_DETAIL = new HashMap<>();
- //static final Map> PRODUCT_LABELS = new HashMap<>();
+ static final HashMap PRODUCT_ID_DETAIL = new HashMap<>();
+ static final HashMap NX2_BOT_TO_HZ1 = new HashMap<>();
+
+ static final List EXCEPT_BOT_ACCOUNT = new ArrayList<>();
+
static final String[] CATEGORY = {"古风", "科幻", "占星", "恋爱", "灾难", "架空", "儿童", "经营", "冒险", "武侠"};
static final ConcurrentHashMap> CATEGORY_PRODUCT_LIST = new ConcurrentHashMap<>();
@@ -37,16 +42,19 @@ public class ScheduleService implements InitializingBean {
private final AllOnProductInfoRepository allOnProductInfoRepository;
+ private final XiaoDuHistoryTBRepository xiaoDuHistoryTBRepository;
+
@Autowired
public ScheduleService(GameProjectTbRepository gameProjectTbRepository,
- ProjectLabelRepository projectLabelRepository, AllOnProductInfoRepository allOnProductInfoRepository) {
+ ProjectLabelRepository projectLabelRepository, AllOnProductInfoRepository allOnProductInfoRepository, XiaoDuHistoryTBRepository xiaoDuHistoryTBRepository) {
this.gameProjectTbRepository = gameProjectTbRepository;
this.projectLabelRepository = projectLabelRepository;
this.allOnProductInfoRepository = allOnProductInfoRepository;
+ this.xiaoDuHistoryTBRepository = xiaoDuHistoryTBRepository;
}
@Scheduled(cron = "0 0 19 * * ?")
- public void getRankingList() {
+ public void initRankingList() {
try {
new Thread(() -> {
RANKING_LIST = gameProjectTbRepository.findFirst15ByApplyStatusOrderByWatchDesc(1);
@@ -58,7 +66,7 @@ public class ScheduleService implements InitializingBean {
}
@Scheduled(cron = "0 0 18 * * ?")
- public void getRecommendList() {
+ public void initRecommendList() {
try {
new Thread(() -> {
RECOMMEND_LIST = gameProjectTbRepository.recommendList();
@@ -67,20 +75,21 @@ public class ScheduleService implements InitializingBean {
} catch (Exception e) {
log.error("更新推荐页出错:{}", e.getMessage());
}
-
}
@Scheduled(cron = "0 0 17 * * ?")
- public void getAllOnTableProductInfo() {
+ public void initAllOnTableProductInfo() {
try {
new Thread(() -> {
ALL_ON_PRODUCT = allOnProductInfoRepository.findAllByApplyStatus(1);
for (OnProductDetail item : ALL_ON_PRODUCT) {
String productName = item.getName();
+ String botAccount = item.getBotAccount();
List labels = projectLabelRepository.productLabels(item.getId());
//PRODUCT_LABELS.put(productName, labels);
item.setLabels(labels);
PRODUCT_NAME_DETAIL.put(productName, item);
+ PRODUCT_ID_DETAIL.put(botAccount, item);
}
//log.info("作品详细信息:{}", PRODUCT_NAME_DETAIL);
}).start();
@@ -90,7 +99,7 @@ public class ScheduleService implements InitializingBean {
}
@Scheduled(cron = "0 0 1 ? * 7")
- public void getProductList() {
+ public void initProductList() {
try {
new Thread(() -> {
for (String category: CATEGORY) {
@@ -104,13 +113,77 @@ public class ScheduleService implements InitializingBean {
}
}
+ @Scheduled(cron = "0 0 2 * * ?")
+ public void deleteOverTimeHistory() {
+ try {
+ new Thread(() -> {
+ xiaoDuHistoryTBRepository.deletePasted((long) (System.currentTimeMillis()-2592E5));
+ List userIds = xiaoDuHistoryTBRepository.getAllUser();
+ for (String userId: userIds) {
+ xiaoDuHistoryTBRepository.deleteOverTime(userId);
+ }
+ }).start();
+ }catch (Exception e) {
+ log.error("清理历史记录数据库出错:{}", e.toString());
+ }
+ }
+
@Override
public void afterPropertiesSet() throws Exception {
- getAllOnTableProductInfo();
- getRecommendList();
- getRankingList();
- getProductList();
+ initAllOnTableProductInfo();
+ initRecommendList();
+ initRankingList();
+ initProductList();
+ tian();
+ keng();
}
+ private void keng() {
+ NX2_BOT_TO_HZ1.put("6854303973", "612535455");
+ NX2_BOT_TO_HZ1.put("1814141710", "9828137390");
+ NX2_BOT_TO_HZ1.put("5741775745", "1586892647");
+ NX2_BOT_TO_HZ1.put("9159908109", "3899761881");
+ NX2_BOT_TO_HZ1.put("6035298742", "6559053319");
+ NX2_BOT_TO_HZ1.put("4366487183", "6402164753");
+ NX2_BOT_TO_HZ1.put("236055939", "6569120969");
+ NX2_BOT_TO_HZ1.put("9965361790", "9727432426");
+ NX2_BOT_TO_HZ1.put("2428131253", "9369493482");
+ NX2_BOT_TO_HZ1.put("8343905461", "7667391968");
+ NX2_BOT_TO_HZ1.put("2675579304", "2167984446");
+ NX2_BOT_TO_HZ1.put("6259213309", "438155367");
+ NX2_BOT_TO_HZ1.put("4707303948", "2139635657");
+ NX2_BOT_TO_HZ1.put("2090828382", "4731779365");
+ NX2_BOT_TO_HZ1.put("8907881060", "4577201364");
+ NX2_BOT_TO_HZ1.put("7051119238", "7907720862");
+ NX2_BOT_TO_HZ1.put("7414315062", "1029558688");
+ }
+ private void tian(){
+ EXCEPT_BOT_ACCOUNT.add("682031219");
+ EXCEPT_BOT_ACCOUNT.add("963477460");
+ EXCEPT_BOT_ACCOUNT.add("9256014607");
+ EXCEPT_BOT_ACCOUNT.add("1778815830");
+ EXCEPT_BOT_ACCOUNT.add("6823941516");
+ EXCEPT_BOT_ACCOUNT.add("4151097686");
+ }
+
+ public static HashMap getProductIdDetail() {
+ return PRODUCT_ID_DETAIL;
+ }
+
+ public static List getRankingList() {
+ return RANKING_LIST;
+ }
+
+ public static List getRecommendList() {
+ return RECOMMEND_LIST;
+ }
+
+ public static HashMap getNx2BotToHz1() {
+ return NX2_BOT_TO_HZ1;
+ }
+
+ public static List getExceptBotAccount() {
+ return EXCEPT_BOT_ACCOUNT;
+ }
}
diff --git a/xiaoduhome/src/main/resources/application.yml b/xiaoduhome/src/main/resources/application.yml
index da9b9ac..23d2278 100644
--- a/xiaoduhome/src/main/resources/application.yml
+++ b/xiaoduhome/src/main/resources/application.yml
@@ -4,11 +4,14 @@ server:
spring:
datasource:
primary:
+ #jdbc-url: jdbc:mysql://aws-nx2.chewrobot.com:3306/game_editor_db?useUnicode=true&characterEncoding=utf-8
jdbc-url: jdbc:mysql://localhost:3306/game_editor_db?useUnicode=true&characterEncoding=utf-8
username: root
+ #password: YAdqFKlzYho
password: 3g9^pWQs#ft7
driver-class-name: com.mysql.cj.jdbc.Driver
secondary:
+ #jdbc-url: jdbc:mysql://aliyun-hz1.chewrobot.com:3306/interface_db?useUnicode=true&characterEncoding=utf-8
jdbc-url: jdbc:mysql://localhost:3306/interface_db?useUnicode=true&characterEncoding=utf-8
username: root
password: 3g9^pWQs#ft7
diff --git a/xiaoduhome/src/main/resources/static/json/categoryPro.json b/xiaoduhome/src/main/resources/static/json/categoryPro.json
index 6170753..d36ccab 100644
--- a/xiaoduhome/src/main/resources/static/json/categoryPro.json
+++ b/xiaoduhome/src/main/resources/static/json/categoryPro.json
@@ -42,8 +42,7 @@
{
"type": "Container",
"align-items": "center",
- "justify-content": "center",
- "margin-left": "40dp",
+ "margin-left": "15dp",
"items": [
{
"type": "Image",
@@ -63,7 +62,6 @@
{
"type": "Text",
"font-size": "30dp",
- "letter-spacing": "3dp",
"margin-top": "10dp",
"text": "${data.imageName}"
}
diff --git a/xiaoduhome/src/main/resources/static/json/collect.json b/xiaoduhome/src/main/resources/static/json/collect.json
new file mode 100644
index 0000000..ce13035
--- /dev/null
+++ b/xiaoduhome/src/main/resources/static/json/collect.json
@@ -0,0 +1,38 @@
+{
+ "type": "DPL",
+ "version": "1.0",
+ "mainTemplate": {
+ "parameters": [
+ "payload"
+ ],
+ "items": [
+ {
+ "type": "Container",
+ "margin-left": "120dp",
+ "align-items": "center",
+ "onClick": [
+ {
+ "type": "SendEvent"
+ }
+ ],
+ "items": [
+ {
+ "type": "Image",
+ "height": "60dp",
+ "width": "60dp",
+ "componentId": "collectImage",
+ "src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/share.png",
+ "scale-type": "fitCenter"
+ },
+ {
+ "type": "Text",
+ "componentId": "collectText",
+ "margin-top": "10dp",
+ "text": "收藏",
+ "font-size": "20dp"
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/xiaoduhome/src/main/resources/static/json/collectPage.json b/xiaoduhome/src/main/resources/static/json/collectPage.json
new file mode 100644
index 0000000..545e726
--- /dev/null
+++ b/xiaoduhome/src/main/resources/static/json/collectPage.json
@@ -0,0 +1,99 @@
+{
+ "type": "DPL",
+ "version": "1.0",
+ "mainTemplate": {
+ "parameters": [
+ "payload"
+ ],
+ "items": [
+ {
+ "type": "Image",
+ "position": "absolute",
+ "top": "0dp",
+ "left": "0dp",
+ "height": "100%",
+ "width": "100%",
+ "src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg"
+ },
+ {
+ "type": "Header",
+ "headerImage": "https://skillstore.cdn.bcebos.com/icon/23/fc7581b7-b505-1f44-ab52-3d9f5e567dfd.png",
+ "headerTitle": "收藏"
+ },
+ {
+ "type": "Container",
+ "margin": "10dp",
+ "height": "100%",
+ "width": "100%",
+ "items": [
+ {
+ "type": "List",
+ "height": "100%",
+ "width": "100%",
+ "direction": "vertical",
+ "items": [
+ {
+ "type": "Container",
+ "height": "100dp",
+ "width": "100%",
+ "flex-direction": "row",
+ "componentId": "${data.botAccountId}",
+ "onclick": [
+ {
+ "type": "SendEvent",
+ "componentId": "${data.botAccountId}"
+ }
+ ],
+ "items": [
+ {
+ "type": "Text",
+ "font-size": "40dp",
+ "margin-left": "40dp",
+ "margin-top": "7dp",
+ "text": "${data.collectPageLeftNum}"
+ },
+ {
+ "type": "Image",
+ "width": "75dp",
+ "height": "75dp",
+ "border-radius": "10dp",
+ "margin-left": "1dp",
+ "src": "${data.bannerImgUrl}"
+ },
+ {
+ "type": "Container",
+ "height": "75dp",
+ "width": "45%",
+ "flex-direction": "column",
+ "margin-left": "20dp",
+ "items": [
+ {
+ "type": "Text",
+ "font-size": "30dp",
+ "text": "${data.name}"
+ },
+ {
+ "type": "Text",
+ "font-size": "20dp",
+ "margin-top": "8dp",
+ "text": "${data.intro}",
+ "text-overflow": "ellipsis",
+ "max-lines": 1
+ }
+ ]
+ },
+ {
+ "type": "Text",
+ "margin-left": "50dp",
+ "font-size": "30dp",
+ "text": "${data.authorName}"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/xiaoduhome/src/main/resources/static/json/frame.json b/xiaoduhome/src/main/resources/static/json/frame.json
new file mode 100644
index 0000000..30b30f0
--- /dev/null
+++ b/xiaoduhome/src/main/resources/static/json/frame.json
@@ -0,0 +1,31 @@
+{
+ "type": "Container",
+ "flex-direction": "row",
+ "margin-bottom": "15dp",
+ "items": [
+ {
+ "type": "Text",
+ "text": "作品排行榜",
+ "font-size": "35dp",
+ "margin-left": "30dp"
+ },
+ {
+ "type": "Frame",
+ "margin-left": "15dp",
+ "border-width": "1dp",
+ "border-top-left-radius": "25dp",
+ "border-top-right-radius": "15dp",
+ "border-bottom-right-radius": "15dp",
+ "padding-vertical": "5dp",
+ "padding-horizontal": "15dp",
+ "border-color": "rgb(255,255,255)",
+ "items": [
+ {
+ "type": "Text",
+ "font-size": "15dp",
+ "color": "rgb(255,255,255,0.4)"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/xiaoduhome/src/main/resources/static/json/history.json b/xiaoduhome/src/main/resources/static/json/history.json
new file mode 100644
index 0000000..fcb0abb
--- /dev/null
+++ b/xiaoduhome/src/main/resources/static/json/history.json
@@ -0,0 +1,99 @@
+{
+ "type": "DPL",
+ "version": "1.0",
+ "mainTemplate": {
+ "parameters": [
+ "payload"
+ ],
+ "items": [
+ {
+ "type": "Image",
+ "position": "absolute",
+ "top": "0dp",
+ "left": "0dp",
+ "height": "100%",
+ "width": "100%",
+ "src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg"
+ },
+ {
+ "type": "Header",
+ "headerImage": "https://skillstore.cdn.bcebos.com/icon/23/fc7581b7-b505-1f44-ab52-3d9f5e567dfd.png",
+ "headerTitle": "历史"
+ },
+ {
+ "type": "Container",
+ "margin": "10dp",
+ "height": "100%",
+ "width": "100%",
+ "items": [
+ {
+ "type": "List",
+ "height": "100%",
+ "width": "100%",
+ "direction": "vertical",
+ "items": [
+ {
+ "type": "Container",
+ "height": "100dp",
+ "width": "100%",
+ "flex-direction": "row",
+ "componentId": "${data.botAccountId}",
+ "onclick": [
+ {
+ "type": "SendEvent",
+ "componentId": "${data.botAccountId}"
+ }
+ ],
+ "items": [
+ {
+ "type": "Text",
+ "font-size": "40dp",
+ "margin-left": "40dp",
+ "margin-top": "7dp",
+ "text": "${data.collectPageLeftNum}"
+ },
+ {
+ "type": "Image",
+ "width": "20%",
+ "height": "75dp",
+ "border-radius": "5%",
+ "margin-left": "1dp",
+ "src": "${data.bannerImgUrl}"
+ },
+ {
+ "type": "Container",
+ "height": "75dp",
+ "width": "45%",
+ "flex-direction": "column",
+ "margin-left": "20dp",
+ "items": [
+ {
+ "type": "Text",
+ "font-size": "30dp",
+ "text": "${data.name}"
+ },
+ {
+ "type": "Text",
+ "font-size": "20dp",
+ "margin-top": "8dp",
+ "text": "${data.intro}",
+ "text-overflow": "ellipsis",
+ "max-lines": 1
+ }
+ ]
+ },
+ {
+ "type": "Text",
+ "margin-left": "40dp",
+ "font-size": "20dp",
+ "text": "${data.lastTime}"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/xiaoduhome/src/main/resources/static/json/onLunch2.json b/xiaoduhome/src/main/resources/static/json/onLunch2.json
index 7542097..720f42a 100644
--- a/xiaoduhome/src/main/resources/static/json/onLunch2.json
+++ b/xiaoduhome/src/main/resources/static/json/onLunch2.json
@@ -47,7 +47,6 @@
{
"type": "Container",
"align-items": "center",
- "justify-content": "center",
"margin-left": "30dp",
"items": [
{
@@ -68,7 +67,6 @@
{
"type": "Text",
"font-size": "24dp",
- "letter-spacing": "3dp",
"margin-top": "10dp",
"text": "${data.imageName}"
}
@@ -82,6 +80,7 @@
"type": "Container",
"height": "250dp",
"width": "100%",
+ "margin-top": "30dp",
"items": [
{
"type": "List",
@@ -93,7 +92,6 @@
"type": "Container",
"margin-left": "30dp",
"align-items": "center",
- "justify-content": "center",
"items": [
{
"type": "Image",
@@ -113,7 +111,6 @@
{
"type": "Text",
"font-size": "24dp",
- "letter-spacing": "3dp",
"margin-top": "10dp",
"text": "${data.imageName}"
}
@@ -127,6 +124,8 @@
"type": "Container",
"height": "250dp",
"width": "100%",
+ "margin-top": "30dp",
+ "margin-bottom": "60dp",
"items": [
{
"type": "List",
@@ -137,7 +136,6 @@
{
"type": "Container",
"align-items": "center",
- "justify-content": "center",
"margin-left": "30dp",
"items": [
{
@@ -158,7 +156,6 @@
{
"type": "Text",
"font-size": "24dp",
- "letter-spacing": "3dp",
"margin-top": "10dp",
"text": "${data.imageName}"
}
diff --git a/xiaoduhome/src/main/resources/static/json/play.json b/xiaoduhome/src/main/resources/static/json/play.json
index bce498b..b413291 100644
--- a/xiaoduhome/src/main/resources/static/json/play.json
+++ b/xiaoduhome/src/main/resources/static/json/play.json
@@ -26,37 +26,24 @@
"height": "100%",
"width": "100%",
"componentId": "whole",
- "onClick": [
- {
- "type": "SendEvent",
- "componentId": "continues"
- }
- ],
"items": [
{
"type": "Container",
- "width": "100%",
- "height": "100%",
+ "padding":"35dp",
+ "position": "absolute",
+ "bottom": "120dp",
"items": [
{
- "type": "Container",
- "height": "280dp",
- "width": "90%",
- "align-items": "flex-end",
- "items": [
- {
- "type": "Text",
- "font-size": "35dp",
- "font-style": "normal",
- "letter-spacing": "3dp"
- }
- ]
+ "type": "Text",
+ "componentId": "text",
+ "font-size": "28dp",
+ "font-style": "normal"
}
]
},
{
"type": "Audio",
- "componentId": "audio",
+ "componentId": "audioCom",
"looping": "false",
"autoplay": "true",
"onEnd": [
diff --git a/xiaoduhome/src/main/resources/static/json/playUpdate.json b/xiaoduhome/src/main/resources/static/json/playUpdate.json
new file mode 100644
index 0000000..189fff9
--- /dev/null
+++ b/xiaoduhome/src/main/resources/static/json/playUpdate.json
@@ -0,0 +1,47 @@
+{
+ "type": "DPL",
+ "version": "1.0",
+ "mainTemplate": {
+ "parameters": [
+ "payload"
+ ],
+ "items": [
+ {
+ "type": "Container",
+ "height": "100%",
+ "width": "100%",
+ "componentId": "whole",
+ "items": [
+ {
+ "type": "Container",
+ "padding":"35dp",
+ "position": "absolute",
+ "bottom": "120dp",
+ "items": [
+ {
+ "type": "Text",
+ "text": "fff",
+ "componentId": "text",
+ "font-size": "28dp",
+ "font-style": "normal"
+ }
+ ]
+ },
+ {
+ "type": "Audio",
+ "componentId": "audioCom",
+ "looping": "false",
+ "autoplay": "true",
+ "src": "ggg",
+ "onEnd": [
+ {
+ "type": "SendEvent",
+ "componentId": "audio"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/xiaoduhome/src/main/resources/static/json/productInfo.json b/xiaoduhome/src/main/resources/static/json/productInfo.json
index dc57e55..1bdaa4d 100644
--- a/xiaoduhome/src/main/resources/static/json/productInfo.json
+++ b/xiaoduhome/src/main/resources/static/json/productInfo.json
@@ -57,7 +57,6 @@
"type": "Text",
"margin-top": "10dp",
"font-size": "38dp",
- "letter-spacing": "15dp",
"margin-left": "5%"
},
{
@@ -69,14 +68,12 @@
"type": "Text",
"text": "发表时间:2019.5.8",
"font-size": "22dp",
- "letter-spacing": "14dp",
"margin-left": "5%"
},
{
"type": "Text",
"text": "作者:小艾",
"font-size": "22dp",
- "letter-spacing": "14dp",
"margin-left": "10%"
}
]
@@ -91,7 +88,6 @@
"max-lines": 1,
"text": "相关标签: 都市 社会 生活",
"font-size": "22dp",
- "letter-spacing": "14dp",
"margin-left": "5%"
}
]
@@ -104,8 +100,7 @@
{
"type": "Text",
"font-size": "25dp",
- "line-height": "50dp",
- "letter-spacing": "50dp",
+ "line-height": "5dp",
"margin-top": "30dp",
"max-lines": 3,
"text-overflow": "ellipsis",
@@ -116,12 +111,13 @@
{
"type": "Container",
"flex-direction": "row",
+ "position": "absolute",
+ "bottom": "160dp",
"items": [
{
"type": "Container",
"margin-left": "50dp",
"align-items": "center",
- "justify-content": "center",
"onClick": [
{
"type": "SendEvent"
@@ -132,7 +128,6 @@
"type": "Image",
"height": "60dp",
"width": "60dp",
- "margin-bottom": "20dp",
"src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/feel.png",
"scale-type": "fitCenter"
},
@@ -140,8 +135,7 @@
"type": "Text",
"text": "开始体验",
"margin-top": "10dp",
- "font-size": "20dp",
- "letter-spacing": "12dp"
+ "font-size": "20dp"
}
]
},
@@ -149,7 +143,6 @@
"type": "Container",
"margin-left": "130dp",
"align-items": "center",
- "justify-content": "center",
"onClick": [
{
"type": "SendEvent"
@@ -160,7 +153,6 @@
"type": "Image",
"height": "60dp",
"width": "60dp",
- "margin-bottom": "20dp",
"src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/flower.png",
"scale-type": "fitCenter"
},
@@ -168,16 +160,14 @@
"type": "Text",
"text": "打赏鲜花",
"margin-top": "10dp",
- "font-size": "20dp",
- "letter-spacing": "12dp"
+ "font-size": "20dp"
}
]
},
{
"type": "Container",
- "margin-left": "130dp",
+ "margin-left": "120dp",
"align-items": "center",
- "justify-content": "center",
"onClick": [
{
"type": "SendEvent"
@@ -188,7 +178,6 @@
"type": "Image",
"height": "60dp",
"width": "60dp",
- "margin-bottom": "20dp",
"componentId": "collectImage",
"src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/share.png",
"scale-type": "fitCenter"
@@ -198,8 +187,7 @@
"componentId": "collectText",
"margin-top": "10dp",
"text": "收藏",
- "font-size": "20dp",
- "letter-spacing": "49dp"
+ "font-size": "20dp"
}
]
}
diff --git a/xiaoduhome/src/main/resources/static/json/ranking.json b/xiaoduhome/src/main/resources/static/json/ranking.json
new file mode 100644
index 0000000..e8a7ce7
--- /dev/null
+++ b/xiaoduhome/src/main/resources/static/json/ranking.json
@@ -0,0 +1,93 @@
+{
+ "type": "DPL",
+ "version": "1.0",
+ "mainTemplate": {
+ "parameters": [
+ "payload"
+ ],
+ "items": [
+ {
+ "type": "Container",
+ "height": "100%",
+ "width": "100%",
+ "items": [
+ {
+ "type": "Image",
+ "position": "absolute",
+ "top": "0dp",
+ "left": "0dp",
+ "src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg",
+ "height": "100%",
+ "width": "100%"
+ },
+ {
+ "type": "Header",
+ "headerImage": "https://skillstore.cdn.bcebos.com/icon/23/fc7581b7-b505-1f44-ab52-3d9f5e567dfd.png",
+ "headerTitle": "排行榜",
+ "hasBackIcon": true
+ },
+ {
+ "type": "Container",
+ "height": "100%",
+ "width": "100%",
+ "componentId": "whole",
+ "margin-top": "65dp",
+ "items": [
+ {
+ "type": "List",
+ "height": "100%",
+ "width": "100%",
+ "direction": "horizontal",
+ "items": [
+ {
+ "type": "Container",
+ "align-items": "center",
+ "margin-left": "15dp",
+ "items": [
+ {
+ "type": "Image",
+ "width": "220dp",
+ "height": "220dp",
+ "componentId": "${data.imageId}",
+ "scale-type": "fitXY",
+ "border-radius": "10dp",
+ "src": "${data.imageSrc}",
+ "onClick": [
+ {
+ "type": "SendEvent",
+ "componentId": "${data.imageId}"
+ }
+ ]
+ },
+ {
+ "type": "Text",
+ "font-size": "30dp",
+ "margin-top": "10dp",
+ "text": "${data.imageName}"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "type": "Container",
+ "position": "absolute",
+ "width": "100%",
+ "left": "0",
+ "bottom": "0",
+ "items": [
+ {
+ "type": "Footer",
+ "hints": [
+ "打开推荐作品","下一个分类","打开排行榜"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/xiaoduhome/src/main/resources/static/json/recommand.json b/xiaoduhome/src/main/resources/static/json/recommand.json
new file mode 100644
index 0000000..e7e23b7
--- /dev/null
+++ b/xiaoduhome/src/main/resources/static/json/recommand.json
@@ -0,0 +1,93 @@
+{
+ "type": "DPL",
+ "version": "1.0",
+ "mainTemplate": {
+ "parameters": [
+ "payload"
+ ],
+ "items": [
+ {
+ "type": "Container",
+ "height": "100%",
+ "width": "100%",
+ "items": [
+ {
+ "type": "Image",
+ "position": "absolute",
+ "top": "0dp",
+ "left": "0dp",
+ "src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg",
+ "height": "100%",
+ "width": "100%"
+ },
+ {
+ "type": "Header",
+ "headerImage": "https://skillstore.cdn.bcebos.com/icon/23/fc7581b7-b505-1f44-ab52-3d9f5e567dfd.png",
+ "headerTitle": "推荐页",
+ "hasBackIcon": true
+ },
+ {
+ "type": "Container",
+ "height": "100%",
+ "width": "100%",
+ "componentId": "whole",
+ "margin-top": "65dp",
+ "items": [
+ {
+ "type": "List",
+ "height": "100%",
+ "width": "100%",
+ "direction": "horizontal",
+ "items": [
+ {
+ "type": "Container",
+ "align-items": "center",
+ "margin-left": "15dp",
+ "items": [
+ {
+ "type": "Image",
+ "width": "220dp",
+ "height": "220dp",
+ "componentId": "${data.imageId}",
+ "scale-type": "fitXY",
+ "border-radius": "10dp",
+ "src": "${data.imageSrc}",
+ "onClick": [
+ {
+ "type": "SendEvent",
+ "componentId": "${data.imageId}"
+ }
+ ]
+ },
+ {
+ "type": "Text",
+ "font-size": "30dp",
+ "margin-top": "10dp",
+ "text": "${data.imageName}"
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "type": "Container",
+ "position": "absolute",
+ "width": "100%",
+ "left": "0",
+ "bottom": "0",
+ "items": [
+ {
+ "type": "Footer",
+ "hints": [
+ "打开推荐作品","下一个分类","打开排行榜"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
--
libgit2 0.27.1