diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index f323d7b..ccf257a 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,18 +3,43 @@
+
+
+
+
+
+
+
+
-
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -58,102 +83,104 @@
-
+
-
-
+
+
+
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
+
+
-
-
+
+
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
@@ -172,22 +199,6 @@
- max-lines
- line-height
- onClick
- margin-bottom
- pageSign
- uploadImage
- RANKING_LIST
- max
- DU_ID_2_US_ID
- position
- LunchUtils
- onComplete
- CATEGORY_PROD_LIST
- USER_HISTORY
- URL_LS
- ONLINE_SERVER
initialize
OFFLINE_2_ONLINE
person
@@ -199,9 +210,25 @@
buildMP3Filename
init_url
requestTemplate方法创建文件
- url
resCode
resCode:{}
+ url
+ DU_ID_2_US_ID
+ PRODUCT_NAME_DETAIL
+ botAccount
+ HZ1_BOT_TO_NX2
+ PlayUtils
+ res
+ botName
+ PERSON_MOODURL
+ OFFLINE_SERVER
+ repeateName2Ids
+ successUpLoadFileIds
+ data
+ id2Info
+ log.info
+ del_record_callback_url
+ allRepeateName2Id
OPENID_CACHE
@@ -217,56 +244,56 @@
@@ -292,15 +319,6 @@
-
-
-
-
-
-
-
-
-
@@ -309,9 +327,9 @@
-
-
-
+
+
+
@@ -322,8 +340,6 @@
-
-
@@ -404,17 +420,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -429,6 +434,8 @@
+
+
@@ -442,15 +449,15 @@
-
-
+
+
-
+
@@ -521,12 +528,12 @@
-
-
-
+
+
+
-
+
@@ -534,12 +541,12 @@
-
-
-
+
+
+
-
+
@@ -547,12 +554,12 @@
-
-
+
+
-
+
@@ -869,11 +876,11 @@
-
-
+
+
@@ -898,10 +905,10 @@
+
+
-
-
@@ -992,7 +999,14 @@
-
+
+
+
+
+
+
+
+
@@ -1002,7 +1016,7 @@
-
+
@@ -1014,7 +1028,7 @@
-
+
@@ -1025,16 +1039,16 @@
-
+
-
-
+
+
-
+
@@ -1045,14 +1059,14 @@
-
+
-
-
+
+
@@ -1063,406 +1077,403 @@
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
+
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
-
-
+
+
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
@@ -1521,7 +1532,7 @@
- RokidBox
+ jdwhale
@@ -1545,7 +1556,7 @@
- Maven: aopalliance:aopalliance:1.0
+ Maven: antlr:antlr:2.7.7
diff --git a/dingdong/pom.xml b/dingdong/pom.xml
index 318d4d6..529c933 100644
--- a/dingdong/pom.xml
+++ b/dingdong/pom.xml
@@ -52,7 +52,7 @@
com.alibaba
fastjson
- 1.2.58
+ 1.2.60
diff --git a/jdwhale/pom.xml b/jdwhale/pom.xml
index 2c87019..5ee7d2d 100644
--- a/jdwhale/pom.xml
+++ b/jdwhale/pom.xml
@@ -51,7 +51,7 @@
com.alibaba
fastjson
- 1.2.58
+ 1.2.60
diff --git a/open/pom.xml b/open/pom.xml
index 3f019e6..0b28bfa 100644
--- a/open/pom.xml
+++ b/open/pom.xml
@@ -48,7 +48,7 @@
com.alibaba
fastjson
- 1.2.58
+ 1.2.60
dom4j
diff --git a/open/src/main/java/ai/qiwu/com/open/controller/OpenController.java b/open/src/main/java/ai/qiwu/com/open/controller/OpenController.java
index 24a567b..48f1612 100644
--- a/open/src/main/java/ai/qiwu/com/open/controller/OpenController.java
+++ b/open/src/main/java/ai/qiwu/com/open/controller/OpenController.java
@@ -68,4 +68,15 @@ public class OpenController {
}
return echostr;
}
+
+ @PutMapping("/test/{id}/")
+ public void test(@RequestBody Test test) {
+ System.out.println(test.getId());
+ }
+
+ @PutMapping("/other/{id}/")
+ public void test2(@RequestBody Test test, @PathVariable Integer id) {
+ System.out.println(test.getId());
+ System.out.println(id);
+ }
}
diff --git a/open/src/main/java/ai/qiwu/com/open/controller/Test.java b/open/src/main/java/ai/qiwu/com/open/controller/Test.java
new file mode 100644
index 0000000..6548cee
--- /dev/null
+++ b/open/src/main/java/ai/qiwu/com/open/controller/Test.java
@@ -0,0 +1,17 @@
+package ai.qiwu.com.open.controller;
+
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-9-11 下午6:39
+ */
+@Getter
+@Setter
+@ToString
+public class Test {
+ private Integer id;
+ private String name;
+}
diff --git a/ruoqi/pom.xml b/ruoqi/pom.xml
index 0e37e1a..a702e40 100644
--- a/ruoqi/pom.xml
+++ b/ruoqi/pom.xml
@@ -65,7 +65,7 @@
com.alibaba
fastjson
- 1.2.58
+ 1.2.60
diff --git a/spirit/pom.xml b/spirit/pom.xml
index 53227dd..bb9f9b2 100644
--- a/spirit/pom.xml
+++ b/spirit/pom.xml
@@ -54,7 +54,7 @@
com.alibaba
fastjson
- 1.2.58
+ 1.2.60
com.google.guava
diff --git a/tts_offline/pom.xml b/tts_offline/pom.xml
index c638c87..a391d05 100644
--- a/tts_offline/pom.xml
+++ b/tts_offline/pom.xml
@@ -48,7 +48,7 @@
com.alibaba
fastjson
- 1.2.58
+ 1.2.60
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/ChangeSound.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/ChangeSound.java
index b49f6b8..a7259c2 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/ChangeSound.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/ChangeSound.java
@@ -16,7 +16,7 @@ public class ChangeSound {
private static final List OPT_FLAG = Arrays.asList("l", "m", "s");
private static final List DEFAULT_DB_LIST = Arrays.asList("-70", "-60", "-20");;
private static final List DB_LIST = Arrays.asList("-50","-115","-40","-10","-30","-7","-20","-5","-10","-3","0","-3");
- private static final String OFOPTS = "-C 32";
+ private static final String OFOPTS = "-C 64";
private static void compand(Compand compand, List selfCommand) {
List dbList = compand.getDbList();
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/Config.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/Config.java
index 61c17e3..85ab670 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/Config.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/Config.java
@@ -20,8 +20,8 @@ public class Config {
private static Properties properties;
static {
- //String filename = "tts.properties";
- String filename = "ttsTest.properties";
+ String filename = "tts.properties";
+// String filename = "ttsTest.properties";
properties = new Properties();
try {
properties.load(new InputStreamReader(Config.class.getClassLoader().getResourceAsStream(filename), StandardCharsets.UTF_8));
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java
index a3cfde6..4ed6cd8 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java
@@ -28,8 +28,8 @@ public class OkHttp3Utils {
.build();
private static final OkHttpClient ShortTimeoutClient = new OkHttpClient.Builder()
- .connectTimeout(8, TimeUnit.SECONDS)
- .readTimeout(8, TimeUnit.SECONDS)
+ .connectTimeout(10, TimeUnit.SECONDS)
+ .readTimeout(10, TimeUnit.SECONDS)
.writeTimeout(10, TimeUnit.SECONDS)
.build();
@@ -186,7 +186,7 @@ public class OkHttp3Utils {
}
}
- public static Integer doPostReturnCode(String url, Map headers, Map params) throws IOException {
+ public static Integer doPostReturnCode(String url, Map headers) throws IOException {
Request.Builder builder = new Request.Builder();
Request request = builder.url(url).build();
@@ -195,13 +195,9 @@ public class OkHttp3Utils {
Iterator> headIterator = headers.entrySet().iterator();
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
- MultipartBody.Builder requestBuilder = new MultipartBody.Builder();
- Iterator> paramsIterator = params.entrySet().iterator();
- paramsIterator.forEachRemaining(e -> requestBuilder.addFormDataPart(e.getKey(), e.getValue()));
-
- builder.headers(headBuilder.build()).post(requestBuilder.build());
-
+ builder.headers(headBuilder.build()).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), "[]"));
try (Response response = client.newCall(builder.build()).execute(); ResponseBody body = response.body()){
+ log.info("doPostReturnCode:删除缓存回调地址返回信息:{}",body.string());
return response.code();
}catch (SocketTimeoutException e) {
log.error("捕获到SocketTimeoutException:{}", e.toString());
@@ -275,8 +271,8 @@ public class OkHttp3Utils {
Iterator> headIterator = headers.entrySet().iterator();
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
- builder.headers(headBuilder.build()).delete(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonStr));
- try (Response response = client.newCall(builder.build()).execute()){
+ builder.headers(headBuilder.build()).delete(RequestBody.create(MediaType.parse("application/json;charset=utf-8"), jsonStr));
+ try (Response response = client.newCall(builder.build()).execute();ResponseBody body = response.body()){
return response.code();
}catch (SocketTimeoutException e) {
log.error("捕获到SocketTimeoutException:{}", e.toString());
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTSUtils.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTSUtils.java
index 002fa1d..7bfa304 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTSUtils.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTSUtils.java
@@ -27,6 +27,11 @@ import java.util.zip.ZipFile;
public class TTSUtils {
private static final String STRIP = " /'\"";
private static final List TRIP_ENTER = Arrays.asList('\r','\n');
+ private static final String AB_REGEX = "\uD83C\uDD70(.*?)\uD83C\uDD71";
+
+ public static String getAbRegex() {
+ return AB_REGEX;
+ }
public static String charset(File file) {
String charset = "GB18030";
@@ -414,7 +419,6 @@ public class TTSUtils {
//System.out.println(needDelete.length);
//System.out.println(Arrays.toString(needDelete));
- File file = new File("/home/yf01/en.mp3");
- file.renameTo(new File("/home/yf01/springbootdemo/nihao.mp3"));
+ System.out.println(charset(new File("/usr/local/sublimeWorkplace/font/play.json")));
}
}
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 75b7540..2300d9d 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
@@ -108,4 +108,9 @@ public class TTSController {
ttService.delOneSen(data, response);
}
+ @PostMapping("/api/offline_callback")
+ public void offlineCallback(MultipartFile file, String url, String ids, HttpServletResponse response) {
+ ttService.offlineCallback(file, url, ids, response);
+ }
+
}
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java
index a50e8f6..ead0b7d 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java
@@ -25,6 +25,7 @@ public class GeneralMP3Data {
private Double pitch;
private String format;
+ private String npcName;
public GeneralMP3Data(String server, String text, String person, String tone, String botname,
Boolean cache, Double volume, Double speed, Double pitch) {
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Initialize.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Initialize.java
index 10acba0..d14b003 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Initialize.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/Initialize.java
@@ -21,13 +21,38 @@ import java.util.*;
@Component
@Slf4j
public class Initialize implements InitializingBean {
+ /**
+ * 默认person
+ */
private static String init_person = "B05";
+ /**
+ * 默认情绪
+ */
private String init_tone = "正常";
+ /**
+ * 默认请求地址
+ */
private String init_url; // 一定是线上url
+ /**
+ * 线上请求地址列表
+ */
private static final List URL_LS; //线上地址列表
+
+ /**
+ * 存储数据结构: person -> (name,sex,mood[],third_party)
+ */
private static final Map PERSON_INFO_ONLINE; //speakers_online
+
+
+ /**
+ * 存储数据结构: person_offline -> (name,sex,mood[],third_party)
+ */
private static final Map PERSON_INFO_OFFLINE; //speakers_offline
+
+ /**
+ * 存储数据结构: person_offline -> (name,sex,mood[],third_party)
+ */
private static final Map> PERSON_MOODURL; //api
private static final Map> OFFLINE_2_ONLINE;
private static final List THIRD_PARTY_TTS;
@@ -38,6 +63,7 @@ public class Initialize implements InitializingBean {
private static final String SERVER_NAME;
private static final String SERVER_URL;
private static final String AUDIO_DIR;
+ private static final String ZIP_DIR;
private static final Map ONLINE_SERVER = new HashMap<>();
private static final String OFFLINE_SERVER;
private static final String THIRD_PARTY;
@@ -62,6 +88,7 @@ public class Initialize implements InitializingBean {
SERVER_NAME = Config.getProperty("server_name");
SERVER_URL = Config.getProperty("server_url");
AUDIO_DIR = Config.getProperty("audio_dir");
+ ZIP_DIR = Config.getProperty("zip_dir");
UPLOADED_DIR = Config.getProperty("record_dir");
delCacheCallbackUrl = Config.getProperty("del_cache_callback_url");
delRecordCallbackUrl = Config.getProperty("del_record_callback_url");
@@ -225,6 +252,10 @@ public class Initialize implements InitializingBean {
return AUDIO_DIR;
}
+ static String getZipDir() {
+ return ZIP_DIR;
+ }
+
static String getUploadedDir() {return UPLOADED_DIR;}
static String getRecord_callback_url() {
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 39d49cf..ae8dfa8 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
@@ -12,6 +12,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
@@ -20,6 +21,8 @@ import java.nio.charset.Charset;
import java.util.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
/**
@@ -108,10 +111,10 @@ public class TTService {
result = TTSConstants.DELETE_OFFLINE_FAIL;
deleteOfflineResCode = 555;
}else {
- deleteOfflineResCode = OkHttp3Utils.doPostReturnCode(Initialize.getDelCacheCallbackUrl(), new HashMap<>(), new HashMap<>());
+ deleteOfflineResCode = OkHttp3Utils.doPostReturnCode(Initialize.getDelCacheCallbackUrl(), new HashMap<>());
}
} catch (Exception e) {
- log.error("删除offline地址的bot请求出错:{}", e.toString());
+ log.error("删除offline地址的bot请求出错:{},offlineStr:{}", e.toString(),offlineStr);
result = TTSConstants.DELETE_FAIL;
deleteOfflineResCode = 555;
}
@@ -165,7 +168,7 @@ public class TTService {
return;
}
}
- TTServiceUtil.buildMp3Response(response, new MP3Response(404), null, 404, false);
+ TTServiceUtil.buildMp3Response(response, new MP3Response(400), null, 400, false);
}
/**
@@ -182,6 +185,11 @@ public class TTService {
String platform = request.getPlatform();
List infoList = request.getText_info_ls();
String botName = request.getBotname();
+ if (botName == null) botName = "中控";
+ else if (botName.trim().equals("")) {
+ TTServiceUtil.buildTTS_lsResponse(response, new TTSResponse(400, "no botname"), null, 400);
+ return;
+ }
List> futures = new ArrayList<>();
List file_ls = new ArrayList<>();
boolean geneThird = request.getGen3rd() == null || request.getGen3rd() != 0;
@@ -190,7 +198,7 @@ public class TTService {
// person没有值或是不存在则赋予init_person
String person = info.getPerson();
if (StringUtils.isBlank(person)) person = initialize.getInit_person();
- log.info("person:{}", person);
+ //log.info("person:{}", person);
// text 字段不为空
String text = info.getText();
@@ -213,7 +221,7 @@ public class TTService {
}
// 获取该person的mood的url地址
url = moodUrlMap.get(tone);
- log.info("mood->url:{}", url);
+ //log.info("mood->url:{}", url);
}
String filepath = null;
@@ -225,37 +233,27 @@ public class TTService {
String npcName = info.getNpcName();
String fileName = TTSUtils.buildMP3Filename(text);
if (StringUtils.isNotBlank(npcName)) {
- String path;
- if (StringUtils.isBlank(botName)) {
- path = StringUtils.join(new String[]{Initialize.getAudioDir(), Initialize.getUploadedDir(),npcName, fileName}, File.separator);
- }else {
- path = StringUtils.join(new String[]{Initialize.getAudioDir(), botName, Initialize.getUploadedDir(),npcName, fileName}, File.separator);
- }
+ String path = StringUtils.join(new String[]{Initialize.getAudioDir(), botName, Initialize.getUploadedDir(),npcName, fileName}, File.separator);;
if (TTSUtils.doesFileExist(path)) filepath = path;
}
if (filepath == null) {
// 目录为:(audio_dir)/botname/person/tone
- String[] parents;
- if (StringUtils.isBlank(botName)) {
- parents = new String[]{Initialize.getAudioDir(), person, tone};
- }else {
- parents = new String[]{Initialize.getAudioDir(), botName, person, tone};
- }
- String folder = StringUtils.join(parents, File.separator);
+ String folder = StringUtils.join(new String[]{Initialize.getAudioDir(), botName, person, tone}, File.separator);
boolean createDirRes = TTSUtils.makedir(folder);
if (!createDirRes) {
log.error("tts_ls创建目录:{}失败",folder);
}
// 生成文件名
filepath = new StringBuilder(folder).append(File.separator).append(fileName).toString();
- log.info("tts_ls方法:filepath:{}", filepath);
+ //log.info("tts_ls方法:filepath:{}", filepath);
}
// 若文件不存在则先下载wav文件,之后转换成mp3
if (!TTSUtils.doesFileExist(filepath)) {
//log.info("general mp3");
- GeneralMP3Data data = new GeneralMP3Data(Initialize.getServerName(), text,
+ final GeneralMP3Data data = new GeneralMP3Data(Initialize.getServerName(), text,
person, tone, botName, true, volume, speed, pitch);
+ data.setNpcName(npcName);
final String path = filepath;
final String moodUrl = url;
Future future = POOL.submit(() -> generalMP3(moodUrl, data, path, "GET",true));
@@ -283,7 +281,7 @@ public class TTService {
}
// 阻塞等待mp3文件生成成功
- log.info("196:file list:{}", file_ls);
+ //log.info("196:file list:{}", file_ls);
for (Future future : futures) {
try {
// ResponseCodeWithData data = future.get(60, TimeUnit.SECONDS);
@@ -309,18 +307,12 @@ public class TTService {
// 成功则构建请求get_audio接口的请求url,包括参数信息,返回该url
if ("xiaoai".equals(platform)) {
String tmp_name = TTSUtils.pythonlistToStr(file_ls);
- String[] parents;
- String dirs = "[xiaoai]";
- if (StringUtils.isBlank(botName)) {
- parents = new String[]{Initialize.getAudioDir(), "xiaoai"};
- }else {
- parents = new String[]{Initialize.getAudioDir(), botName, "xiaoai"};
- dirs = String.format("[%s,xiaoai]", botName);
- }
+ String[] parents = new String[]{Initialize.getAudioDir(), botName, "xiaoai"};
+ String dirs = String.format("[%s,xiaoai]", botName);
String folder = StringUtils.join(parents, File.separator);
//String tmp_audio_name = String.format("%s/%s", folder, tmp_name);
String tmp_audio_name = new StringBuilder(folder).append(File.separator).append(tmp_name).toString();
- log.info("小爱tmp_audio_name:{}", tmp_audio_name);
+ //log.info("小爱tmp_audio_name:{}", tmp_audio_name);
try {
if (!TTSUtils.doesFileExist(tmp_audio_name)) {
TTSUtils.makedir(folder);
@@ -350,7 +342,7 @@ public class TTService {
}
String filename_64 = StringUtils.endsWith(filename, ".b64") ? filename : filename+".b64";
if (!TTSUtils.doesFileExist(filename_64)) {
- log.info("241:文件:{}不存在",filename_64);
+ //log.info("241:文件:{}不存在",filename_64);
TTSUtils.cpContent(filename_64.substring(0, filename_64.length()-4), filename_64);
}
}
@@ -423,7 +415,7 @@ public class TTService {
TTServiceUtil.buildServletResponse(servletResponse, new TTSResponse(404, String.format("%s的%s情绪的url为空", person, mood)), null, 404);
return;
}
- log.info("426:moodurl:{}", moodUrl);
+ //log.info("426:moodurl:{}", moodUrl);
} else {
mood = "正常";
}
@@ -457,7 +449,7 @@ public class TTService {
TTSUtils.makedir(folder);
filePath = StringUtils.join(new String[]{folder, fileName}, File.separator);
}
- log.info("filepath:{}", filePath);
+ //log.info("filepath:{}", filePath);
TTSResponse response = null;
// _type为json,则构建请求get_audio接口的信息
if ("json".equals(ttsRequest.get_type())) {
@@ -477,6 +469,7 @@ public class TTService {
if (!TTSUtils.doesFileExist(filePath) || requestMethod.equals("PUT")){
GeneralMP3Data data = new GeneralMP3Data(Initialize.getServerName(), ttsRequest.getText(),
person, mood, botName, true, volume, speed, pitch);
+ data.setNpcName(npcName);
ResponseCodeWithData codeWithData = generalMP3(moodUrl, data, filePath, requestMethod, getOnline);
if (codeWithData.getCode() != 200) {
log.error("下载:{}音频失败", moodUrl);
@@ -502,13 +495,17 @@ public class TTService {
* @param requestMethod 请求方法
* @return 返回状态码,调用方法通过此来判断方法是否成功
*/
- private ResponseCodeWithData generalMP3(String url, GeneralMP3Data data, String filePath, String requestMethod, boolean getOnline) {
+ private ResponseCodeWithData generalMP3(String url, GeneralMP3Data data, String filePath, String requestMethod,
+ boolean getOnline) {
//long startTime = System.currentTimeMillis();
ResponseCodeWithData res = null;
String wavFilename = filePath.substring(0, filePath.length()-4)+".wav";
+ if (StringUtils.isNotBlank(data.getNpcName())) {
+ if (genRecordWithChange(url, data, filePath, requestMethod, getOnline)) return new ResponseCodeWithData(200);
+ }
if (!TTSUtils.doesFileExist(wavFilename)) {
if (url == null) {
- res = dealThirdPartyBaiDu(data.getText(), data.getPerson(), wavFilename);
+ res = dealThirdPartyBaiDu(data.getText().trim(), data.getPerson(), wavFilename);
if (res.getCode() != 200) {
return res;
}
@@ -519,7 +516,7 @@ public class TTService {
longTime = false;
}
//long wavStartTime = System.currentTimeMillis();
- log.info("url:{}", url);
+ //log.info("url:{}", url);
res = requestTemplate(url, data, wavFilename, longTime, getOnline);
//long wavEndTime = System.currentTimeMillis();
//log.info("wav whole time:{}", (wavEndTime-wavStartTime)/1000.0);
@@ -534,7 +531,7 @@ public class TTService {
if (fileExist) {
new File(filePath).delete();
}
- res = changeSound(wavFilename, data.getVolume(), data.getSpeed(), data.getPitch(), filePath, res);
+ res = changeSound(wavFilename, data.getVolume(), data.getSpeed(), data.getPitch(), filePath);
}else if (!fileExist) {
if (offlineService.equals(url)) {
data.setFormat("mp3");
@@ -543,10 +540,10 @@ public class TTService {
log.error("线下请求音频文件:{},失败:{}",filePath, res);
}
if (!TTSUtils.doesFileExist(filePath)) {
- res = changeSound(wavFilename, data.getVolume(), data.getSpeed(), data.getPitch(), filePath, res);
+ res = changeSound(wavFilename, data.getVolume(), data.getSpeed(), data.getPitch(), filePath);
}
}else {
- res = changeSound(wavFilename, data.getVolume(), data.getSpeed(), data.getPitch(), filePath, res);
+ res = changeSound(wavFilename, data.getVolume(), data.getSpeed(), data.getPitch(), filePath);
// String executeResult = null;
// try {
// //long changeSoundStartTime = System.currentTimeMillis();
@@ -595,9 +592,67 @@ public class TTService {
return res;
}
+ private boolean genRecordWithChange(String url, GeneralMP3Data data, String personToneFilePath,
+ String requestMethod, boolean getOnline) {
+ String text = data.getText();
+ // 存储变量集合
+ List variableTextList = new ArrayList<>();
+ // 获取AB之间的变量,为空则忽略
+ Pattern pattern = Pattern.compile(TTSUtils.getAbRegex());
+ Matcher matcher = pattern.matcher(text);
+ while (matcher.find()) {
+ String variableText = matcher.group(1);
+ if (StringUtils.isNotBlank(variableText)) variableTextList.add(variableText);
+ }
+ //不存在变量则返回false,回到generalMP3方法整体处理
+ if (variableTextList.size() != 0) {
+ // 要合并的mp3地址集合
+ List combineMp3FilePathList = new ArrayList<>();
+ // 人工上传目录
+ String recordFolder = StringUtils.join(new String[]{Initialize.getAudioDir(), data.getBotname(),
+ Initialize.getUploadedDir(), data.getNpcName()}, File.separator);
+ // 非变量部分
+ String[] notVariableTextArray = pattern.split(text);
+ // 遍历所有非变量,若其mp3文件在人工目录下不存在则返回false回到generalMp3方法,整句合成
+ for (String notVariableText: notVariableTextArray) {
+ String notVariableTextPath = new StringBuilder(recordFolder).append(File.separator)
+ .append(TTSUtils.buildMP3Filename(notVariableText)).toString();
+ if (!TTSUtils.doesFileExist(notVariableTextPath)) return false;
+ combineMp3FilePathList.add(notVariableTextPath);
+ }
+ // 我们自己的语音合成目录
+ String usDir = StringUtils.join(new String[]{Initialize.getAudioDir(),data.getBotname(),
+ data.getPerson(), data.getTone()}, File.separator);
+ // 遍历所有变量,若其mp3文件在人工目录下不存在则调用generalMP3方法生成
+ for (String variableText: variableTextList) {
+ String variableTextFilename = TTSUtils.buildMP3Filename(variableText);
+ String variableTextPath = new StringBuilder(recordFolder).append(File.separator)
+ .append(variableTextFilename).toString();
+ if (!TTSUtils.doesFileExist(variableTextPath)) {
+ GeneralMP3Data variableData = new GeneralMP3Data(data.getServer(), data.getText(),data.getPerson(),
+ data.getTone(), data.getBotname(), data.getCache(),data.getVolume(),data.getSpeed(),data.getPitch());
+ String variablePathInUsDir = new StringBuilder(usDir).append(variableTextFilename).toString();
+ ResponseCodeWithData response = generalMP3(url, variableData, variablePathInUsDir, requestMethod, getOnline);
+ if (response.getCode() != 200) return false;
+ combineMp3FilePathList.add(variablePathInUsDir);
+ }
+ }
+ // 合并所有分段mp3文件
+ try {
+ TTSUtils.combineMp3File(combineMp3FilePathList, personToneFilePath);
+ } catch (Exception e) {
+ log.error("genRecordWithChange:合成音频失败:{}",e.toString());
+ return false;
+ }
+ return true;
+ }
+ return false;
+ }
+
private ResponseCodeWithData changeSound(String wavFilename, double volume, double speed,
- double pitch, String mp3FilePath, ResponseCodeWithData res) {
+ double pitch, String mp3FilePath) {
String executeResult = null;
+ ResponseCodeWithData res = null;
try {
//long changeSoundStartTime = System.currentTimeMillis();
executeResult = CallPython.changeSound(wavFilename, volume, speed,
@@ -651,7 +706,7 @@ public class TTService {
return new ResponseCodeWithData(402, "requestTemplate请求无法获取到结果,该请求信息是:"+data.toString());
}
int resCode = res.getCode();
- log.info("resCode:{}, offlineService:{},url:{}", resCode, offlineService, url);
+ //log.info("resCode:{}, offlineService:{},url:{}", resCode, offlineService, url);
if (resCode == 200) {
return res;
}
@@ -668,14 +723,14 @@ public class TTService {
}
if (initialize.doesThisMoodUrlWithOnline0(url)) {
url = initialize.getInit_url();
- log.info("requestTemplate方法,init_url:{}",url);
+ //log.info("requestTemplate方法,init_url:{}",url);
}
List personTon = Initialize.getUrl2PersonTon(url);
data.setPerson(personTon.get(0));
data.setTone(personTon.get(1));
dataStr = JSON.toJSONString(data);
res = requestLongTimeout(url, dataStr, new File(filePath));
- log.info("requestLongTimeout返回结果:{}",res.getCode());
+ //log.info("requestLongTimeout返回结果:{}",res.getCode());
} catch (Exception e) {
log.error("person:{},mood:{}, url not found", person, mood);
res = null;
@@ -726,13 +781,15 @@ public class TTService {
private ResponseCodeWithData dealThirdPartyBaiDu(String text, String person, String filepath) {
boolean result;
- try {
- result = TTSUtils.createFile(filepath);
- } catch (Exception e) {
- log.error("创建第三方wav文件失败:{}", e.toString());
- return new ResponseCodeWithData(555, "创建第三方wav文件失败");
- }
- if (!result) return new ResponseCodeWithData(555, "创建第三方wav文件失败");
+// try {
+// result = TTSUtils.createFile(filepath);
+// } catch (Exception e) {
+// log.error("创建第三方wav文件失败:{}", e.toString());
+// return new ResponseCodeWithData(555, "创建第三方wav文件失败");
+// }
+// if (!result) return new ResponseCodeWithData(555, "创建第三方wav文件失败");
+
+ text = text.replaceAll("\\{/(.+?)/}", "");
result = ThirdPartyService.thirdPartyCall(text, Initialize.theThirdPartysPer(person), filepath, person);
if (result) {
return new ResponseCodeWithData(200, "创建第三方wav文件成功");
@@ -744,32 +801,43 @@ public class TTService {
initialize.afterPropertiesSet();
}
+ /**
+ * 上传单个音频文件;
+ * 参数说明:tid:句子id; botName:作品帐号名(上传人的标识); npcName:npc名称; text:语音文件对应的句子; file:录音文件
+ * @param data
+ * @param response
+ */
public void uploadOneSen(UploadOneSenData data, HttpServletResponse response) {
- if (StringUtils.isAnyBlank(data.getBotName(), data.getNpcName(), data.getText()) || data.getFile() == null) {
+ //tid,botName,npcName,text,file皆不能为空,否则返回400
+ if (StringUtils.isAnyBlank(String.valueOf(data.getTid()),data.getBotName(), data.getNpcName(), data.getText()) || data.getFile() == null) {
TTServiceUtil.buildUploadResponse(response, new TTSResponse(400, "参数不能为空"), 400);
return;
}
+ // audio_dir/botname/record/npcname
String folder = StringUtils.join(new String[]{Initialize.getAudioDir(), data.getBotName(),
Initialize.getUploadedDir(), data.getNpcName()},File.separator);
+ // absolute filepath
String filename = StringUtils.join(new String[]{folder, TTSUtils.buildMP3Filename(data.getText())}, File.separator);
+ // 删除之前已存在的文件
if (TTSUtils.doesFileExist(filename) && !new File(filename).delete()) {
TTServiceUtil.buildUploadResponse(response, new TTSResponse(555, "删除已存在的文件失败:"+filename), 555);
return;
}
+ // 创建目录
else if (!TTSUtils.makedir(folder)) {
TTServiceUtil.buildUploadResponse(response, new TTSResponse(555, "创建目录失败:"+folder), 555);
return;
}
+ // 写入文件
try {
data.getFile().transferTo(new File(filename));
} catch (IOException e) {
log.error("写入文件出错:{}",ExceptionUtils.getStackTrace(e));
}
-// RecordCallbackData callbackData = new RecordCallbackData();
-// callbackData.setTid(data.getTid());
String msg="";
+ // 回调http://localhost:18082/text/offline/upload/callback,无需管其是否成功
try {
- msg = OkHttp3Utils.doPostJsonStr(Initialize.getRecord_callback_url(), JSON.toJSONString(data.getTid()));
+ msg = OkHttp3Utils.doPostJsonStr(Initialize.getRecord_callback_url(), JSON.toJSONString(new int[]{data.getTid()}));
} catch (Exception e) {
msg = "post record_callback_url error";
log.error("post record_callback_url error:{}",ExceptionUtils.getStackTrace(e));
@@ -777,18 +845,30 @@ public class TTService {
TTServiceUtil.buildUploadResponse(response, new TTSResponse(200,msg), 200);
}
+ /**
+ * 批量音频文件;
+ * 参数说明: botName作品帐号名(上传人的标识), npcName:npc名称, file:压缩文件zip
+ * @param data
+ * @param response
+ */
public void uploadOneNpc(UploadOneSenData data, HttpServletResponse response) {
+ // audio_dir/botname/record/npcname
final String folder = StringUtils.join(new String[]{Initialize.getAudioDir(), data.getBotName(),
Initialize.getUploadedDir(), data.getNpcName()}, File.separator);
+ TTSUtils.makedir(folder);
long currentTime = System.currentTimeMillis();
- final String zipFolder = new StringBuilder(folder).append(File.separator).append(currentTime).toString();
+ // zipDir(专门存放压缩包及解压缩后的文件的)/botname+timestamp(确保文件名唯一,防止统一用户删除操作与上传操作的冲突)
+ final String zipFolder = new StringBuilder(Initialize.getZipDir()).append(File.separator)
+ .append(data.getBotName()).append(currentTime).toString();
TTSUtils.makedir(zipFolder);
+ // 构建服务器上该压缩包的绝对路径
String zipFilename = data.getFile().getName();
if (zipFilename == null) zipFilename = new StringBuilder(String.valueOf(currentTime)).append(".zip").toString();
else if (!StringUtils.endsWith(zipFilename, ".zip")) zipFilename = zipFilename+".zip";
-
String filename = new StringBuilder(zipFolder).append(File.separator).append(zipFilename).toString();
+
+ // 写入文件
try {
data.getFile().transferTo(new File(filename));
} catch (IOException e) {
@@ -796,17 +876,17 @@ public class TTService {
TTServiceUtil.buildUploadResponse(response, new TTSResponse(555, "写入上传文件出错:"+filename), 555);
return;
}
+ // 检查压缩包格式是否正确,标准是不含有目录
if (!TTSUtils.checkZipFile(filename)){
TTServiceUtil.buildUploadResponse(response, new TTSResponse(400, "压缩包结构不正确"), 400);
return;
}
+ // 解压
if (!TTSUtils.unZip(zipFolder, filename)) {
TTServiceUtil.buildUploadResponse(response, new TTSResponse(555, "压缩包解压失败"), 555);
return;
}
-// if (!new File(filename).delete()) {
-// log.error("压缩包:{}删除失败",filename);
-// }
+ // 压缩包中之应该只含有一个csv文件
File[] csvFiles = new File(zipFolder).listFiles((dir, name) -> StringUtils.endsWith(name, ".csv"));
if (csvFiles == null || csvFiles.length != 1) {
int count = csvFiles == null ? 0 : csvFiles.length;
@@ -814,29 +894,60 @@ public class TTService {
return;
}
File csvFile = csvFiles[0];
+ // 判断该文件的编码
String encoding = TTSUtils.charset(csvFile);
- List successUpLoadFileIds = new ArrayList<>();
- HashMap origin2finallyName = new HashMap<>();
- HashMap oldNameToId = new HashMap<>();
- HashMap allFailUpLoadList = new HashMap<>();
+ // 所有成功上传的id,若多个id指向同一文件,任何一个成功则都应该将其余的id加入集合中
+ final List successUpLoadFileIds = new ArrayList<>();
+ // 所有失败了的id以及失败原因
+ HashMap allFailUpLoadId2Reason = new HashMap<>();
+ // 每句话的id指向它的具体信息,
+ HashMap id2Info = new HashMap<>();
+ // 修改后的文件名->该句话的id
+ HashMap allOldname2Id = new HashMap<>();
+ // 指向同一音频文件,且text相同的文件名->id,该信息用来提用户,这种text相同指向文件相同的情况是否是他想要的
+ HashMap> allRepeateId2Info = new HashMap<>();
+ // 指向相同文件的所有语句id集合
+ HashMap> repeateName2Ids = new HashMap<>();
+
+ // 意料之外的错误发生,无法判断程序进度,记录该种情况最后根据情况返回相应的信息
boolean unExpectException = false;
- int count = 0;
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(csvFile), Charset.forName(encoding)))){
- String row;
+ String row = reader.readLine(); // 去掉首行
while ((row = reader.readLine()) != null) {
- row = TTSUtils.tripEnter(row);
+ row = TTSUtils.tripEnter(row); // 去掉末尾所有换行符
// id,text,isUpload,filename
- String[] arr = row.split(",");
+ String[] arr = row.split(","); // 切分
String audioFileName = arr[3];
+ // filename列不为空代表用户为该句指定了文件
if (StringUtils.isNotBlank(audioFileName)) {
- count++;
+ id2Info.put(arr[0],arr); // 存储该行的详细信息,用于之后展示错误信息使用
+ // 修正文件名,不包含后缀名的加上.mp3后缀名
audioFileName = StringUtils.endsWith(audioFileName,".mp3") ? audioFileName : audioFileName+".mp3";
- if (origin2finallyName.containsKey(audioFileName)) {
- allFailUpLoadList.put(arr[0], String.format("名字与id是%s的文件名相同",oldNameToId.get(audioFileName)));
- continue;
+ String previousId;
+ // 若之前已有相同文件名,则将该文件的id加入集合,以该文件名为key
+ if ((previousId = allOldname2Id.putIfAbsent(audioFileName, arr[0])) != null) {
+ List repeateIds = repeateName2Ids.computeIfAbsent(audioFileName, s -> new ArrayList<>());
+ repeateIds.add(arr[0]);
+ //遍历指向相同文件的语句,生成text与当前一样的语句的提示信息
+ for (String repeateId: repeateIds) {
+ if (!repeateId.equals(arr[0]) && arr[1].equals(id2Info.get(repeateId)[1])){
+ List repeateInfo = allRepeateId2Info.computeIfAbsent(arr[0], s -> new ArrayList<>());
+ repeateInfo.add(String.format("其与id是%s指向同一音频文件,且text相同,这是您想要的结果吗",repeateId));
+ }
+ }
+ // repeateName2Ids并不包含首个重复语句的id,所以这里需要再与首个重复id语句进行判断
+ if (id2Info.get(previousId)[1].equals(arr[1])) {
+ List repeateInfo = allRepeateId2Info.computeIfAbsent(arr[0], s -> new ArrayList<>());
+ repeateInfo.add(String.format("其与id是%s指向同一音频文件,且text相同,这是您想要的结果吗",previousId));
+ }
+ // 之前的重复语句并不一定执行成功,若不成功则放行当前的这条重复语句
+ if (successUpLoadFileIds.contains(previousId)) {
+ continue;
+ }
}
+ // zip压缩包目录,解压也在该目录下
String fileInPackage = new StringBuilder(zipFolder).append(File.separator).append(audioFileName).toString();
String md5Name = TTSUtils.buildMP3Filename(arr[1]);
String usFilename = new StringBuilder(folder).append(File.separator).append(md5Name).toString();
@@ -847,87 +958,81 @@ public class TTService {
result = usFile.delete();
}
if (result) {
- String freshPath = new StringBuilder(folder).append(File.separator)
- .append().toString();
- String oldPath = new StringBuilder(zipFolder).append(File.separator).append(oldFileName).toString();
- if (new File(oldPath).renameTo(new File(freshPath))) {
- successUpLoadFileIds.add(oldNameToId.get(oldFileName));
+ if (new File(fileInPackage).renameTo(usFile)) {
+ successUpLoadFileIds.add(arr[0]);
}
- origin2finallyName.put(audioFileName, md5Name);
- oldNameToId.put(audioFileName, arr[0]);
- //result = new File(fileInPackage).renameTo(usFile);
-// if (result) {
-// successUpLoadFileIds.add(arr[0]);
-// }else {
-// log.error("更改名字失败,原名:{},新名:{}",fileInPackage, usFilename);
-// }
}else {
- allFailUpLoadList.put(arr[0], "程序原因,请重新上传");
+ allFailUpLoadId2Reason.put(arr[0], "程序原因,请重新上传");
log.error("删除之前的就音频失败:{}",fileInPackage);
}
}
else {
- allFailUpLoadList.put(arr[0], "压缩包中没有该mp3文件");
+ allFailUpLoadId2Reason.put(arr[0], "压缩包中没有该mp3文件");
}
}
}
-// boolean result = csvFile.delete();
-// if (!result) log.error("删除csv文件失败:{}",csvFile.getAbsolutePath());
} catch (Exception e) {
-// boolean result = csvFile.delete();
-// if (result) log.error("解析csv文件出错:{}",ExceptionUtils.getStackTrace(e));
-// else log.error("解析csv文件出错,且删除cvs文件:{}失败:{}",csvFile.getAbsolutePath(),ExceptionUtils.getStackTrace(e));
unExpectException = true;
log.error("解析csv文件出错:{}",ExceptionUtils.getStackTrace(e));
}
String msg = "失败请重新上传;";
- if (origin2finallyName.size() != 0) {
- for (String oldFileName : origin2finallyName.keySet()) {
- String freshPath = new StringBuilder(folder).append(File.separator)
- .append(origin2finallyName.get(oldFileName)).toString();
- String oldPath = new StringBuilder(zipFolder).append(File.separator).append(oldFileName).toString();
- if (new File(oldPath).renameTo(new File(freshPath))) {
- successUpLoadFileIds.add(oldNameToId.get(oldFileName));
+ //log.info("repeateName2Ids:{}",repeateName2Ids);
+ if (successUpLoadFileIds.size() != 0) {
+ if (repeateName2Ids.size() != 0) {
+ List repeatNameIdList = new ArrayList<>();
+ for (String successId: successUpLoadFileIds) {
+ String name = id2Info.get(successId)[3];
+ name = StringUtils.endsWith(name,".mp3") ? name : name+".mp3";
+ List nameRepeats = repeateName2Ids.get(name);
+ if (nameRepeats != null && nameRepeats.size()!=0) repeatNameIdList.addAll(nameRepeats);
}
+ if (repeatNameIdList.size() != 0) successUpLoadFileIds.addAll(repeatNameIdList);
}
- try {
- String str = OkHttp3Utils.doPostJsonStr(Initialize.getRecord_callback_url(), JSON.toJSONString(successUpLoadFileIds));
- if (str != null) {
- UploadCallbackResponse callbackResponse = JSON.parseObject(str, UploadCallbackResponse.class);
- if (callbackResponse.getCode() == 200) {
- msg = new StringBuilder("已成功上传的文件id列表:").append(JSON.toJSONString(successUpLoadFileIds)).toString();
- if (!unExpectException) {
- int failCount;
- if ((failCount=allFailUpLoadList.size()) == 0) {
- msg = String.format("本次上传的全部%d个文件全部成功",count);
- }
- else {
- msg = new StringBuilder("本次总共上传文件数").append(count).append(";其中成功上传")
- .append(successUpLoadFileIds.size()).append("个文件;").append("\n").append("未成功个数").append(failCount)
- .append(";它们的id以及失败原因如下:").append(allFailUpLoadList).toString();
- }
- }else {
- int failCount;
- if ((failCount=allFailUpLoadList.size()) == 0) {
- msg = new StringBuilder("本次成功上传了").append(count)
- .append("个文件,剩下的并未成功,请对照下面的成功id列表进行检查:")
- .append(successUpLoadFileIds).toString();
- }
- else {
- msg = new StringBuilder("本次成功上传了").append(count).append("个文件;").append("\n")
- .append("未成功个数").append(failCount)
- .append(";已知的失败文件id及原因如下:").append(allFailUpLoadList)
- .append("其余部分皆未成功,请重新上传这些失败的文件").toString();
- }
+ POOL.submit(() -> {
+ try {
+ String str = OkHttp3Utils.doPostJsonStr(Initialize.getRecord_callback_url(), JSON.toJSONString(successUpLoadFileIds));
+ if (str != null) {
+ UploadCallbackResponse callbackResponse = JSON.parseObject(str, UploadCallbackResponse.class);
+ if (callbackResponse.getCode() != 200) {
+ log.warn("打包上传回调返回信息:{}",str);
}
- }else if (callbackResponse.getMsg() != null) msg = new StringBuilder(msg).append(callbackResponse.getMsg()).toString();
+ }
+ } catch (Exception e) {
+ log.error("打包上传回调出现错误:{}",ExceptionUtils.getStackTrace(e));
}
- } catch (Exception e) {
- log.error("回调出现错误:{}",ExceptionUtils.getStackTrace(e));
+ });
+ if (!unExpectException) {
+ int failCount;
+ if ((failCount=allFailUpLoadId2Reason.size()) == 0) {
+ msg = String.format("本次上传的%d个文件全部成功",successUpLoadFileIds.size());
+ }
+ else {
+ msg = new StringBuilder("本次上传总数").append(id2Info.size()).append(";其中成功上传")
+ .append(successUpLoadFileIds.size()).append("个文件;").append("\n").append("未成功个数").append(failCount)
+ .append(";它们的id以及失败原因如下:").append(allFailUpLoadId2Reason).toString();
+ }
+ }else {
+ int failCount;
+ if ((failCount=allFailUpLoadId2Reason.size()) == 0) {
+ msg = new StringBuilder("本次上传总数").append(id2Info.size())
+ .append("其中成功上传了").append(successUpLoadFileIds.size())
+ .append("个文件,剩下的并未成功,请对照下面的成功id列表进行检查:")
+ .append(successUpLoadFileIds).toString();
+ }
+ else {
+ msg = new StringBuilder("本次上传总数").append(id2Info.size()).append(";其中成功上传")
+ .append("个文件;").append("\n").append("未成功个数").append(failCount)
+ .append(";已知的失败文件id及原因如下:").append(allFailUpLoadId2Reason)
+ .append(";其余部分皆未成功,请重新上传这些失败的文件").toString();
+ }
+ }
+ if (allRepeateId2Info.size() != 0) {
+ msg = new StringBuilder(msg).append(";\n").append("下面为提醒信息,请确认:").append(allRepeateId2Info).toString();
}
}
POOL.submit(() -> TTSUtils.deleteFile(new File(zipFolder)));
+ //log.info("msg:{}",msg);
TTServiceUtil.buildUploadResponse(response, new TTSResponse(200, msg), 200);
}
@@ -941,11 +1046,12 @@ public class TTService {
boolean result = true;
if (TTSUtils.doesFileExist(filePath)) {
result = new File(filePath).delete();
+ // 目录为空则删除目录
}
if (result) {
String msg=null;
try {
- String str = OkHttp3Utils.doPostJsonStr(Initialize.getDelRecordCallbackUrl(), JSON.toJSONString(data.getTid()));
+ String str = OkHttp3Utils.doPostJsonStr(Initialize.getDelRecordCallbackUrl(), JSON.toJSONString(new int[]{data.getTid()}));
log.info("删除地址回调结果:{}",str);
} catch (Exception e) {
msg = "post del_record_callback error";
@@ -958,4 +1064,42 @@ public class TTService {
}
}
+ public void offlineCallback(MultipartFile file, String url, String ids, HttpServletResponse response) {
+ String filename = file.getName();
+ if (!StringUtils.endsWith(filename, ".zip") || StringUtils.isAnyBlank(url, ids)) {
+ log.info("offlineCallback:{}",filename);
+ TTServiceUtil.buildUploadResponse(response, new TTSResponse(400, "not is zipfile or params is not right"), 400);
+ return;
+ }
+ String filePath = StringUtils.join(new String[]{Initialize.getZipDir(), filename}, File.separator);
+ try {
+ file.transferTo(new File(filePath));
+ if (!TTSUtils.unZip(Initialize.getAudioDir(), filePath)) {
+ POOL.submit(() -> new File(filePath).delete());
+ TTServiceUtil.buildUploadResponse(response, new TTSResponse(555, "压缩包解压失败"), 555);
+ return;
+ }
+ POOL.submit(() -> new File(filePath).delete());
+ ids = ids.trim();
+ if (StringUtils.isBlank(ids) || ids.length() <= 2) {
+ TTServiceUtil.buildUploadResponse(response, new TTSResponse(400, "ids为空"), 400);
+ return;
+ }
+ String[] idList = ids.substring(1, ids.length()-1).split(",");
+ String[] idTrimList = new String[idList.length];
+ for (int i = 0; i < idList.length; i++) idTrimList[i] = idList[i].trim();
+ try {
+ String callResponse = OkHttp3Utils.doPostJsonStr(url, JSON.toJSONString(idTrimList));
+ log.info("offlineCallback:回调返回{}",callResponse);
+ } catch (Exception e) {
+ log.error("offlineCallback回调出错:{}",ExceptionUtils.getStackTrace(e));
+ }
+ } catch (Exception e) {
+ log.error("offlineCallback出错:{}",ExceptionUtils.getStackTrace(e));
+ TTServiceUtil.buildUploadResponse(response, new TTSResponse(555, "程序出错"), 555);
+ return;
+ }
+ TTServiceUtil.buildUploadResponse(response, new TTSResponse(200), 200);
+ }
+
}
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/baidu/ThirdPartyService.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/baidu/ThirdPartyService.java
index 381f885..ee26543 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/baidu/ThirdPartyService.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/baidu/ThirdPartyService.java
@@ -9,6 +9,7 @@ import ai.qiwu.com.tts_service.service.LieHuSchedule;
import com.baidu.aip.speech.AipSpeech;
import com.baidu.aip.speech.TtsResponse;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.RandomStringUtils;
import java.io.*;
import java.util.HashMap;
@@ -40,12 +41,12 @@ public class ThirdPartyService {
return person.substring(0,i+1);
}
- public static boolean synthesis(String text, int per, String filepath) {
+ private static boolean synthesis(String text, int per, String filepath) {
HashMap options = new HashMap<>();
-// options.put("spd", correctSoundParams(speed, false));
+ options.put("spd", 5);
// options.put("pit", correctSoundParams(pitch, true));
-// options.put("vol", correctSoundParams(volume, false));
- options.put("aue", 6);
+ options.put("vol", 5);
+ options.put("aue", 4);
options.put("per", per);
TtsResponse res = CLIENT.synthesis(text, "zh", 1, options);
if (res.getResult() == null) {
@@ -75,7 +76,7 @@ public class ThirdPartyService {
headers.put("Authorization", TTSConstants.LIE_HU.AUTHORIZATION+LieHuSchedule.getLieHuToken());
HashMap params = new HashMap<>();
params.put("tex", text);
- params.put("sn", UUID.randomUUID().toString());
+ params.put("sn", new StringBuilder(RandomStringUtils.randomAlphabetic(5)).append(System.currentTimeMillis()).toString());
params.put("pdt", TTSConstants.LIE_HU.PDT);
params.put("per", per);
params.put("aue", "4");
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 d9a7e69..3f94190 100644
--- a/tts_service/src/main/resources/tts.properties
+++ b/tts_service/src/main/resources/tts.properties
@@ -2,6 +2,7 @@ server_name=aws-nx2
server_url=http://aws-nx2.chewrobot.com:9663
audio_dir=/root/TTS-service/audio
record_dir=record
+zip_dir=/root/TTS-service/mqwZip
online_sever=1:http://dev01.centaurstech.com,2:http://dev01.centaurstech.com
offline_server=http://dev01.centaurstech.com:9001
#第三方tts标记
diff --git a/tts_service/src/main/resources/ttsTest.properties b/tts_service/src/main/resources/ttsTest.properties
index d51ba43..002b4c5 100644
--- a/tts_service/src/main/resources/ttsTest.properties
+++ b/tts_service/src/main/resources/ttsTest.properties
@@ -4,11 +4,12 @@ record_dir=record
audio_dir=/root/GameEditor/mqw/project/tts/audio
online_sever=1:http://dev01.centaurstech.com,2:http://dev01.centaurstech.com
offline_server=http://dev01.centaurstech.com:9001
+zip_dir=/root/GameEditor/mqw/project/ttsTest/mqwZip
#第三方tts标记
third_party_tts_text =third_party_tts
-del_cache_callback_url=http://localhost:18082/text/offline/delCache/callback
-record_callback_url=http://localhost:18082/text/offline/upload/callback
-del_record_callback_url=http://localhost:18082/text/offline/delUpload/callback
+del_cache_callback_url=http://aws-nx2.chewrobot.com:18082/text/offline/delCache/callback
+record_callback_url=http://aws-nx2.chewrobot.com:18082/text/offline/upload/callback
+del_record_callback_url=http://aws-nx2.chewrobot.com:18082/text/offline/delUpload/callback
python_interpreter=/usr/bin/python3
diff --git a/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/controller/XiaoAiController.java b/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/controller/XiaoAiController.java
index 53fe188..af42306 100644
--- a/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/controller/XiaoAiController.java
+++ b/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/controller/XiaoAiController.java
@@ -4,13 +4,8 @@ import ai.qiwu.mi.xiaoai.model.request.XiaoAiRequest;
import ai.qiwu.mi.xiaoai.model.response.XiaoAiResponse;
import ai.qiwu.mi.xiaoai.service.XiaoAiService;
import lombok.extern.slf4j.Slf4j;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.ResponseBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
/**
* @author 苗权威
@@ -24,7 +19,7 @@ public class XiaoAiController {
private XiaoAiService xiaoAiService;
@RequestMapping("/xiaoai")
- public @ResponseBody XiaoAiResponse xiaoai(@RequestBody XiaoAiRequest request) {
+ public XiaoAiResponse xiaoai(@RequestBody XiaoAiRequest request) {
//log.info("请求:"+request);
XiaoAiResponse response = xiaoAiService.getResponse(request);
log.info("响应:"+response);
diff --git a/xiaodu/pom.xml b/xiaodu/pom.xml
index 477fde3..7544bd4 100644
--- a/xiaodu/pom.xml
+++ b/xiaodu/pom.xml
@@ -94,7 +94,7 @@
com.alibaba
fastjson
- 1.2.58
+ 1.2.60
diff --git a/xiaoduhome/pom.xml b/xiaoduhome/pom.xml
index e49cfd5..a710d36 100644
--- a/xiaoduhome/pom.xml
+++ b/xiaoduhome/pom.xml
@@ -38,6 +38,13 @@
spring-boot-starter-thymeleaf
2.1.6.RELEASE
+
+
+
+
+
+
+
commons-fileupload
commons-fileupload
@@ -66,11 +73,6 @@
2.1.6.RELEASE
- com.alibaba
- fastjson
- 1.2.58
-
-
org.projectlombok
lombok
1.18.8
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 28a109b..fbf799f 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
@@ -51,6 +51,7 @@ public interface Constants {
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";
+ String DEFAULT_ASIDE_IMG_URL = "http://aws-nx2.chewrobot.com:8888/Editor/Editor/static/img/default.png";
}
interface PRODUCT_INTRO {
@@ -139,6 +140,7 @@ public interface Constants {
String FLOWER_INTERFACE = "http://aws-nx2.chewrobot.com:18082/api/flower/count";
String USER_CLOOEC_LIST = "http://aliyun-hz1.chewrobot.com:18082/api/favorite";
String USER_ID_BY_TOKEN = "https://account-center-test.chewrobot.com/api/sdk/user/info";
+ String ASIDE_IMG_URL = "http://aws-nx2.chewrobot.com:18082/api/works";
}
interface BAI_DU {
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 ff1e8fd..0c00561 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
@@ -184,4 +184,10 @@ public class OkHttp3Utils {
return response.body().string();
}
}
+
+ public static void main(String[] args) {
+ String url = "http://192.168.1.82:8081/bot/condition";
+ String authorization = "Basic ZXlKaGJHY2lPaUpJVXpVeE1pSXNJbWxoZENJNk1UVTJPRFU1T0RBM05Dd2laWGh3SWpveE5UWTROalE0TkRjMGZRLmV5SnBaQ0k2TXpZc0ltRjFkR2h2Y21sMGVTSTZNWDAueDdDY2Zhak12ZmRkbExwUFVZYXFkUmZVNF91S2xBX0Q5NzZTaGZTQWUzLWh6SVg0Wm91bFdkNkpvS1pRQ0VlQ0N5b3k0dXRLRzJYVDhFZG9aZHJyU2c6czAwcGVyczNjcmV0";
+
+ }
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
index 8ef8928..b6b92b6 100644
--- 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
@@ -408,28 +408,4 @@ public class TempleUtils {
pojo.setItems(pojoItems);
return pojo;
}
-
- public static void main(String[] args) {
- new Thread(() -> {
- long start = System.currentTimeMillis();
- int i = 5000;
- while (i-- > 0) {
- getPlayDocument("gsgdg", "sgege", "dsgrgh");
- }
- System.out.println("pojo:"+(System.currentTimeMillis()-start));
- }).start();
-
- new Thread(() -> {
- long start = System.currentTimeMillis();
- int i = 5000;
- while (i-- > 0) {
- MyDocument document = JSON.parseObject(getDPLTemple("static/json/play.json"), MyDocument.class);
- document.getMainTemplate().getItems().get(1).setHeaderTitle("gsgdg");
- List- container = document.getMainTemplate().getItems().get(2).getItems();
- container.get(1).setSrc("sgege");
- container.get(0).getItems().get(0).setText("dsgrgh");
- }
- System.out.println("fastJson:"+(System.currentTimeMillis()-start));
- }).start();
- }
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java
index d42c8b1..3dd5d92 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java
@@ -23,6 +23,7 @@ public class LunchUtils {
public static LunchDocument buildLunchDocument() {
LunchDocument document = new LunchDocument();
+ document.setDuration(240000);
LunchMainTemplate mainTemplate = new LunchMainTemplate();
document.setMainTemplate(mainTemplate);
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayPojo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayPojo.java
index 8331e1d..0b8f5cc 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayPojo.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayPojo.java
@@ -25,17 +25,34 @@ public class PlayPojo {
private String width;
private String headerTitle;
private Boolean hasBackIcon;
- private String componentId;
+ private String right;
private List items;
- private String bottom;
- private String padding;
+ @JsonProperty("padding-left")
+ private String paddingLeft;
+ @JsonProperty("padding-top")
+ private String paddingTop;
+ @JsonProperty("padding-right")
+ private String paddingRight;
+ @JsonProperty("padding-vertical")
+ private String paddingVertical;
+ @JsonProperty("border-radius")
+ private String borderRadius;
+ @JsonProperty("background-color")
+ private String backgroundColor;
+ private String text;
+ @JsonProperty("scale-type")
+ private String scaleType;
+ private String componentId;
@JsonProperty("font-size")
private String fontSize;
@JsonProperty("font-style")
private String fontStyle;
+ private String padding;
private String looping;
private String autoplay;
private List onEnd;
+ @JsonProperty("margin-left")
+ private String marginLeft;
private List hints;
- private String text;
+ private List onClick;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java
index 36c98ab..4f026c4 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java
@@ -1,9 +1,11 @@
package ai.qiwu.com.xiaoduhome.common.temple.play;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
+import com.baidu.dueros.data.response.directive.audioplayer.Play;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
/**
@@ -12,37 +14,135 @@ import java.util.List;
*/
public class PlayUtils {
- public static PlayDocument getPlayDocument(String headerName, String audio, String text) {
+ private static final PlayPojo PLAY_HINT = buildHints();
+ private static final PlayPojo PLAY_BACK_IMG = buildLunchBackgroundImg();
+ private static final PlayPojo PLAY_FLOWER = buildFlower();
+ private static final PlayPojo PLAY_LOGO = buildLogoImage();
+ private static final PlayPojo PLAY_COLLECT = buildCollect();
+ private static final PlayPojo PLAY_UN_COLLECT = buildUnCollect();
+
+ public static PlayDocument getPlayDocument(String headerName, String aside, String asideImg,
+ String audio, String text, boolean collected) {
PlayDocument document = new PlayDocument();
+ document.setDuration(180000);
PlayMainTemplate mainTemplate = new PlayMainTemplate();
document.setMainTemplate(mainTemplate);
- getPlayPojo(mainTemplate.getItems(),headerName, audio, text);
+ PlayPojo collectComponent = PLAY_COLLECT;
+ if (!collected) collectComponent = PLAY_UN_COLLECT;
+ mainTemplate.setItems(Arrays.asList(PLAY_BACK_IMG, buildLunchHead(headerName), PLAY_LOGO,
+ buildAside(aside), buildAsideImage(asideImg), buildWholeContainer(audio, text)
+ ,collectComponent, PLAY_FLOWER, PLAY_HINT));
return document;
}
- private static void getPlayPojo(List items, String headerName, String audioSrc, String textContent) {
- // ---------image----------
- PlayPojo image = new PlayPojo();
- image.setType("Image");
- image.setPosition("absolute");
- image.setTop("0dp");
- image.setLeft("0dp");
- image.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg");
- image.setHeight("100%");
- image.setWidth("100%");
+ public static PlayPojo buildCollect() {
+ PlayPojo collectCon = new PlayPojo();
+ collectCon.setType("Container");
+ collectCon.setLeft("300dp");
+ collectCon.setTop("380dp");
+ collectCon.setPosition("absolute");
+
+ PlayPojo frame = new PlayPojo();
+ frame.setType("Frame");
+ frame.setWidth("120dp");
+ frame.setHeight("120dp");
+ frame.setPaddingTop("20dp");
+ frame.setBorderRadius("60dp");
+ frame.setBackgroundColor("rgba(0,0,0,0.4)");
+
+ PlayPojo backGroundImg = new PlayPojo();
+ backGroundImg.setType("Image");
+ backGroundImg.setComponentId("playCollect");
+ backGroundImg.setMarginLeft("35dp");
+ backGroundImg.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/collec.png");
+ backGroundImg.setHeight("50dp");
+ backGroundImg.setWidth("50dp");
+ backGroundImg.setScaleType("fitCenter");
+ backGroundImg.setOnClick(Collections.singletonList(new Event("SendEvent", "playButton")));
+
+// PlayPojo text = new PlayPojo();
+// text.setType("Text");
+// text.setMarginLeft("22dp");
+// text.setText("收藏作品");
+// text.setFontSize("20dp");
+
+ frame.setItems(Collections.singletonList(backGroundImg));
+ collectCon.setItems(Collections.singletonList(frame));
+ return collectCon;
+ }
+
+ public static PlayPojo buildUnCollect() {
+ PlayPojo collectCon = new PlayPojo();
+ collectCon.setType("Container");
+ collectCon.setLeft("300dp");
+ collectCon.setTop("380dp");
+ collectCon.setPosition("absolute");
+
+ PlayPojo frame = new PlayPojo();
+ frame.setType("Frame");
+ frame.setWidth("120dp");
+ frame.setHeight("120dp");
+ frame.setPaddingTop("20dp");
+ frame.setBorderRadius("60dp");
+ frame.setBackgroundColor("rgba(0,0,0,0.4)");
+
+ PlayPojo backGroundImg = new PlayPojo();
+ backGroundImg.setType("Image");
+ backGroundImg.setComponentId("playCollect");
+ backGroundImg.setMarginLeft("35dp");
+ backGroundImg.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/uncollec.png");
+ backGroundImg.setHeight("50dp");
+ backGroundImg.setWidth("50dp");
+ backGroundImg.setScaleType("fitCenter");
+ backGroundImg.setOnClick(Collections.singletonList(new Event("SendEvent", "playButton")));
+
+// PlayPojo text = new PlayPojo();
+// text.setType("Text");
+// text.setMarginLeft("22dp");
+// text.setText("取消收藏");
+// text.setFontSize("20dp");
+
+ frame.setItems(Collections.singletonList(backGroundImg));
+ collectCon.setItems(Collections.singletonList(frame));
+ return collectCon;
+ }
+
+ public static PlayPojo buildFlower() {
+ PlayPojo flowerCon = new PlayPojo();
+ flowerCon.setType("Container");
+ flowerCon.setLeft("600dp");
+ flowerCon.setTop("380dp");
+ flowerCon.setPosition("absolute");
- items.add(image);
+ PlayPojo frame = new PlayPojo();
+ frame.setType("Frame");
+ frame.setWidth("120dp");
+ frame.setHeight("120dp");
+ frame.setPaddingTop("20dp");
+ frame.setBorderRadius("60dp");
+ frame.setBackgroundColor("rgba(0,0,0,0.4)");
- // --------header-------------
- PlayPojo header = new PlayPojo();
- header.setType("Header");
- if (headerName == null) header.setHeaderTitle("");
- else header.setHeaderTitle(headerName);
- header.setHasBackIcon(false);
+ PlayPojo backGroundImg = new PlayPojo();
+ backGroundImg.setType("Image");
+ backGroundImg.setMarginLeft("35dp");
+ backGroundImg.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/flower.png");
+ backGroundImg.setHeight("50dp");
+ backGroundImg.setWidth("50dp");
+ backGroundImg.setScaleType("fitCenter");
+ backGroundImg.setOnClick(Collections.singletonList(new Event("SendEvent", "playButton")));
- items.add(header);
+// PlayPojo text = new PlayPojo();
+// text.setType("Text");
+// text.setMarginLeft("22dp");
+// text.setText("鲜花打赏");
+// text.setFontSize("20dp");
- // --------whole-------------
+ frame.setItems(Collections.singletonList(backGroundImg));
+ flowerCon.setItems(Collections.singletonList(frame));
+ return flowerCon;
+ }
+
+ public static PlayPojo buildWholeContainer(String audioSrc, String textContent) {
PlayPojo whole = new PlayPojo();
whole.setType("Container");
whole.setHeight("100%");
@@ -53,16 +153,15 @@ public class PlayUtils {
textContainer.setType("Container");
textContainer.setPadding("35dp");
textContainer.setPosition("absolute");
- textContainer.setBottom("120dp");
+ textContainer.setTop("140dp");
+
PlayPojo text = new PlayPojo();
text.setType("Text");
text.setComponentId("text");
text.setFontSize("28dp");
text.setFontStyle("normal");
text.setText(textContent);
- List textConItems = new ArrayList<>();
- textConItems.add(text);
- textContainer.setItems(textConItems);
+ textContainer.setItems(Collections.singletonList(text));
PlayPojo audio = new PlayPojo();
audio.setType("Audio");
@@ -71,74 +170,102 @@ public class PlayUtils {
audio.setAutoplay("true");
audio.setSrc(audioSrc);
Event onEnd = new Event("SendEvent","audio");
- List audioOnEndEventList = new ArrayList<>();
- audioOnEndEventList.add(onEnd);
- audio.setOnEnd(audioOnEndEventList);
-
- List wholeItems = new ArrayList<>();
- wholeItems.add(textContainer);
- wholeItems.add(audio);
- whole.setItems(wholeItems);
-
- items.add(whole);
-
- //--------footer--------
- PlayPojo footerContainer = new PlayPojo();
- footerContainer.setType("Container");
- footerContainer.setPosition("absolute");
- footerContainer.setWidth("100%");
- footerContainer.setLeft("0");
- footerContainer.setBottom("0");
-
- PlayPojo footer = new PlayPojo();
- footer.setType("Footer");
- footer.setHints(Arrays.asList("我要送花","收藏","回到首页","返回"));
-
- List footerContainerItems = new ArrayList<>();
- footerContainerItems.add(footer);
- footerContainer.setItems(footerContainerItems);
-
- items.add(footer);
+ audio.setOnEnd(Collections.singletonList(onEnd));
+
+ whole.setItems(Arrays.asList(textContainer, audio));
+ return whole;
}
- public static PlayPojo getWholePojo(String audioSrc, String textContent) {
- PlayPojo whole = new PlayPojo();
- whole.setType("Container");
- whole.setHeight("100%");
- whole.setWidth("100%");
- whole.setComponentId("whole");
+ private static PlayPojo buildLunchBackgroundImg() {
+ PlayPojo backGroundImg = new PlayPojo();
+ backGroundImg.setType("Image");
+ backGroundImg.setPosition("absolute");
+ backGroundImg.setTop("0dp");
+ backGroundImg.setLeft("0dp");
+ backGroundImg.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg");
+ backGroundImg.setHeight("100%");
+ backGroundImg.setWidth("100%");
+
+ return backGroundImg;
+ }
+
+ private static PlayPojo buildLunchHead(String headName) {
+ PlayPojo head = new PlayPojo();
+ head.setType("Header");
+ head.setHeaderTitle(headName);
+ head.setHasBackIcon(false);
+
+ return head;
+ }
+
+ private static PlayPojo buildLogoImage() {
+ PlayPojo logo = new PlayPojo();
+ logo.setType("Image");
+ logo.setPosition("absolute");
+ logo.setSrc("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/logo.png");
+ logo.setWidth("200dp");
+ logo.setHeight("60dp");
+ logo.setTop("10dp");
+ logo.setRight("10dp");
+ return logo;
+ }
+
+ private static PlayPojo buildAside(String aside) {
+ PlayPojo asideContainer = new PlayPojo();
+ asideContainer.setType("Container");
+ asideContainer.setPosition("absolute");
+ asideContainer.setLeft("130dp");
+ asideContainer.setTop("135dp");
+
+ PlayPojo frame = new PlayPojo();
+ frame.setType("Frame");
+ frame.setPaddingLeft("50dp");
+ frame.setPaddingRight("15dp");
+ frame.setPaddingVertical("10dp");
+ frame.setBorderRadius("10dp");
+ frame.setBackgroundColor("rgba(0,0,0,0.4)");
- PlayPojo textContainer = new PlayPojo();
- textContainer.setType("Container");
- textContainer.setPadding("35dp");
- textContainer.setPosition("absolute");
- textContainer.setBottom("120dp");
PlayPojo text = new PlayPojo();
text.setType("Text");
- text.setComponentId("text");
- text.setFontSize("28dp");
- text.setFontStyle("normal");
- text.setText(textContent);
- List textConItems = new ArrayList<>();
- textConItems.add(text);
- textContainer.setItems(textConItems);
+ text.setText(aside);
+ text.setComponentId("asideText");
+ text.setHeight("50dp");
- PlayPojo audio = new PlayPojo();
- audio.setType("Audio");
- audio.setComponentId("audioCom");
- audio.setLooping("false");
- audio.setAutoplay("true");
- audio.setSrc(audioSrc);
- Event onEnd = new Event("SendEvent","audio");
- List audioOnEndEventList = new ArrayList<>();
- audioOnEndEventList.add(onEnd);
- audio.setOnEnd(audioOnEndEventList);
+ frame.setItems(Collections.singletonList(text));
+ asideContainer.setItems(Collections.singletonList(frame));
+ return asideContainer;
+ }
- List wholeItems = new ArrayList<>();
- wholeItems.add(textContainer);
- wholeItems.add(audio);
- whole.setItems(wholeItems);
+ private static PlayPojo buildAsideImage(String src) {
+ PlayPojo asideContainer = new PlayPojo();
+ asideContainer.setType("Container");
+ asideContainer.setPosition("absolute");
+ asideContainer.setLeft("60dp");
+ asideContainer.setTop("120dp");
- return whole;
+ PlayPojo frame = new PlayPojo();
+ frame.setType("Frame");
+ frame.setWidth("100dp");
+ frame.setHeight("100dp");
+ frame.setBorderRadius("50dp");
+
+ PlayPojo image = new PlayPojo();
+ image.setType("Image");
+ image.setComponentId("asideImg");
+ image.setSrc(src);
+ frame.setWidth("100dp");
+ image.setHeight("100dp");
+ image.setScaleType("fitCenter");
+
+ frame.setItems(Collections.singletonList(image));
+ asideContainer.setItems(Collections.singletonList(frame));
+ return asideContainer;
+ }
+
+ private static PlayPojo buildHints() {
+ PlayPojo hint = new PlayPojo();
+ hint.setType("Footer");
+ hint.setHints(Arrays.asList("我要送花", "收藏", "回到首页", "返回"));
+ return hint;
}
}
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
new file mode 100644
index 0000000..8fca36c
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/TestBuild.java
@@ -0,0 +1,139 @@
+package ai.qiwu.com.xiaoduhome.pojo;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.eclipsesource.json.JsonObject;
+import lombok.*;
+
+import java.nio.ByteBuffer;
+import java.nio.charset.Charset;
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-9-16 上午11:35
+ */
+@Builder
+@Getter
+@Setter
+@ToString
+@NoArgsConstructor
+@AllArgsConstructor
+public class TestBuild {
+ private Integer id;
+ private String name;
+
+ public static String unicodeToString(String unicode) {
+ StringBuffer string = new StringBuffer();
+ String[] hex = unicode.split("\\\\u");
+ for (int i = 1; i < hex.length; i++) {
+ int data = Integer.parseInt(hex[i], 16);// 转换出每一个代码点
+ string.append((char) data);// 追加成string
+ }
+ return string.toString();
+ }
+
+ public static String decodeUnicode2(String dataStr) {
+ int start = 0;
+ int end = 0;
+ final StringBuffer buffer = new StringBuffer();
+ while (start > -1) {
+ end = dataStr.indexOf("\\u", start + 2);
+ String charStr = null;
+ if (end == -1) {
+ charStr = dataStr.substring(start + 2, dataStr.length());
+ } else {
+ charStr = dataStr.substring(start + 2, end);
+ }
+ char letter = (char) Integer.parseInt(charStr, 16);
+ buffer.append(new Character(letter).toString());
+ start = end;
+ }
+ return buffer.toString();
+ }
+
+ public static String unicodetoString(String unicode) {
+ if (unicode == null || "".equals(unicode)) {
+ return null;
+ }
+ StringBuilder sb = new StringBuilder();
+ int i = -1;
+ int pos = 0;
+ while ((i = unicode.indexOf("\\u", pos)) != -1) {
+ sb.append(unicode, pos, i);
+ if (i + 5 < unicode.length()) {
+ pos = i + 6;
+ sb.append((char) Integer.parseInt(unicode.substring(i + 2, i + 6), 16));
+ }
+ }
+ sb.append(unicode.substring(pos));
+ return sb.toString();
+ }
+
+ public static String decodeUnicode(String str) {
+ Charset set = Charset.forName("UTF-16");
+ Pattern p = Pattern.compile("\\\\u([0-9a-fA-F]{4})");
+ Matcher m = p.matcher( str );
+ int start = 0 ;
+ int start2 = 0 ;
+ StringBuffer sb = new StringBuffer();
+ while( m.find( start ) ) {
+ start2 = m.start() ;
+ if( start2 > start ){
+ String seg = str.substring(start, start2) ;
+ sb.append( seg );
+ }
+ String code = m.group( 1 );
+ int i = Integer.valueOf( code , 16 );
+ byte[] bb = new byte[ 4 ] ;
+ bb[ 0 ] = (byte) ((i >> 8) & 0xFF );
+ bb[ 1 ] = (byte) ( i & 0xFF ) ;
+ ByteBuffer b = ByteBuffer.wrap(bb);
+ sb.append( String.valueOf( set.decode(b) ).trim() );
+ start = m.end() ;
+ }
+ start2 = str.length() ;
+ if( start2 > start ){
+ String seg = str.substring(start, start2) ;
+ sb.append( seg );
+ }
+ return sb.toString() ;
+ }
+ public static void main(String[] args) {
+ String s = "\uD83C\uDD70(.*?)\uD83C\uDD71";
+ String test = "23424ijoij\uD83C\uDD70\uD83C\uDD71ghoiwugh\uD83C\uDD70oihjoihoih\uD83C\uDD71gerwgwgh";
+ String test2 = "342gsegsergh";
+ //test = new String(test.getBytes(), Charset.forName("UTF-8"));
+ Pattern pattern = Pattern.compile(s);
+ Matcher matcher = pattern.matcher(test2);
+ //System.out.println(matcher.groupCount());
+ System.out.println(matcher.find());
+// while (matcher.find()) {
+// System.out.println(matcher.group(1));
+// }
+ System.out.println(Arrays.toString(pattern.split(test2)));
+ String test3 = "sgiejogwi{/sgrg/}sgkw{/3432iuh/}sge4g{/sfg/}fs/gerg/}";
+ String test4 = "gewgewghwhwh";
+ System.out.println(test3.replaceAll("\\{/(.+?)/}", ""));
+ System.out.println(test3.replaceAll("\\{/(.+?)/\\}", ""));
+ System.out.println(test4.replaceAll("\\{/(.+?)/}", ""));
+ System.out.println(test4.replaceAll("\\{/(.+?)/\\}", ""));
+ System.out.println(JSON.toJSONString(new Long[]{}));
+ String test5 = "[1, 2, 3]";
+ String[] idList = test5.substring(1, test5.length()-1).split(",");
+ String[] idTrimList = new String[idList.length];
+ for (int i = 0; i < idList.length; i++) idTrimList[i] = idList[i].trim();
+ System.out.println(JSON.toJSONString(idTrimList));
+ String test6 = "[ ]";
+ String test7 = "";
+ String[] idList2 = test6.substring(1, test6.length()-1).split(",");
+ System.out.println(Arrays.toString(idList2));
+ System.out.println(test6.length());
+ }
+}
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
new file mode 100644
index 0000000..45684e2
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java
@@ -0,0 +1,19 @@
+package ai.qiwu.com.xiaoduhome.pojo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-9-10 下午4:46
+ */
+@Getter
+@Setter
+public class UserBehaviorData {
+ private volatile HashMap userBotId2History = new HashMap<>();
+ private volatile HashMap userBotId2Flowers = new HashMap<>();
+ private volatile HashMap userBotId2Collected = new HashMap<>();
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Event.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Event.java
index 7e1b834..31c04df 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Event.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/dpl/Event.java
@@ -30,7 +30,6 @@ public class Event {
private String repeatCount;
private String position;
private String value;
- private List onComplete;
public Event() {
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/playAside/AsideImage.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/playAside/AsideImage.java
new file mode 100644
index 0000000..304fa7a
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/playAside/AsideImage.java
@@ -0,0 +1,20 @@
+package ai.qiwu.com.xiaoduhome.pojo.playAside;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Map;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-9-10 下午6:17
+ */
+@Getter
+@Setter
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class AsideImage {
+ private String authorName;
+ private String worksBannerImgUrl;
+ private Map npcHeadImgUrl;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/playAside/AsideImageResponse.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/playAside/AsideImageResponse.java
new file mode 100644
index 0000000..a0a904b
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/playAside/AsideImageResponse.java
@@ -0,0 +1,18 @@
+package ai.qiwu.com.xiaoduhome.pojo.playAside;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-9-10 下午6:16
+ */
+@Getter
+@Setter
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class AsideImageResponse {
+ private Integer code;
+ private String msg;
+ private AsideImage data;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFlowerTBRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFlowerTBRepository.java
index db1ca70..e9633e7 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFlowerTBRepository.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFlowerTBRepository.java
@@ -28,4 +28,6 @@ public interface AppFlowerTBRepository extends JpaRepository boolean exists(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 0adac6d..f1c86a1 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
@@ -28,4 +28,7 @@ public interface GameProjectTbRepository extends JpaRepository postRankBot(Integer begin);
+
+ @Query(value = "select bot_account from game_project_tb where apply_status=1",nativeQuery = true)
+ List getAllOnTableProductIds();
}
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 6d220b7..7898f41 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
@@ -19,9 +19,11 @@ import ai.qiwu.com.xiaoduhome.pojo.*;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Data;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Item;
import ai.qiwu.com.xiaoduhome.pojo.dpl.MyDocument;
+import ai.qiwu.com.xiaoduhome.pojo.playAside.AsideImageResponse;
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.primary.GameProjectTbRepository;
import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryTBRepository;
import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuOrderTbRepository;
import com.alibaba.fastjson.JSON;
@@ -48,6 +50,7 @@ import com.baidu.dueros.data.response.directive.pay.Charge;
import com.baidu.dueros.model.Response;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.data.domain.Example;
import javax.servlet.http.HttpServletRequest;
@@ -68,7 +71,7 @@ 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.*;
-import static ai.qiwu.com.xiaoduhome.service.ScheduleService.CATEGORY;
+import static ai.qiwu.com.xiaoduhome.service.ScheduleService.*;
/**
* @author 苗权威
@@ -88,7 +91,7 @@ public class DplBotService extends BaseBot {
private static final int CORE = Runtime.getRuntime().availableProcessors();
- private static final ThreadPoolExecutor POOL = new ThreadPoolExecutor(CORE+1, 1500,
+ public 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;
@@ -97,7 +100,9 @@ public class DplBotService extends BaseBot {
private static volatile FunnyDocument FUNNY_DEFAULT_DOCUMENT;
- private static final ConcurrentHashMap> USER_HISTORY = new ConcurrentHashMap<>();
+ private static final ConcurrentHashMap USER_HISTORY = new ConcurrentHashMap<>();
+
+ private final byte byteFill = 1;
static {
// LOAD_DOCUMENT = JSON.parseObject(getDPLTemple("static/json/onLunch2.json"), MyDocument.class);
@@ -135,14 +140,48 @@ public class DplBotService extends BaseBot {
RenderDocument renderDocument = new RenderDocument(FIRST_PAGE);
this.addDirective(renderDocument);
OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, Constants.WelcomeWord.WELCOME);
+
POOL.submit(() -> {
XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
- USER_HISTORY.put(getUserId(), repository.getUserHostory(getUserId()));
- log.info("用户历史记录:{}",USER_HISTORY);
+ String userId = getUserId();
+ UserBehaviorData data = USER_HISTORY.get(userId);
+ if (data == null) {
+ data = new UserBehaviorData();
+ USER_HISTORY.put(userId, data);
+ }
+ HashMap userBotId2History = data.getUserBotId2History();
+ for (String botId: repository.getUserHostory(getUserId())) {
+ userBotId2History.put(botId, byteFill);
+ }
+ //log.info("用户历史记录:{}",USER_HISTORY);
});
+ if (getAccessToken() != null) {
+ getUserFavorite();
+ }
return new Response(outputSpeech);
}
+ private void getUserFavorite() {
+ POOL.submit(() -> {
+ AppFavoriteTBRepository favoriteTBRepository = BaseHolder.getBean("appFavoriteTBRepository");
+ try {
+ String userId = getUserId();
+ UserBehaviorData data = USER_HISTORY.get(userId);
+ if (data == null) {
+ data = new UserBehaviorData();
+ USER_HISTORY.put(userId, data);
+ }
+ String usUserId = getUsUserId();
+ List favoriteBotIDS = favoriteTBRepository.getFavoriteBotIds(Integer.valueOf(usUserId));
+ for(String botId : favoriteBotIDS) {
+ data.getUserBotId2Collected().put(botId, byteFill);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ });
+ }
+
@Override
protected Response onInent(IntentRequest intentRequest) {
//
@@ -359,7 +398,8 @@ public class DplBotService extends BaseBot {
private Response dealOpenNum(String idsToken, OverTimeDetail overDetail) {
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 botID = tokenList[collectNum-1];
+ OnProductDetail detail = ScheduleService.PRODUCT_ID_DETAIL.get(botID);
String productName = correctName(detail.getName());
String enterProductWord = new StringBuilder(Constants.PRE_PRODUCT_PLAY).append(productName).toString();
log.info("进入作品语句:{}", enterProductWord);
@@ -373,8 +413,13 @@ public class DplBotService extends BaseBot {
return buildErrorResponse(SORRY_UNCATCH);
}
String text = data.getText();
+ int i1 = text.indexOf("【");
+ int i2 = text.indexOf("@");
+ String aside = text.substring(i1+1, i2);
text = text.substring(text.indexOf("】")+1);
- PlayDocument document = PlayUtils.getPlayDocument(productName, data.getAudio(), text);
+ log.info("旁白名字:{}",aside);
+ PlayDocument document = PlayUtils.getPlayDocument(productName, aside, ScheduleService.getAsideImgUrl(botID, aside),
+ data.getAudio(), text, doesUserCollectThisBot(botID));
RenderDocument render = new RenderDocument(document);
this.setSessionAttribute(PRE_COLLE, null);
@@ -543,12 +588,18 @@ public class DplBotService extends BaseBot {
return buildErrorResponse(SORRY_UNCATCH);
}
String text = data.getText();
+
+ int i1 = text.indexOf("【");
+ int i2 = text.indexOf("@");
+ String aside = text.substring(i1+1, i2);
text = text.substring(text.indexOf("】")+1);
- PlayDocument document = PlayUtils.getPlayDocument(productName, data.getAudio(), text);
-// 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).setText(text);
+ log.info("旁白名字:{}",aside);
+
+ String keng = productName;
+ if (keng.equals("清新传")) keng = "清新传{/zhuan4/}";
+ String botID = ScheduleService.getProductNameDetail().get(keng).getBotAccount();
+ PlayDocument document = PlayUtils.getPlayDocument(productName, aside, ScheduleService.getAsideImgUrl(botID, aside),
+ data.getAudio(), text, doesUserCollectThisBot(botID));
RenderDocument render = new RenderDocument(document);
this.setSessionAttribute(PRE_COLLE, null);
@@ -585,6 +636,13 @@ public class DplBotService extends BaseBot {
if (userId == null) throw new IllegalStateException("通过accessToken获取用户id失败");
POOL.submit(new UnCollectThread(botId, userId));
+ POOL.execute(() -> {
+ UserBehaviorData data = USER_HISTORY.get(getUserId());
+ if(data == null) getUserFavorite();
+ else {
+ data.getUserBotId2Collected().remove(botId);
+ }
+ });
// QiWuResponse response = RequestTerminal.requestTerminate(CHAT_COLLECT, userId);
// log.info("chat 取消收藏 的返回{}", response);
} catch (Exception e) {
@@ -600,6 +658,13 @@ public class DplBotService extends BaseBot {
if (userId == null) throw new IllegalStateException("通过accessToken获取用户id失败");
POOL.submit(new CollectThread(botId, userId));
+ POOL.execute(() -> {
+ UserBehaviorData data = USER_HISTORY.get(getUserId());
+ if(data == null) getUserFavorite();
+ else {
+ data.getUserBotId2Collected().put(botId, byteFill);
+ }
+ });
// QiWuResponse response = RequestTerminal.requestTerminate(CHAT_COLLECT, userId);
// log.info("chat 我要收藏 的返回{}", response);
} catch (Exception e) {
@@ -622,6 +687,8 @@ public class DplBotService extends BaseBot {
this.addDirective(new PushStack());
this.setSessionAttribute("pageSign","5");
this.setSessionAttribute("trace","05");
+ } else if ("playButton".equals(componentId)) {
+ return buildErrorResponse("请直接对我下达语音指令,如:我要送花或者我要收藏或取消收藏");
}
// else if ("funnyChange".equals(componentId)) {
// ExecuteCommands executeCommands = new ExecuteCommands();
@@ -767,6 +834,20 @@ public class DplBotService extends BaseBot {
return executeCommands;
}
+ private ExecuteCommands changeCollectIconInPlay(boolean collect) {
+ ExecuteCommands executeCommands = new ExecuteCommands();
+ SetStateCommand setState = new SetStateCommand();
+ setState.setComponentId("playCollect");
+ setState.setState("src");
+ if (collect) {
+ setState.setValue(COLLECTED_IMG_URL);
+ }else {
+ setState.setValue(UN_COLLECTED_IMG_URL);
+ }
+ executeCommands.addCommand(setState);
+ return executeCommands;
+ }
+
private String getUsUserId() throws IOException {
String usId = DU_ID_2_US_ID.get(getCustomerId());
if (usId == null) usId = getUserIdByToken(getAccessToken());
@@ -1699,6 +1780,7 @@ public class DplBotService extends BaseBot {
}
boolean collect = "collect".equals(intentName);
boolean inProductInfo = false;
+ boolean inPlayInfo = false;
String botAccount;
String trace = dplBotService.getSessionAttribute("trace");
if (trace == null || trace.length() <= 2) {
@@ -1711,7 +1793,10 @@ public class DplBotService extends BaseBot {
return;
}
} else {
- if (StringUtils.endsWith(trace, File.separator)) botAccount = trace.substring(2, trace.length()-1);
+ if (StringUtils.endsWith(trace, File.separator)) {
+ botAccount = trace.substring(2, trace.length()-1);
+ inPlayInfo = true;
+ }
else {
inProductInfo = true;
botAccount = trace.substring(2);
@@ -1719,6 +1804,7 @@ public class DplBotService extends BaseBot {
}
try {
boolean alreadyCollected;
+ final String botAccountFinal = botAccount;
String appUserId = dplBotService.getSessionAttribute("userId");
if (appUserId == null) appUserId = getUserIdByToken(getAccessToken());
if (appUserId != null) {
@@ -1731,22 +1817,40 @@ public class DplBotService extends BaseBot {
if (alreadyCollected) {
if (collect) detail.setResponse(buildErrorResponse("您之前就已经收藏过该作品啦,看来你真的很喜欢它"));
else {
- POOL.submit(new UnCollectThread(botAccount, appUserId));
+ POOL.submit(new UnCollectThread(botAccountFinal, appUserId));
+ POOL.execute(() -> {
+ UserBehaviorData data = USER_HISTORY.get(getUserId());
+ if(data == null) getUserFavorite();
+ else {
+ data.getUserBotId2Collected().remove(botAccountFinal);
+ }
+ });
String botName = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
if (inProductInfo) {
ExecuteCommands commands = changeIconIdTextAfterCollect(false, botAccount);
detail.getDirectives().add(commands);
+ } else if (inPlayInfo) {
+ changeCollectIconInPlay(false);
}
if (botName == null) detail.setResponse(buildErrorResponse(UN_COLLECT_BOT_WORD));
else detail.setResponse(buildErrorResponse(String.format(UN_COLLECT_BOT_WORD_MG,botName)));
}
- }else {
+ } else {
if (collect) {
- POOL.submit(new CollectThread(botAccount, appUserId));
+ POOL.submit(new CollectThread(botAccountFinal, appUserId));
+ POOL.execute(() -> {
+ UserBehaviorData data = USER_HISTORY.get(getUserId());
+ if(data == null) getUserFavorite();
+ else {
+ data.getUserBotId2Collected().put(botAccountFinal, byteFill);
+ }
+ });
String word = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
if (inProductInfo) {
ExecuteCommands commands = changeIconIdTextAfterCollect(true, botAccount);
detail.getDirectives().add(commands);
+ } else if (inPlayInfo) {
+ changeCollectIconInPlay(true);
}
if (word == null) detail.setResponse(buildErrorResponse(COLLECT_BOT_WORD));
else detail.setResponse(buildErrorResponse(String.format(COLLECT_BOT_WORD_MG, correctName(word))));
@@ -1905,6 +2009,10 @@ public class DplBotService extends BaseBot {
}
log.info("funny出现问题");
}
+ int i1 = text.indexOf("【");
+ int i2 = text.indexOf("@");
+ String aside = text.substring(i1+1, i2);
+ log.info("旁白名字:{}",aside);
//log.info("小悟返回:{}", text);
text = text.substring(text.indexOf("】")+1);
final String botAccount = ScheduleService.getNx2BotToHz1().get(data.getAipioneerUsername());
@@ -1926,7 +2034,10 @@ public class DplBotService extends BaseBot {
// container.get(1).setSrc(data.getAudio());
// container.get(0).getItems().get(0).setText(text);
String productName = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
- PlayDocument document = PlayUtils.getPlayDocument(correctName(productName), data.getAudio(), text);
+
+ PlayDocument document = PlayUtils.getPlayDocument(correctName(productName), aside,
+ ScheduleService.getAsideImgUrl(botAccount, aside),
+ data.getAudio(), text,doesUserCollectThisBot(botAccount));
RenderDocument render = new RenderDocument(document);
addDirective(render);
detail.getDirectives().add(render);
@@ -1958,25 +2069,35 @@ public class DplBotService extends BaseBot {
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);
+ 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);
+
+ SetStateCommand asideImg = new SetStateCommand();
+ asideImg.setComponentId("asideImg");
+ asideImg.setState("src");
+ asideImg.setValue(ScheduleService.getAsideImgUrl(botAccount, aside));
+
+ SetStateCommand asideText = new SetStateCommand();
+ asideText.setComponentId("asideText");
+ asideText.setState("text");
+ asideText.setValue(aside);
+
+ executeCommands.addCommand(audio);
+ executeCommands.addCommand(textState);
// UpdateComponentCommand update = new UpdateComponentCommand();
// update.setComponentId("whole");
// update.setDocument(TempleUtils.getPlayUpdate(data.getAudio(), text));
// executeCommands.addCommand(update);
- addDirective(executeCommands);
- detail.getDirectives().add(executeCommands);
+ addDirective(executeCommands);
+ detail.getDirectives().add(executeCommands);
// String productName = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
// PlayDocument document = PlayUtils.getPlayDocument(correctName(productName), data.getAudio(), text);
@@ -2051,8 +2172,11 @@ public class DplBotService extends BaseBot {
return buildErrorResponse(SORRY_UNCATCH);
}
String text = data.getText();
+ int i1 = text.indexOf("【");
+ int i2 = text.indexOf("@");
+ String aside = text.substring(i1+1, i2);
text = text.substring(text.indexOf("】")+1);
- PlayDocument document = PlayUtils.getPlayDocument(productName, data.getAudio(), text);
+ PlayDocument document = PlayUtils.getPlayDocument(productName, aside,ScheduleService.getAsideImgUrl(botId, aside),data.getAudio(), text,doesUserCollectThisBot(botId));
RenderDocument render = new RenderDocument(document);
this.setSessionAttribute(PRE_COLLE, null);
@@ -2068,8 +2192,8 @@ public class DplBotService extends BaseBot {
}
private boolean doesUserPlayed(String botAccount) {
- List playedBotIds = USER_HISTORY.get(getUserId());
- if (playedBotIds != null) return playedBotIds.contains(botAccount);
+ UserBehaviorData data = USER_HISTORY.get(getUserId());
+ if (data != null) return data.getUserBotId2History().containsKey(botAccount);
return false;
}
@@ -2284,6 +2408,29 @@ public class DplBotService extends BaseBot {
}
}
+ private boolean doesUserCollectThisBot(String botID) {
+ boolean collected = false;
+ if (getAccessToken() != null) {
+ UserBehaviorData userData = USER_HISTORY.get(getUserId());
+ if (userData != null) {
+ collected = userData.getUserBotId2Collected().containsKey(botID);
+ } else {
+ getUserFavorite();
+ try {
+ AppFavoriteTBRepository repository = BaseHolder.getBean("appFavoriteTBRepository");
+ AppFavoriteTB tb = new AppFavoriteTB();
+ tb.setBotId(botID);
+ tb.setUserId(Integer.valueOf(getUsUserId()));
+ Example example = Example.of(tb);
+ collected = repository.exists(example);
+ } catch (Exception e) {
+ }
+
+ }
+ }
+ return collected;
+ }
+
public static void main(String[] args) throws IOException, InterruptedException, ExecutionException, TimeoutException {
String s = "NDM4MTU1MzY3NDU3NzIwMTM2NDY0MDIxNjQ3NTMzODk5NzYxODgxMTAyOTU1ODY4ODc5MDc3MjA4NjIyMTM5NjM1NjU3Mjc3MDA5MjgzOTM2OTQ5MzQ4Mjk3Mjc0MzI0MjY5ODI4MTM3MzkwNDczMTc3OTM2NTY1NTkwNTMzMTk2MTI1MzU0NTU3NjY3MzkxOTY=";
String[] tokenList = new String(Base64.getDecoder().decode(s)).split(File.separator);
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 92639a7..0898047 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
@@ -5,6 +5,7 @@ import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import ai.qiwu.com.xiaoduhome.common.Utils;
import ai.qiwu.com.xiaoduhome.pojo.QiWuRequest;
import ai.qiwu.com.xiaoduhome.pojo.QiWuResponse;
+import ai.qiwu.com.xiaoduhome.pojo.playAside.AsideImageResponse;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
@@ -44,19 +45,12 @@ class RequestTerminal {
}
public static void main(String[] args) throws IOException {
- int i = 10;
- while (i-- > 0) {
- final int j = i;
- new Thread(() -> {
- try {
- String userId = j+"2453525"+j;
- log.info(userId);
- String word = requestTerminate("有什么好玩的吗",userId).getText();
- System.out.println(Utils.getRecommandBotNames(word));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }).start();
- }
+ String url = "http://aws-nx2.chewrobot.com:18082/api/works";
+ HashMap params = new HashMap<>();
+ params.put("include", "npcHeadImgUrl");
+ params.put("aipioneerUsername","1814141710");
+ String str = OkHttp3Utils.doGet(url, params);
+ AsideImageResponse response = JSON.parseObject(str, AsideImageResponse.class);
+ System.out.println(response.getData().getNpcHeadImgUrl());
}
}
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 ae27df4..3f8f680 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
@@ -1,28 +1,32 @@
package ai.qiwu.com.xiaoduhome.service;
+import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import ai.qiwu.com.xiaoduhome.common.temple.onLunch.LunchUtils;
import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
+import ai.qiwu.com.xiaoduhome.pojo.playAside.AsideImageResponse;
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 ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuOrderTbRepository;
+import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import okhttp3.OkHttpClient;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
+import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
+import static ai.qiwu.com.xiaoduhome.common.Constants.DPL_COMPONENT_ID.DEFAULT_ASIDE_IMG_URL;
+import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.ASIDE_IMG_URL;
+
/**
* @author 苗权威
* @dateTime 19-8-14 下午8:56
@@ -37,7 +41,10 @@ public class ScheduleService implements InitializingBean {
static final HashMap PRODUCT_NAME_DETAIL = new HashMap<>();
static final HashMap PRODUCT_ID_DETAIL = new HashMap<>();
+ static final HashMap> ASIDE_IMG = new HashMap<>();
+
static final HashMap NX2_BOT_TO_HZ1 = new HashMap<>();
+ static final HashMap HZ1_BOT_TO_NX2 = new HashMap<>();
static final List EXCEPT_BOT_ACCOUNT = new ArrayList<>();
static final String[] CATEGORY = {"古风", "儿童", "科幻", "占星", "恋爱", "灾难", "架空", "经营", "冒险", "武侠"};
@@ -149,6 +156,25 @@ public class ScheduleService implements InitializingBean {
}).start();
}
+ private void getAsideImg() {
+ DplBotService.POOL.submit(() -> {
+ List botIds = gameProjectTbRepository.getAllOnTableProductIds();
+ for (String botId: botIds) {
+ try {
+ botId = HZ1_BOT_TO_NX2.get(botId);
+ HashMap params = new HashMap<>();
+ params.put("include", "npcHeadImgUrl");
+ params.put("aipioneerUsername",botId);
+ String str = OkHttp3Utils.doGet(ASIDE_IMG_URL, params);
+ AsideImageResponse response = JSON.parseObject(str, AsideImageResponse.class);
+ ASIDE_IMG.put(botId, response.getData().getNpcHeadImgUrl());
+ } catch (Exception e) {
+ log.error("定时获取头像出错:botId:{},{}",botId, ScheduleService.getProductIdDetail().get(botId).getName());
+ }
+ }
+ });
+ }
+
@Override
public void afterPropertiesSet() throws Exception {
initAllOnTableProductInfo();
@@ -159,6 +185,8 @@ public class ScheduleService implements InitializingBean {
deleteUnPayedOrder();
tian();
keng();
+ fan_keng();
+ getAsideImg();
Logger.getLogger(OkHttpClient.class.getName()).setLevel(Level.FINE);
}
@@ -175,6 +203,7 @@ public class ScheduleService implements InitializingBean {
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");
@@ -182,6 +211,27 @@ public class ScheduleService implements InitializingBean {
NX2_BOT_TO_HZ1.put("7414315062", "1029558688");
}
+ private void fan_keng() {
+ HZ1_BOT_TO_NX2.put("612535455", "6854303973");
+ HZ1_BOT_TO_NX2.put("9828137390", "1814141710");
+ HZ1_BOT_TO_NX2.put("1586892647", "5741775745");
+ HZ1_BOT_TO_NX2.put("3899761881", "9159908109");
+ HZ1_BOT_TO_NX2.put("6559053319", "6035298742");
+ HZ1_BOT_TO_NX2.put("6402164753", "4366487183");
+ HZ1_BOT_TO_NX2.put("6569120969", "236055939");
+ HZ1_BOT_TO_NX2.put("9727432426", "9965361790");
+ HZ1_BOT_TO_NX2.put("9369493482", "2428131253");
+ HZ1_BOT_TO_NX2.put("7667391968", "8343905461");
+ HZ1_BOT_TO_NX2.put("2167984446", "2675579304");
+ HZ1_BOT_TO_NX2.put("438155367", "6259213309");
+
+ HZ1_BOT_TO_NX2.put("2139635657", "4707303948");
+ HZ1_BOT_TO_NX2.put("4731779365", "2090828382");
+ HZ1_BOT_TO_NX2.put("4577201364", "8907881060");
+ HZ1_BOT_TO_NX2.put("7907720862", "7051119238");
+ HZ1_BOT_TO_NX2.put("1029558688", "7414315062");
+ }
+
private void tian(){
EXCEPT_BOT_ACCOUNT.add("682031219");
EXCEPT_BOT_ACCOUNT.add("963477460");
@@ -195,6 +245,10 @@ public class ScheduleService implements InitializingBean {
return PRODUCT_ID_DETAIL;
}
+ public static HashMap getProductNameDetail() {
+ return PRODUCT_NAME_DETAIL;
+ }
+
public static List getRankingList() {
return RANKING_LIST;
}
@@ -203,11 +257,11 @@ public class ScheduleService implements InitializingBean {
return RECOMMEND_LIST;
}
- public static HashMap getNx2BotToHz1() {
+ static HashMap getNx2BotToHz1() {
return NX2_BOT_TO_HZ1;
}
- public static List getExceptBotAccount() {
+ static List getExceptBotAccount() {
return EXCEPT_BOT_ACCOUNT;
}
@@ -230,4 +284,16 @@ public class ScheduleService implements InitializingBean {
public static HashMap> getCategoryProductIdList() {
return CATEGORY_PRODUCT_ID_LIST;
}
+
+ public static String getAsideImgUrl(String botId, String name) {
+ String url = DEFAULT_ASIDE_IMG_URL;
+ return url;
+// Map imgs = ASIDE_IMG.get(botId);
+// if (imgs == null) {
+// url = DEFAULT_ASIDE_IMG_URL
+// }
+// String url = ASIDE_IMG.get(botId).get(name);
+// if (url == null) url = DEFAULT_ASIDE_IMG_URL;
+// return url;
+ }
}
diff --git a/xiaoduhome/src/main/resources/application.yml b/xiaoduhome/src/main/resources/application.yml
index 23d2278..6cad026 100644
--- a/xiaoduhome/src/main/resources/application.yml
+++ b/xiaoduhome/src/main/resources/application.yml
@@ -9,13 +9,13 @@ spring:
username: root
#password: YAdqFKlzYho
password: 3g9^pWQs#ft7
- driver-class-name: com.mysql.cj.jdbc.Driver
+ driver-class-name: com.mysql.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
- driver-class-name: com.mysql.cj.jdbc.Driver
+ driver-class-name: com.mysql.jdbc.Driver
# username: root
# password: mysql
diff --git a/xiaoduhome/src/main/resources/logback-spring.xml b/xiaoduhome/src/main/resources/logback-spring.xml
deleted file mode 100644
index dfc8ac2..0000000
--- a/xiaoduhome/src/main/resources/logback-spring.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-
-
-
-
-
- [%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%L] [%-5p] %m%n
-
-
-
-
-
-
-
- ERROR
- DENY
- ACCEPT
-
-
-
- [%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%L] [%-5p] %m%n
-
-
-
-
-
-
-
- ${LOG_INFO_HOME}//%d.log
- 30
-
-
-
-
-
- ERROR
-
-
-
- [%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%L] [%-5p] %m%n
-
-
-
-
-
-
- ${LOG_ERROR_HOME}//%d.log
- 30
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
- 256
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
- 256
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/xiaoduhome/src/main/resources/static/json/play2.json b/xiaoduhome/src/main/resources/static/json/play2.json
new file mode 100644
index 0000000..0248482
--- /dev/null
+++ b/xiaoduhome/src/main/resources/static/json/play2.json
@@ -0,0 +1,202 @@
+{
+ "type": "DPL",
+ "duration": 0,
+ "mainTemplate": {
+ "parameters": [
+ "payload"
+ ],
+ "items": [
+ {
+ "type": "Image",
+ "position": "absolute",
+ "left": "0dp",
+ "top": "0dp",
+ "src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg",
+ "height": "100%",
+ "width": "100%"
+ },
+ {
+ "type": "Header",
+ "headerTitle": "末世降临",
+ "hasBackIcon": false
+ },
+ {
+ "type":"Image",
+ "position":"absolute",
+ "src":"https://aliyun-hz1.chewrobot.com/xiaoduhome/image/logo.png",
+ "width":"200dp",
+ "height":"60dp",
+ "top":"10dp",
+ "right":"10dp"
+ },
+
+ {
+ "type":"Container",
+ "position":"absolute",
+ "left":"130dp",
+ "top":"135dp",
+
+ "items":[
+ {
+ "type":"Frame",
+
+ "padding-left":"50dp",
+ "padding-right":"15dp",
+ "padding-vertical":"10dp",
+ "border-radius":"10dp",
+ "background-color":"rgba(0,0,0,0.4)",
+ "items":[
+ {
+ "type":"Text",
+ "text":"末世降临",
+
+ "height":"50dp",
+ "scale-type":"fitCenter"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "type":"Container",
+ "position":"absolute",
+ "left":"60dp",
+ "top":"120dp",
+
+ "items":[
+ {
+ "type":"Frame",
+ "width":"100dp",
+ "height":"100dp",
+
+ "border-radius":"50dp",
+
+ "items":[
+ {
+ "type":"Image",
+ "src":"https://aliyun-hz1.chewrobot.com/upload/img/other/2019/07/08160205349.png",
+ "width":"100dp",
+ "height":"100dp",
+ "scale-type":"fitCenter"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "type": "Container",
+ "height": "100%",
+ "width": "100%",
+ "componentId": "whole",
+ "items": [
+ {
+ "type": "Container",
+ "position": "absolute",
+ "items": [
+ {
+ "type": "Text",
+ "componentId": "text",
+ "text": "欢迎来到末世降临,请说继续剧情或者重新开始 ",
+ "font-size": "28dp",
+ "font-style": "normal"
+ }
+ ],
+ "top": "140dp",
+ "left":"22dp",
+ "padding": "35dp"
+ },
+ {
+ "type": "Audio",
+ "src": "http://aws-nx2.chewrobot.com:9663/api/tts/get_audio?dirs=%5B6035298742%2Cxiaoai%5D&filename=57134b89a5b9ae85d9d815c6269a2d8c.mp3",
+ "componentId": "audioCom",
+ "looping": "false",
+ "autoplay": "true",
+ "onEnd": [
+ {
+ "type": "SendEvent",
+ "componentId": "audio"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "type":"Container",
+ "position":"absolute",
+ "left":"600dp",
+ "top":"380dp",
+
+ "items":[
+ {
+ "type":"Frame",
+ "width":"120dp",
+ "height":"120dp",
+ "padding-top":"20dp",
+
+ "border-radius":"60dp",
+ "background-color":"rgba(0,0,0,0.4)",
+ "items":[
+ {
+ "type":"Image",
+ "src":"https://aliyun-hz1.chewrobot.com/xiaoduhome/image/flower.png",
+ "width":"50dp",
+ "height":"50dp",
+ "margin-left":"35dp",
+ "scale-type":"fitCenter"
+ },
+ {
+ "type":"Text",
+ "margin-left":"22dp",
+ "text":"鲜花打赏",
+ "font-size":"20dp"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "type":"Container",
+ "position":"absolute",
+ "left":"300dp",
+ "top":"380dp",
+
+ "items":[
+ {
+ "type":"Frame",
+ "width":"120dp",
+ "height":"120dp",
+ "padding-top":"20dp",
+
+ "border-radius":"60dp",
+ "background-color":"rgba(0,0,0,0.4)",
+ "items":[
+ {
+ "type":"Image",
+ "src":"https://aliyun-hz1.chewrobot.com/xiaoduhome/image/collec.png",
+ "width":"50dp",
+ "height":"50dp",
+ "margin-left":"35dp",
+ "scale-type":"fitCenter"
+ },
+ {
+ "type":"Text",
+ "margin-left":"22dp",
+ "text":"收藏作品",
+ "font-size":"20dp"
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "type": "Footer",
+ "hints": [
+ "我要送花",
+ "收藏",
+ "回到首页",
+ "返回"
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/xiaoya/pom.xml b/xiaoya/pom.xml
index 0829857..e85ae60 100644
--- a/xiaoya/pom.xml
+++ b/xiaoya/pom.xml
@@ -57,7 +57,7 @@
com.alibaba
fastjson
- 1.2.58
+ 1.2.60