From b525a3209458c4e0d106667a6cd9bd9163d26f37 Mon Sep 17 00:00:00 2001
From: 苗权威 <1160292058@qq.com>
Date: Thu, 26 Sep 2019 21:00:37 +0800
Subject: [PATCH] 9.26
---
.idea/workspace.xml | 821 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
readme.md | 0
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java | 36 ++++++++++++++++++++++++++----------
tts_service/src/main/resources/application.yml | 4 ++--
xiaoai/pom.xml | 28 ++++++++++++++--------------
xiaoai/readme.md | 2 ++
xiaoai/src/main/java/ai/qiwu/mi/xiaoai/XiaoaiApplication.java | 7 +------
xiaoai/src/main/resources/application.properties | 1 +
xiaoai/start.sh | 1 +
xiaoai/upload.sh | 1 +
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java | 3 +++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryPagePojo.java | 6 ++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java | 40 ++++++++++++++++++++++++++++++++++++----
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFavoriteTB.java | 5 +++--
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFlowerTB.java | 4 ++--
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppUserTB.java | 3 ++-
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/OnProductDetail.java | 3 ++-
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryTB.java | 6 +++---
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuOrderTB.java | 5 +++--
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java | 8 ++++----
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java | 4 ++--
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFavoriteTBRepository.java | 6 ++++--
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuHistoryBotTimeRepository.java | 4 ++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java | 198 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java | 25 ++++++++++++++++++++++++-
26 files changed, 663 insertions(+), 640 deletions(-)
create mode 100644 readme.md
create mode 100644 xiaoai/readme.md
create mode 100644 xiaoai/start.sh
create mode 100644 xiaoai/upload.sh
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index c7752d4..dfedfe8 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,30 +3,27 @@
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
-
-
+
+
+
+
-
-
-
-
@@ -72,102 +69,95 @@
-
-
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
@@ -187,17 +177,6 @@
- allRepeateName2Info
- repeateName2Ids
- del_record_callback_url
- record_callback_url
- buildMp3Response
- HttpServletResponse
- check
- USER_HISTORY
- getJsonFromName
- T
- userId
tts
getAccessToken
onBuyEvent
@@ -216,6 +195,17 @@
padding-left
correctName
onChargeEvent
+ directives
+ compare
+ jytId
+ pageIndex
+ pageSign
+ audioFileName
+ del_record_callback_url
+ tid
+ buildUploadResponse
+ allRepeateName2Info
+ successUpLoadFileIds
Task
@@ -232,23 +222,6 @@
@@ -300,11 +290,20 @@
-
+
+
+
+
+
+
+
+
+
+
-
+
@@ -315,8 +314,8 @@
-
-
+
+
@@ -328,8 +327,6 @@
-
-
@@ -340,236 +337,19 @@
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -583,7 +363,7 @@
-
+
@@ -635,7 +415,7 @@
-
+
@@ -1014,6 +794,7 @@
+
@@ -1034,15 +815,14 @@
-
+
-
@@ -1148,7 +928,8 @@
-
+
+
@@ -1158,7 +939,7 @@
-
+
@@ -1170,8 +951,7 @@
-
-
+
@@ -1180,17 +960,17 @@
-
-
+
+
-
+
-
+
@@ -1201,13 +981,13 @@
-
+
-
-
-
-
+
+
+
+
@@ -1257,387 +1037,392 @@
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
+
+
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
+
+
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
diff --git a/readme.md b/readme.md
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/readme.md
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 6aa2022..3789d8c 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
@@ -20,6 +20,7 @@ import java.io.*;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.nio.charset.Charset;
+import java.nio.file.Files;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
@@ -1063,7 +1064,7 @@ public class TTService {
String encoding = TTSUtils.charset(csvFile);
// 所有成功上传的id,若多个id指向同一文件,任何一个成功则都应该将其余的id加入集合中
- final List successUpLoadFileIds = new ArrayList<>();
+ final Set successUpLoadFileIds = new HashSet<>();
// 所有失败了的id以及失败原因
HashMap allFailUpLoadId2Reason = new HashMap<>();
@@ -1091,21 +1092,25 @@ public class TTService {
// filename列不为空代表用户为该句指定了文件
if (StringUtils.isNotBlank(audioFileName)) {
id2Info.put(arr[0],arr); // 存储该行的详细信息,用于之后展示错误信息使用
+ boolean hasSuffix = StringUtils.endsWith(audioFileName,".mp3") || StringUtils.endsWith(audioFileName,".MP3");
// 修正文件名,不包含后缀名的加上.mp3后缀名
- audioFileName = StringUtils.endsWith(audioFileName,".mp3") ? audioFileName : audioFileName+".mp3";
+ if (!hasSuffix) audioFileName = audioFileName+".mp3";
// String previousId;
// 若之前已有相同文件名,则将该文件的id加入集合,以该文件名为key
// (previousId = allOldname2Id.putIfAbsent(audioFileName, arr[0])) != null
+
List repeateIds = repeateName2Ids.computeIfAbsent(audioFileName, s -> new ArrayList<>());
if (repeateIds.size() != 0) {
// Set repeateIds = repeateName2Ids.computeIfAbsent(audioFileName, s -> new HashSet<>());
// repeateIds.add(arr[0]);
// repeateIds.add(previousId);
//遍历指向相同文件的语句,生成text与当前一样的语句的提示信息
+ boolean doesBeforeRepeate = false;
boolean beforeSuccess = false;
hasRepeate = true;
for (String repeateId: repeateIds) {
if (arr[1].equals(id2Info.get(repeateId)[1])) {
+ doesBeforeRepeate = true;
Set textIdEqualIds = allRepeateName2Info.computeIfAbsent(audioFileName, s -> new HashSet<>());
textIdEqualIds.add(arr[0]);
textIdEqualIds.add(repeateId);
@@ -1114,7 +1119,7 @@ public class TTService {
if (successUpLoadFileIds.contains(repeateId)) beforeSuccess = true;
}
// 之前的重复语句并不一定执行成功,若不成功则放行当前的这条重复语句
- if (beforeSuccess) {
+ if (beforeSuccess && doesBeforeRepeate) {
repeateIds.add(arr[0]);
continue;
}
@@ -1126,7 +1131,13 @@ public class TTService {
// audio_dir/botname/record/npcname/xxx.mp3
final String usFilename = new StringBuilder(folder).append(File.separator).append(md5Name).toString();
// 压缩包中有该mp3文件
- if (TTSUtils.doesFileExist(fileInPackage)) {
+ boolean doesFileExit = TTSUtils.doesFileExist(fileInPackage);
+ if (!doesFileExit && !hasSuffix) {
+ fileInPackage = new StringBuilder(zipFolder).append(File.separator)
+ .append(audioFileName, 0, audioFileName.lastIndexOf(".")).append(".MP3").toString();
+ doesFileExit = TTSUtils.doesFileExist(fileInPackage);
+ }
+ if (doesFileExit) {
File usFile = new File(usFilename);
boolean result=true;
// 删除之前的旧文件
@@ -1136,10 +1147,16 @@ public class TTService {
// 删除成功后删除其b64文件,且将压缩包中的文件移到安置目录下,即
// /root/TTS-service/mqwZip/audioFilename -> audio_dir/botname/record/npcname/xxx.mp3
if (result) {
- POOL.submit(() -> new File(new StringBuilder(usFilename).append(".b64").toString()).delete());
- if (new File(fileInPackage).renameTo(usFile)) {
+ new File(new StringBuilder(usFilename).append(".b64").toString()).delete();
+ try {
+ Files.copy(new File(fileInPackage).toPath(), usFile.toPath());
successUpLoadFileIds.add(arr[0]);
+ } catch (Exception e) {
+
}
+// if (new File(fileInPackage).renameTo(usFile)) {
+// successUpLoadFileIds.add(arr[0]);
+// }
}else {
allFailUpLoadId2Reason.put(arr[0], "程序原因,请重新上传");
log.error("删除之前的就音频失败:{}",fileInPackage);
@@ -1159,13 +1176,12 @@ public class TTService {
//log.info("repeateName2Ids:{}",repeateName2Ids);
if (successUpLoadFileIds.size() != 0) {
if (hasRepeate) {
- List repeatNameIdList = new ArrayList<>();
+ Set repeatNameIdList = new HashSet<>();
for (String successId: successUpLoadFileIds) {
String name = id2Info.get(successId)[3];
name = StringUtils.endsWith(name,".mp3") ? name : name+".mp3";
- List nameRepeats = repeateName2Ids.get(name);
+ Set nameRepeats = allRepeateName2Info.get(name);
if (nameRepeats != null && nameRepeats.size()>0) {
- nameRepeats.remove(successId);
repeatNameIdList.addAll(nameRepeats);
}
}
@@ -1218,7 +1234,7 @@ public class TTService {
StringBuilder msgBuild = new StringBuilder(msg).append(";\n").append("下面为提醒信息,请确认:");
for (String id : successUpLoadFileIds) {
String name = id2Info.get(id)[3];
- name = StringUtils.endsWith(name,".mp3") ? name : name+".mp3";
+ name = StringUtils.endsWith(name,".mp3") || StringUtils.endsWith(name,".MP3") ? name : name+".mp3";
Set infos = allRepeateName2Info.remove(name);
if (infos != null && infos.size() != 0) msgBuild
.append("下面的id列表,其所代表的语句的text皆为:\"").append(id2Info.get(id)[1]).append("\",且他们指向同一个文件,这是您想要的结果吗?").append(":")
diff --git a/tts_service/src/main/resources/application.yml b/tts_service/src/main/resources/application.yml
index d9dfcb5..3d395a9 100644
--- a/tts_service/src/main/resources/application.yml
+++ b/tts_service/src/main/resources/application.yml
@@ -19,8 +19,8 @@ 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:
diff --git a/xiaoai/pom.xml b/xiaoai/pom.xml
index 548bf87..4505afb 100644
--- a/xiaoai/pom.xml
+++ b/xiaoai/pom.xml
@@ -11,7 +11,7 @@
ai.qiwu.mi
xiaoai
0.0.1-SNAPSHOT
- war
+
xiaoai
Demo project for Spring Boot
@@ -23,12 +23,12 @@
org.springframework.boot
spring-boot-starter-web
-
-
- org.springframework.boot
- spring-boot-starter-tomcat
-
-
+
+
+
+
+
+
@@ -36,13 +36,13 @@
spring-boot-starter-test
test
-
-
- javax.servlet
- javax.servlet-api
- LATEST
- provided
-
+
+
+
+
+
+
+
org.apache.httpcomponents
diff --git a/xiaoai/readme.md b/xiaoai/readme.md
new file mode 100644
index 0000000..3f6661d
--- /dev/null
+++ b/xiaoai/readme.md
@@ -0,0 +1,2 @@
+upload.sh:将jar包上传到服务器
+start.sh:服务器上执行该文件,启动项目
\ No newline at end of file
diff --git a/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/XiaoaiApplication.java b/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/XiaoaiApplication.java
index d49df54..11589e4 100644
--- a/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/XiaoaiApplication.java
+++ b/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/XiaoaiApplication.java
@@ -6,14 +6,9 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
-public class XiaoaiApplication extends SpringBootServletInitializer {
+public class XiaoaiApplication{
public static void main(String[] args) {
SpringApplication.run(XiaoaiApplication.class, args);
}
-
- @Override
- protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
- return builder.sources(XiaoaiApplication.class);
- }
}
diff --git a/xiaoai/src/main/resources/application.properties b/xiaoai/src/main/resources/application.properties
index 64456db..3627cc8 100644
--- a/xiaoai/src/main/resources/application.properties
+++ b/xiaoai/src/main/resources/application.properties
@@ -1,3 +1,4 @@
+server.port=8189
logging.path=/usr/mqw/logs/xiaoai
logging.level.root = info
spring.output.ansi.enabled=detect
\ No newline at end of file
diff --git a/xiaoai/start.sh b/xiaoai/start.sh
new file mode 100644
index 0000000..d8f0ac6
--- /dev/null
+++ b/xiaoai/start.sh
@@ -0,0 +1 @@
+nohup java -jar /root/GameEditor/mqw/project/xiaoai/xiaoai.jar > nohup.log 2>&1 &
\ No newline at end of file
diff --git a/xiaoai/upload.sh b/xiaoai/upload.sh
new file mode 100644
index 0000000..3a585cc
--- /dev/null
+++ b/xiaoai/upload.sh
@@ -0,0 +1 @@
+scp /usr/local/intellij/workplace/smartbox/xiaoai/target/xiaoai.jar root@aliyun-hz1.chewrobot.com:/root/GameEditor/mqw/project/xiaoai/
\ No newline at end of file
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 0dfca8f..9c4d7dd 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
@@ -33,6 +33,9 @@ public interface Constants {
String REWARD_FLOWER = "请扫码支付";
String UNIT_PRICE = "1";
+ Integer CO_HI_PAGE_SIZE = 4;
+ Integer RE_RA_CA_PAGE_SIZE = 20;
+
interface DPL_COMPONENT_ID {
String FLOWE = "flowe";
String FLOWER_PRODUCT_ID = "190817185926388308";
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
index 0e4b6fe..b8e9efd 100644
--- 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
@@ -70,4 +70,10 @@ public class CollectHistoryPagePojo {
private String paddingLeft;
@JsonProperty("scale-type")
private String scaleType;
+ @JsonProperty("background-color")
+ private String backgroundColor;
+ @JsonProperty("align-items")
+ private String alignItems;
+ @JsonProperty("justify-content")
+ private String justifyContent;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java
index 5700fc3..2d08dae 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/CollectHistoryUtils.java
@@ -19,7 +19,8 @@ public class CollectHistoryUtils {
private static final CollectHistoryPagePojo HISTORY_HEAD = buildHistoryHead();
private static final CollectHistoryPagePojo FOOTER = buildFooter();
- public static CollectHistoryDocument getDocument(List datas, boolean collect) {
+ public static CollectHistoryDocument getDocument(List datas, boolean collect,
+ int index, int num) {
CollectHistoryDocument document = new CollectHistoryDocument();
document.setDuration(120000);
CollectHistoryMainTemplate mainTemplate = new CollectHistoryMainTemplate();
@@ -30,7 +31,7 @@ public class CollectHistoryUtils {
allContainer.setWidth("100%");
allContainer.setPaddingRight("15dp");
allContainer.setPaddingLeft("15dp");
- allContainer.setPaddingBottom("120dp");
+ allContainer.setPaddingBottom("180dp");
CollectHistoryPagePojo list = new CollectHistoryPagePojo();
list.setType("List");
@@ -45,7 +46,7 @@ public class CollectHistoryUtils {
CollectHistoryPagePojo head;
if (collect) head = COLLECT_HEAD;
else head = HISTORY_HEAD;
- mainTemplate.getItems().addAll(Arrays.asList(BACK_IMG, head, allContainer, FOOTER));
+ mainTemplate.getItems().addAll(Arrays.asList(BACK_IMG, head, allContainer, FOOTER, buildPageButton(index, num)));
return document;
}
@@ -121,6 +122,37 @@ public class CollectHistoryUtils {
return main;
}
+ private static CollectHistoryPagePojo buildPageButton(int curIndex, int num) {
+ CollectHistoryPagePojo fCon = new CollectHistoryPagePojo();
+ fCon.setType("Container");
+ fCon.setLeft("447dp");
+ fCon.setBottom("70dp");
+ fCon.setPosition("absolute");
+
+ CollectHistoryPagePojo frame = new CollectHistoryPagePojo();
+ frame.setType("Frame");
+ frame.setBorderRadius("40dp");
+ frame.setBackgroundColor("rgba(0,0,0,0.5)");
+
+ CollectHistoryPagePojo sCon = new CollectHistoryPagePojo();
+ sCon.setType("Container");
+ sCon.setWidth("130dp");
+ sCon.setHeight("35dp");
+ sCon.setAlignItems("center");
+ sCon.setJustifyContent("center");
+
+ CollectHistoryPagePojo text = new CollectHistoryPagePojo();
+ text.setType("Text");
+ text.setFontSize("22dp");
+ if (num == 0) text.setText("第"+curIndex+"页");
+ else text.setText(curIndex+"/"+num);
+
+ sCon.setItems(Collections.singletonList(text));
+ frame.setItems(Collections.singletonList(sCon));
+ fCon.setItems(Collections.singletonList(frame));
+ return fCon;
+ }
+
private static CollectHistoryPagePojo buildFooter() {
CollectHistoryPagePojo footerCon = new CollectHistoryPagePojo();
footerCon.setType("Container");
@@ -131,7 +163,7 @@ public class CollectHistoryUtils {
CollectHistoryPagePojo footer = new CollectHistoryPagePojo();
footer.setType("Footer");
- footer.setHints(Arrays.asList("打开第一个","下一页","上一页","返回"));
+ footer.setHints(Arrays.asList("打开第一个","下一页","上一页","返回","跳到第三页"));
footerCon.setItems(Collections.singletonList(footer));
return footerCon;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFavoriteTB.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFavoriteTB.java
index 3fb2eb8..1f6c723 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFavoriteTB.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFavoriteTB.java
@@ -9,6 +9,7 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
+import java.sql.Timestamp;
import java.util.Date;
/**
@@ -36,9 +37,9 @@ public class AppFavoriteTB {
@CreatedDate
@Column(name = "gmt_create", updatable = false, nullable = false)
- private Date createTime;
+ private Timestamp createTime;
@LastModifiedDate
@Column(name = "gmt_modified", nullable = false)
- private Date updateTime;
+ private Timestamp updateTime;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFlowerTB.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFlowerTB.java
index d0e9cdc..39e5bbd 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFlowerTB.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFlowerTB.java
@@ -48,9 +48,9 @@ public class AppFlowerTB {
@CreatedDate
@Column(name = "gmt_create", updatable = false, nullable = false)
- private Date createTime;
+ private Timestamp createTime;
@LastModifiedDate
@Column(name = "gmt_modified", nullable = false)
- private Date updateTime;
+ private Timestamp updateTime;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppUserTB.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppUserTB.java
index d273217..f447d8c 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppUserTB.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppUserTB.java
@@ -7,6 +7,7 @@ import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
+import java.sql.Timestamp;
import java.util.Date;
/**
@@ -29,5 +30,5 @@ public class AppUserTB {
@CreatedDate
@Column(name = "gmt_create", updatable = false, nullable = false)
- private Date createTime;
+ private Timestamp createTime;
}
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 a47e122..51ee193 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
@@ -5,6 +5,7 @@ import lombok.Setter;
import lombok.ToString;
import javax.persistence.*;
+import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
@@ -38,7 +39,7 @@ public class OnProductDetail {
private Integer applyStatus;
@Column(name = "gmt_create")
- private Date createTime;
+ private Timestamp createTime;
@Column(name = "user_nickname")
private String authorName;
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
index 6f87462..b230383 100644
--- 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
@@ -3,12 +3,12 @@ package ai.qiwu.com.xiaoduhome.entity.secondary;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
-import lombok.ToString;
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.sql.Timestamp;
import java.util.Date;
/**
@@ -36,9 +36,9 @@ public class XiaoDuHistoryTB {
@CreatedDate
@Column(name = "create_time", updatable = false, nullable = false)
- private Date createTime;
+ private Timestamp createTime;
@LastModifiedDate
@Column(name = "update_time")
- private Date updateTime;
+ private Timestamp updateTime;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuOrderTB.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuOrderTB.java
index d104194..b2612da 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuOrderTB.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuOrderTB.java
@@ -7,6 +7,7 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
+import java.sql.Timestamp;
import java.util.Date;
/**
@@ -58,9 +59,9 @@ public class XiaoDuOrderTB {
@CreatedDate
@Column(name = "create_time", updatable = false, nullable = false)
- private Date createTime;
+ private Timestamp createTime;
@LastModifiedDate
@Column(name = "update_time", nullable = false)
- private Date updateTime;
+ private Timestamp updateTime;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java
index 345c523..b5e3e90 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java
@@ -191,11 +191,11 @@ public class TestBuild {
public static void main(String[] args) throws IOException {
String target = "/home/yf01/下载/tts/target.csv";
- String src = "/home/yf01/下载/齐齐-人工配音关系对于表(1).csv";
- String srcModify = "/home/yf01/下载/%E6%B0%B4%E5%BF%83%E6%B9%96.csv";
- String v2 = "/home/yf01/下载/齐齐-人工配音关系对于表.csv";
+ String src = "/home/yf01/下载/齐齐-人工配音关系对于表(2).csv";
+ String srcModify = "/home/yf01/下载/qiOld.csv";
+ String v2 = "/home/yf01/下载/qiNew.csv";
//csvUtil(target, src, srcModify, v2);
- //check(src, srcModify, target);
+ check(src, srcModify, target);
}
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java
index 34d896f..7a87ba9 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java
@@ -20,9 +20,9 @@ public class UserBehaviorData {
// 用户对作品所送花的数目
private volatile HashMap userBotId2Flowers = new HashMap<>();
// 用户是否收藏该作品
- private volatile HashMap userBotId2Collected = new HashMap<>();
+ private volatile HashMap userBotId2Collected = new HashMap<>();
// 标记清除,每半小时标记一次
- private volatile Byte mark = 1;
+ private volatile Byte mark = 0;
private volatile String jytUserId;
}
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 d94c34c..1911cc8 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
@@ -23,8 +23,10 @@ public interface AppFavoriteTBRepository extends JpaRepository getFavoriteBotIds(Long userId);
+ List getByUserId(Long userId);
+
+ @Query(value = "select bot_username from app_favorite_tb where user_id=?1 order by gmt_create desc limit ?2,10", nativeQuery = true)
+ List getFavoriteLimit(Long userId, Integer start);
@Override
long count(Example example);
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
index b1a24c4..f722706 100644
--- 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
@@ -2,6 +2,7 @@ package ai.qiwu.com.xiaoduhome.repository.secondary;
import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryBotIdTime;
import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.Query;
import java.util.List;
@@ -11,4 +12,7 @@ import java.util.List;
*/
public interface XiaoDuHistoryBotTimeRepository extends JpaRepository {
List getByXiaoduUserId(String xiaoduUserId);
+
+ @Query(value = "select bot_id,last_time from xiaodu_history_tb where xiaodu_user_id=?1 order by last_time desc limit ?2,10",nativeQuery = true)
+ List getByXiaoduUserIdLimit(String xiaoduUserId, Integer start);
}
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 364a9ce..771f7e4 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
@@ -65,12 +65,11 @@ import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.*;
+import static ai.qiwu.com.xiaoduhome.common.Constants.*;
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;
import static ai.qiwu.com.xiaoduhome.common.Constants.WelcomeWord.ERROR_SEND_FLOWER;
import static ai.qiwu.com.xiaoduhome.common.Constants.WelcomeWord.FAIL_COLLECT;
import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.*;
@@ -104,7 +103,9 @@ public class DplBotService extends BaseBot {
// 初次进入时创建用户的行为信息,包括历史记录,送花数,收藏记录
// 历史记录,收藏记录,送花数,郊游天下id
if (DplbotServiceUtil.USER_HISTORY.get(getUserId()) == null) {
- DplbotServiceUtil.onLunchFillUserBehaviorData(getAccessToken(), getUserId());
+ String accessToken = getAccessToken();
+ if (accessToken != null) setSessionAttribute("userId", DplbotServiceUtil.getUserIdByToken(accessToken));
+ DplbotServiceUtil.onLunchFillUserBehaviorData(accessToken, getUserId());
}
return new Response(outputSpeech);
}
@@ -183,7 +184,7 @@ public class DplBotService extends BaseBot {
overDetail.getAttributes().put(PRE_COLLE, null);
String trace = getSessionAttribute(BACK_TRACE);
if (trace == null || trace.length() != 2) trace = "00";
- String backTrace = new StringBuilder(trace).append(detail.getBotAccount()).toString();
+ String backTrace = new StringBuilder(trace).append(detail.getBotAccount()).append(File.separator).toString();
this.setSessionAttribute(BACK_TRACE, backTrace);
overDetail.getAttributes().put(BACK_TRACE,backTrace);
this.addDirective(render);
@@ -276,7 +277,6 @@ public class DplBotService extends BaseBot {
trace = builder.append(productDetail.getBotAccount()).toString();
log.info("after trace------------:{}",trace);
this.setSessionAttribute(BACK_TRACE, trace);
- this.setSessionAttribute("pageSign",null);
return new Response();
} else if (Constants.PRE_ENTER_PRODUCT.equals(componentPrefix)) {
String productName = componentId.substring(5);
@@ -355,7 +355,6 @@ public class DplBotService extends BaseBot {
RenderDocument render = new RenderDocument(document);
this.setSessionAttribute("category",category);
this.addDirective(render);
- this.setSessionAttribute("pageSign","5");
this.setSessionAttribute("trace","05");
} else if ("playButton".equals(componentId)) {
return buildErrorResponse("您可以直接对我说我要送花或者我要收藏或取消收藏");
@@ -383,7 +382,7 @@ public class DplBotService extends BaseBot {
}
private Response dealHistoryClick() {
- CollectHistoryDocument document = DplbotServiceUtil.getHistory(getUserId(), getAccessToken());
+ CollectHistoryDocument document = DplbotServiceUtil.getHistory(getUserId(), getAccessToken(), 0);
if (document == null) return new Response();
RenderDocument render = new RenderDocument(document);
addDirective(render);
@@ -407,7 +406,7 @@ public class DplBotService extends BaseBot {
return new Response();
}
}
- CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(getUserId(), getAccessToken(), appUserId);
+ CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(getUserId(), getAccessToken(), appUserId, 0);
if (document != null) {
RenderDocument render = new RenderDocument(document);
addDirective(render);
@@ -669,11 +668,55 @@ public class DplBotService extends BaseBot {
case "collect" :
case "unCollect" : dealCollectOrUnCollectIntent(detail, userId, intentName);break;
case "sendFlower" : dealSendFlowerIntent(detail, userId);break;
+ case "jump" : dealJumpIntent(detail, userId);break;
case "start" : dealStartIntent(detail, userId, intentRequest, intentName);break;
}
}
}
+ private void dealJumpIntent(OverTimeDetail detail, String userId) {
+ String trace = getSessionAttribute("trace");
+ if (trace == null || trace.length() < 2) {
+ detail.setResponse(buildErrorResponse("小悟跳不动了"));
+ LAST_OUTTIME_RESULT.put(userId,detail);
+ return;
+ }
+ String num = getSlot("sys.number");
+ if (num == null) {
+ detail.setResponse(buildErrorResponse("我没听清您要跳转的页面,请再说一遍"));
+ LAST_OUTTIME_RESULT.put(userId,detail);
+ return;
+ }
+ int index = Integer.parseInt(num);
+ char pageSign = trace.charAt(1);
+ switch (pageSign) {
+ case '1' : {
+ dealCollectHistoryJump(index, true, detail, userId);
+ break;
+ }
+ case '2' : {
+ dealCollectHistoryJump(index, false, detail, userId);
+ break;
+ }
+ }
+ LAST_OUTTIME_RESULT.put(userId,detail);
+ }
+
+ private void dealCollectHistoryJump(int index, boolean collect, OverTimeDetail detail, String userId) {
+ index = index == 0 ? index : index-1;
+ int start = index*CO_HI_PAGE_SIZE;
+ CollectHistoryDocument document;
+ if (collect) document = DplbotServiceUtil.getCollectPage(userId, getAccessToken(), getSessionAttribute("userId"), start);
+ else document = DplbotServiceUtil.getHistory(userId, getAccessToken(), start);
+ if (document != null) {
+ String cmt = String.valueOf(index+1);
+ setSessionAttribute("comCnt",cmt);
+ detail.getAttributes().put("comCnt", cmt);
+ } else {
+ detail.setResponse(buildErrorResponse("超出了范围无法跳到那一页"));
+ }
+ }
+
private void dealStartIntent(OverTimeDetail detail, String userId, IntentRequest intentRequest, String intentName) {
String trace = getSessionAttribute("trace");
if (trace != null && trace.length() > 2 && !StringUtils.endsWith(trace,File.separator)) {
@@ -859,8 +902,6 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put("recommand", null);
detail.getAttributes().put(PRE_COLLE, null);
}
- setSessionAttribute("pageSign", "4");
- detail.getAttributes().put("pageSign", "4");
setSessionAttribute(BACK_TRACE, "04");
detail.getAttributes().put(BACK_TRACE, "04");
LAST_OUTTIME_RESULT.put(userId, detail);
@@ -884,16 +925,15 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put(PRE_COLLE, null);
detail.getAttributes().put("count", recommandDocument.getCount());
}
- setSessionAttribute("pageSign", "3");
- detail.getAttributes().put("pageSign", "3");
setSessionAttribute(BACK_TRACE, "03");
detail.getAttributes().put(BACK_TRACE,"03");
LAST_OUTTIME_RESULT.put(userId, detail);
}
private void dealHistoryIntent(OverTimeDetail detail, String userId) {
- CollectHistoryDocument document = DplbotServiceUtil.getHistory(getUserId(), getAccessToken());
+ CollectHistoryDocument document = DplbotServiceUtil.getHistory(getUserId(), getAccessToken(), 0);
if (document == null) {
+ detail.setResponse(buildErrorResponse("没有更多了"));
LAST_OUTTIME_RESULT.put(userId, detail);
return;
}
@@ -915,17 +955,51 @@ public class DplBotService extends BaseBot {
}
private void dealNextPageIntent(OverTimeDetail detail, String userId, IntentRequest intentRequest) {
- String signPage = getSessionAttribute("pageSign");
- if (signPage == null) {
+ String signPage = getSessionAttribute("trace");
+ if (signPage == null || signPage.length() < 2) {
detail.setResponse(buildErrorResponse("哎呀,小悟累啦,滑不动了"));
LAST_OUTTIME_RESULT.put(userId,detail);
return;
}
- String pageIndex = getSessionAttribute("pageIndex");
- int sign = Integer.parseInt(signPage);
+ char sign = signPage.charAt(1);
int index = 0;
switch (sign) {
- case 6: {
+ case '1': {
+ String recommendNextCount = getSessionAttribute("comCnt");
+ if (recommendNextCount == null) {
+ recommendNextCount = "1";
+ }
+ int count = Integer.parseInt(recommendNextCount);
+ int start = count*CO_HI_PAGE_SIZE;
+ CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(userId, getAccessToken(),
+ getSessionAttribute("userId"), start);
+ if (document != null) {
+ String cmt = String.valueOf(count+1);
+ setSessionAttribute("comCnt",cmt);
+ detail.getAttributes().put("comCnt", cmt);
+ } else {
+ detail.setResponse(buildErrorResponse("已经到最后一页了"));
+ }
+ break;
+ }
+ case '2': {
+ String recommendNextCount = getSessionAttribute("comCnt");
+ if (recommendNextCount == null) {
+ recommendNextCount = "1";
+ }
+ int count = Integer.parseInt(recommendNextCount);
+ int start = count*CO_HI_PAGE_SIZE;
+ CollectHistoryDocument document = DplbotServiceUtil.getHistory(userId, getAccessToken(), start);
+ if (document != null) {
+ String cmt = String.valueOf(count+1);
+ setSessionAttribute("comCnt",cmt);
+ detail.getAttributes().put("comCnt", cmt);
+ } else {
+ detail.setResponse(buildErrorResponse("已经到最后一页了"));
+ }
+ break;
+ }
+ case '6': {
ExecuteCommands executeCommands = new ExecuteCommands();
SetPageCommand setPage = new SetPageCommand();
setPage.setComponentId("funnyPage");
@@ -936,7 +1010,7 @@ public class DplBotService extends BaseBot {
detail.getDirectives().add(executeCommands);
break;
}
- case 3: {
+ case '3': {
String recommendNextCount = getSessionAttribute("comCnt");
int count = 1;
if (recommendNextCount != null) count = Integer.parseInt(recommendNextCount);
@@ -955,7 +1029,8 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put("comCnt",String.valueOf(count+1));
break;
}
- case 4: {
+ case '4': {
+ String pageIndex = getSessionAttribute("pageIndex");
int count = 15;
String countStr = getSessionAttribute("count");
if (countStr != null) count = Integer.parseInt(countStr);
@@ -1002,7 +1077,7 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put("pageIndex", String.valueOf(index));
break;
}
- case 5:{
+ case '5':{
String category = getSessionAttribute("category");
if (category == null) category = "古风";
String categoryNextCount = getSessionAttribute("comCnt");
@@ -1029,17 +1104,49 @@ public class DplBotService extends BaseBot {
}
private void dealLastPageIntent(OverTimeDetail detail, String userId, IntentRequest intentRequest) {
- String signPage = getSessionAttribute("pageSign");
- if (signPage == null) {
+ String signPage = getSessionAttribute("trace");
+ if (signPage == null || signPage.length() < 2) {
detail.setResponse(buildErrorResponse("不好意思,小悟累啦,滑不动了"));
LAST_OUTTIME_RESULT.put(userId,detail);
return;
}
- String pageIndex = getSessionAttribute("pageIndex");
- int sign = Integer.parseInt(signPage);
+ char sign = signPage.charAt(1);
int index;
switch (sign) {
- case 6: {
+ case '1':{
+ String recommendNextCount = getSessionAttribute("comCnt");
+ if (recommendNextCount == null || "1".equals(recommendNextCount)) {
+ detail.setResponse(buildErrorResponse("客观,前面没啦,没法往前翻了"));
+ break;
+ }
+ int count = Integer.parseInt(recommendNextCount);
+ int start = (count-2)*CO_HI_PAGE_SIZE;
+ CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(userId, getAccessToken(),
+ getSessionAttribute("userId"), start);
+ if (document != null) {
+ String cmt = String.valueOf(count-1);
+ setSessionAttribute("comCnt",cmt);
+ detail.getAttributes().put("comCnt", cmt);
+ }
+ break;
+ }
+ case '2':{
+ String recommendNextCount = getSessionAttribute("comCnt");
+ if (recommendNextCount == null || "1".equals(recommendNextCount)) {
+ detail.setResponse(buildErrorResponse("客观,前面没啦,没法往前翻了"));
+ break;
+ }
+ int count = Integer.parseInt(recommendNextCount);
+ int start = (count-2)*CO_HI_PAGE_SIZE;
+ CollectHistoryDocument document = DplbotServiceUtil.getHistory(userId, getAccessToken(), start);
+ if (document != null) {
+ String cmt = String.valueOf(count-1);
+ setSessionAttribute("comCnt",cmt);
+ detail.getAttributes().put("comCnt", cmt);
+ }
+ break;
+ }
+ case '6': {
ExecuteCommands executeCommands = new ExecuteCommands();
SetPageCommand setPage = new SetPageCommand();
setPage.setComponentId("funnyPage");
@@ -1050,7 +1157,7 @@ public class DplBotService extends BaseBot {
detail.getDirectives().add(executeCommands);
break;
}
- case 3: {
+ case '3': {
String recommendNextCount = getSessionAttribute("comCnt");
if (recommendNextCount == null || "1".equals(recommendNextCount)) {
detail.setResponse(buildErrorResponse("客观,前面没啦,没法往前翻了"));
@@ -1068,7 +1175,8 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put("comCnt",String.valueOf(count-1));
break;
}
- case 4: {
+ case '4': {
+ String pageIndex = getSessionAttribute("pageIndex");
index = 0;
if (pageIndex != null) index = Integer.parseInt(pageIndex);
ExecuteCommands executeCommands = new ExecuteCommands();
@@ -1106,7 +1214,7 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put("pageIndex", String.valueOf(index));
break;
}
- case 5:{
+ case '5':{
String category = getSessionAttribute("category");
if (category == null) category = "古风";
String recommendNextCount = getSessionAttribute("comCnt");
@@ -1175,10 +1283,10 @@ public class DplBotService extends BaseBot {
return;
}
}
- CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(userId, getAccessToken(), appUserId);
+ CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(userId, getAccessToken(), appUserId, 0);
if (document == null) {
backToHome(detail);
- detail.setResponse(buildErrorResponse("您还未收藏过任何作品,快去收藏吧"));
+ detail.setResponse(buildErrorResponse("您还没有收藏任何作品"));
return;
}
RenderDocument render = new RenderDocument(document);
@@ -1227,7 +1335,11 @@ public class DplBotService extends BaseBot {
break;
}
}
- CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(userId, getAccessToken(), appUserId);
+ String recommendNextCount = getSessionAttribute("comCnt");
+ int count = 1;
+ if (recommendNextCount != null) count = Integer.parseInt(recommendNextCount);
+ CollectHistoryDocument document = DplbotServiceUtil.getCollectPage(userId, getAccessToken(),
+ appUserId, (count-1)*CO_HI_PAGE_SIZE);
if (document == null) {
backToHome(detail);
detail.setResponse(buildErrorResponse("您还未收藏过任何作品,快去收藏吧"));
@@ -1244,7 +1356,10 @@ public class DplBotService extends BaseBot {
}
case '2': {
//history
- CollectHistoryDocument document = DplbotServiceUtil.getHistory(getUserId(), getAccessToken());
+ String recommendNextCount = getSessionAttribute("comCnt");
+ int count = 1;
+ if (recommendNextCount != null) count = Integer.parseInt(recommendNextCount);
+ CollectHistoryDocument document = DplbotServiceUtil.getHistory(getUserId(), getAccessToken(), (count-1)*CO_HI_PAGE_SIZE);
if (document == null) {
backToHome(detail);
detail.setResponse(buildErrorResponse("哎呀,可能是您太久没玩了,历史记录已被清空"));
@@ -1356,8 +1471,6 @@ public class DplBotService extends BaseBot {
FUNNY_DEFAULT_DOCUMENT = document;
RenderDocument render = new RenderDocument(document);
addDirective(render);
- setSessionAttribute("pageSign", "6");
- detail.getAttributes().put("pageSign", "6");
detail.getDirectives().add(render);
LAST_OUTTIME_RESULT.put(userId, detail);
return;
@@ -1504,8 +1617,6 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put("category",categoryName);
this.setSessionAttribute("trace","05");
detail.getAttributes().put("trace","05");
- this.setSessionAttribute("pageSign","5");
- detail.getAttributes().put("pageSign","5");
return buildErrorResponse(new StringBuilder("为您打开").append(categoryName).append("类作品").toString());
}
else {
@@ -1537,7 +1648,7 @@ public class DplBotService extends BaseBot {
detail.getAttributes().put(PRE_COLLE, null);
String trace = getSessionAttribute(BACK_TRACE);
if (trace == null || trace.length() != 2) trace = "00";
- String backTrace = new StringBuilder(trace).append(botId).toString();
+ String backTrace = new StringBuilder(trace).append(botId).append(File.separator).toString();
this.setSessionAttribute(BACK_TRACE, backTrace);
detail.getAttributes().put(BACK_TRACE,backTrace);
this.addDirective(render);
@@ -1618,9 +1729,7 @@ public class DplBotService extends BaseBot {
trace = builder.append(productDetail.getBotAccount()).toString();
log.info("after trace------------:{}",trace);
this.setSessionAttribute(BACK_TRACE, trace);
- this.setSessionAttribute("pageSign",null);
detail.getAttributes().put(BACK_TRACE, trace);
- detail.getAttributes().put("pageSign",null);
return new Response();
}
@@ -1653,7 +1762,7 @@ public class DplBotService extends BaseBot {
xiaoDuOrderTB.setIsBuy(false);
xiaoDuOrderTB.setStatus(false);
xiaoDuOrderTB.setChOrderId(orderId);
- xiaoDuOrderTB.setTimeStamp(System.currentTimeMillis());
+ xiaoDuOrderTB.setTimeStamp(curTime);
return xiaoDuOrderTB;
}
@@ -1676,7 +1785,12 @@ public class DplBotService extends BaseBot {
stateCommand.setState("text");
stateCommand.setValue(USER_SEND_FLOWER+before);
executeCommands.addCommand(stateCommand);
- addDirective(executeCommands);
+ log.info("23333");
+ try {
+ addDirective(executeCommands);
+ } catch (Exception e) {
+ log.info(ExceptionUtils.getStackTrace(e));
+ }
} else {
str = "很抱歉,您没有支付成功";
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java
index 1dc757a..dfa7013 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java
@@ -43,7 +43,9 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import static ai.qiwu.com.xiaoduhome.common.Constants.CO_HI_PAGE_SIZE;
import static ai.qiwu.com.xiaoduhome.common.Constants.IMG_PREFIX;
import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.*;
import static ai.qiwu.com.xiaoduhome.service.ScheduleService.curTime;
@@ -54,9 +56,6 @@ import static ai.qiwu.com.xiaoduhome.service.ScheduleService.curTime;
*/
@Slf4j
public class DplbotServiceUtil {
-
- private static final byte BYTE_FILL = 1;
-
private static final int CORE = Runtime.getRuntime().availableProcessors();
static final ThreadPoolExecutor POOL = new ThreadPoolExecutor(CORE+1, 1500,
@@ -68,10 +67,11 @@ public class DplbotServiceUtil {
AppFavoriteTBRepository favoriteTBRepository = BaseHolder.getBean("appFavoriteTBRepository");
try {
UserBehaviorData data = USER_HISTORY.computeIfAbsent(userId, s -> new UserBehaviorData());
- List favoriteBotIDS = favoriteTBRepository.getFavoriteBotIds(Long.valueOf(usUserId));
- for(String botId : favoriteBotIDS) {
- data.getUserBotId2Collected().put(botId, BYTE_FILL);
+ List favoriteBots = favoriteTBRepository.getByUserId(Long.valueOf(usUserId));
+ for(AppFavoriteTB bot : favoriteBots) {
+ data.getUserBotId2Collected().put(bot.getBotId(), bot.getCreateTime().getTime());
}
+ log.info("UserBotId2Collected:"+data.getUserBotId2Collected());
} catch (Exception e) {
e.printStackTrace();
}
@@ -99,7 +99,7 @@ public class DplbotServiceUtil {
return usId;
}
- private static String getUserIdByToken(String accessToken) {
+ static String getUserIdByToken(String accessToken) {
try {
HashMap headers = new HashMap<>();
headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
@@ -235,8 +235,8 @@ public class DplbotServiceUtil {
static boolean didUserCollecThisProduct(String botAccount, String userID, String accessToken, String jytUserId) {
UserBehaviorData data = USER_HISTORY.get(userID);
if (data != null) {
- Byte count = data.getUserBotId2Collected().get(botAccount);
- return count != null;
+ Long time = data.getUserBotId2Collected().get(botAccount);
+ return time != null;
} else {
onLunchFillUserBehaviorData(accessToken, userID);
if (jytUserId == null) {
@@ -293,7 +293,7 @@ public class DplbotServiceUtil {
}
UserBehaviorData behaviorData = USER_HISTORY.get(userId);
if (behaviorData != null) {
- behaviorData.getUserBotId2Collected().put(botAccount, BYTE_FILL);
+ behaviorData.getUserBotId2Collected().put(botAccount, curTime);
} else {
if (jytUserId != null) {
UserBehaviorData data = USER_HISTORY.computeIfAbsent(userId, s -> new UserBehaviorData());
@@ -402,7 +402,7 @@ public class DplbotServiceUtil {
if (historyTB.getLastTime().equals(time)) continue;
historyTB.setLastTime(time);
}
- repository.saveAndFlush(historyTB);
+ repository.save(historyTB);
}
}
});
@@ -496,15 +496,34 @@ public class DplbotServiceUtil {
});
}
- static CollectHistoryDocument getCollectPage(String userId, String accessToken, String jytId) {
- Collection favoriteProducts;
+ static CollectHistoryDocument getCollectPage(String userId, String accessToken, String jytId, int start) {
+ List favoriteProducts = new ArrayList<>();
UserBehaviorData behaviorData = USER_HISTORY.get(userId);
+ int pageNum = 0;
if (behaviorData == null) {
onLunchFillUserBehaviorData(accessToken, userId);
- AppFavoriteTBRepository favorite = BaseHolder.getBean("appFavoriteTBRepository");
- favoriteProducts = favorite.getFavoriteBotIds(Long.parseLong(jytId));
+ if (jytId == null) jytId = getUserIdByToken(accessToken);
+ if (jytId != null) {
+ AppFavoriteTBRepository favorite = BaseHolder.getBean("appFavoriteTBRepository");
+ favoriteProducts = favorite.getFavoriteLimit(Long.parseLong(jytId), start);
+ }
}else {
- favoriteProducts = behaviorData.getUserBotId2Collected().keySet();
+ int bound = behaviorData.getUserBotId2Collected().size();
+ if (start >= bound) {
+ return null;
+ }
+ pageNum = bound/CO_HI_PAGE_SIZE + (bound%CO_HI_PAGE_SIZE == 0 ? 0 : 1);
+ TreeMap order = new TreeMap<>((o1, o2) -> (o1 < o2) ? 1 : ((o1.equals(o2)) ? 0 : -1));
+ for (Map.Entry entry: behaviorData.getUserBotId2Collected().entrySet()) {
+ order.put(entry.getValue(), entry.getKey());
+ }
+ int i = 0, e = start+CO_HI_PAGE_SIZE;
+ for (Map.Entry entry: order.entrySet()) {
+ if (i == e) break;
+ if (i++ >= start) {
+ favoriteProducts.add(entry.getValue());
+ }
+ }
}
if (favoriteProducts.size() == 0) return null;
ArrayList projectInfoList = new ArrayList<>();
@@ -524,7 +543,8 @@ public class DplbotServiceUtil {
data.setAuthorName(productDetail.getAuthorName());
projectInfoList.add(data);
}
- CollectHistoryDocument collectHistoryDocument = CollectHistoryUtils.getDocument(projectInfoList, true);
+ CollectHistoryDocument collectHistoryDocument = CollectHistoryUtils.getDocument(projectInfoList, true,
+ start/CO_HI_PAGE_SIZE+1, pageNum);
String idToken;
if (build.length() != 0) {
build.deleteCharAt(build.length()-1);
@@ -534,20 +554,32 @@ public class DplbotServiceUtil {
return collectHistoryDocument;
}
- static CollectHistoryDocument getHistory(String userId, String accessToken) {
+ static CollectHistoryDocument getHistory(String userId, String accessToken, int start) {
List historyProducts = new ArrayList<>();
UserBehaviorData behaviorData = USER_HISTORY.get(userId);
+ int pageNum = 0;
if (behaviorData == null) {
onLunchFillUserBehaviorData(accessToken, userId);
XiaoDuHistoryBotTimeRepository historyRepository = BaseHolder.getBean("xiaoDuHistoryBotTimeRepository");
- historyProducts = historyRepository.getByXiaoduUserId(userId);
+ historyProducts = historyRepository.getByXiaoduUserIdLimit(userId, start);
} else {
try {
+ int bound = behaviorData.getUserBotId2History().size();
+ if (start >= bound) return null;
+ pageNum = bound/CO_HI_PAGE_SIZE + (bound%CO_HI_PAGE_SIZE == 0 ? 0 : 1);
+ TreeMap order = new TreeMap<>((o1, o2) -> (o1 < o2) ? 1 : ((o1.equals(o2)) ? 0 : -1));
for (Map.Entry entry: behaviorData.getUserBotId2History().entrySet()) {
- XiaoDuHistoryBotIdTime history = new XiaoDuHistoryBotIdTime();
- history.setBotId(entry.getKey());
- history.setLastTime(entry.getValue());
- historyProducts.add(history);
+ order.put(entry.getValue(), entry.getKey());
+ }
+ int i = 0, end = start+CO_HI_PAGE_SIZE;
+ for (Map.Entry entry: order.entrySet()) {
+ if (i == end) break;
+ if (i++ >= start) {
+ XiaoDuHistoryBotIdTime history = new XiaoDuHistoryBotIdTime();
+ history.setBotId(entry.getValue());
+ history.setLastTime(entry.getKey());
+ historyProducts.add(history);
+ }
}
} catch (Exception e){}
}
@@ -557,6 +589,7 @@ public class DplbotServiceUtil {
int i = 1;
final StringBuilder build = new StringBuilder();
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
+ historyProducts.sort((o1, o2) -> (o1.getLastTime() entry: data.getUserBotId2History().entrySet()) {
+ String botId = entry.getKey();
+ Long time = entry.getValue();
+ XiaoDuHistoryTB historyTB = repository.getByXiaoduUserIdAndBotId(userId, botId);
+ if (historyTB == null) {
+ historyTB = new XiaoDuHistoryTB();
+ historyTB.setLastTime(time);
+ historyTB.setBotId(botId);
+ historyTB.setXiaoduUserId(userId);
+ } else {
+ if (historyTB.getLastTime().equals(time)) continue;
+ historyTB.setLastTime(time);
+ }
+ repository.save(historyTB);
+ }
+ data.setUserBotId2Collected(null);
+ data.setUserBotId2Flowers(null);
+ data.setUserBotId2History(null);
+ }
}
}
for (String userId: needClear) DplbotServiceUtil.USER_HISTORY.remove(userId);
--
libgit2 0.27.1