Commit d6419d69 by 苗权威

9.18

parent ab298873
......@@ -52,7 +52,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
<version>1.2.60</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
......
......@@ -51,7 +51,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
<version>1.2.60</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
......
......@@ -48,7 +48,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
<version>1.2.60</version>
</dependency>
<dependency>
<groupId>dom4j</groupId>
......
......@@ -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);
}
}
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;
}
......@@ -65,7 +65,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
<version>1.2.60</version>
</dependency>
</dependencies>
......
......@@ -54,7 +54,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
<version>1.2.60</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
......
......@@ -48,7 +48,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
<version>1.2.60</version>
</dependency>
</dependencies>
......
......@@ -16,7 +16,7 @@ public class ChangeSound {
private static final List<String> OPT_FLAG = Arrays.asList("l", "m", "s");
private static final List<String> DEFAULT_DB_LIST = Arrays.asList("-70", "-60", "-20");;
private static final List<String> 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<String> selfCommand) {
List<String> dbList = compand.getDbList();
......
......@@ -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));
......
......@@ -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<String, String> headers, Map<String, String> params) throws IOException {
public static Integer doPostReturnCode(String url, Map<String, String> headers) throws IOException {
Request.Builder builder = new Request.Builder();
Request request = builder.url(url).build();
......@@ -195,13 +195,9 @@ public class OkHttp3Utils {
Iterator<Map.Entry<String, String>> headIterator = headers.entrySet().iterator();
headIterator.forEachRemaining(e -> headBuilder.add(e.getKey(), e.getValue()));
MultipartBody.Builder requestBuilder = new MultipartBody.Builder();
Iterator<Map.Entry<String, String>> 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<Map.Entry<String, String>> 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());
......
......@@ -27,6 +27,11 @@ import java.util.zip.ZipFile;
public class TTSUtils {
private static final String STRIP = " /'\"";
private static final List<Character> 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")));
}
}
......@@ -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);
}
}
......@@ -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) {
......
......@@ -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<String> URL_LS; //线上地址列表
/**
* 存储数据结构: person -> (name,sex,mood[],third_party)
*/
private static final Map<String, PersonInfo> PERSON_INFO_ONLINE; //speakers_online
/**
* 存储数据结构: person_offline -> (name,sex,mood[],third_party)
*/
private static final Map<String, PersonInfo> PERSON_INFO_OFFLINE; //speakers_offline
/**
* 存储数据结构: person_offline -> (name,sex,mood[],third_party)
*/
private static final Map<String, Map<String, String>> PERSON_MOODURL; //api
private static final Map<String, Map<String, Integer>> OFFLINE_2_ONLINE;
private static final List<String> 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<Integer, String> 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() {
......
......@@ -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<String, Object> 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<String, String> 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");
......
......@@ -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
......@@ -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标记
......
......@@ -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
......
......@@ -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);
......
......@@ -94,7 +94,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
<version>1.2.60</version>
</dependency>
<!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fileupload -->
<dependency>
......
......@@ -38,6 +38,13 @@
<artifactId>spring-boot-starter-thymeleaf</artifactId>
<version>2.1.6.RELEASE</version>
</dependency>
<!--&lt;!&ndash; https://mvnrepository.com/artifact/ch.qos.logback/logback-classic &ndash;&gt;-->
<!--<dependency>-->
<!--<groupId>ch.qos.logback</groupId>-->
<!--<artifactId>logback-classic</artifactId>-->
<!--<version>1.2.3</version>-->
<!--<scope>test</scope>-->
<!--</dependency>-->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
......@@ -66,11 +73,6 @@
<version>2.1.6.RELEASE</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
......
......@@ -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 {
......
......@@ -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";
}
}
......@@ -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<Item> 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();
}
}
......@@ -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);
......
......@@ -25,17 +25,34 @@ public class PlayPojo {
private String width;
private String headerTitle;
private Boolean hasBackIcon;
private String componentId;
private String right;
private List<PlayPojo> 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<Event> onEnd;
@JsonProperty("margin-left")
private String marginLeft;
private List<String> hints;
private String text;
private List<Event> onClick;
}
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());
}
}
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<String, Byte> userBotId2History = new HashMap<>();
private volatile HashMap<String, Integer> userBotId2Flowers = new HashMap<>();
private volatile HashMap<String, Byte> userBotId2Collected = new HashMap<>();
}
......@@ -30,7 +30,6 @@ public class Event {
private String repeatCount;
private String position;
private String value;
private List<Event> onComplete;
public Event() {
}
......
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<String,String> npcHeadImgUrl;
}
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;
}
......@@ -28,4 +28,6 @@ public interface AppFlowerTBRepository extends JpaRepository<AppFlowerTB, Intege
@Override
<S extends AppFlowerTB> boolean exists(Example<S> example);
}
......@@ -28,4 +28,7 @@ public interface GameProjectTbRepository extends JpaRepository<GameProjectTb, In
@Query(value = "select id,intro,name,watch,banner_img_url,apply_status,bot_account,user_nickname from game_project_tb where apply_status = 1 order by watch desc limit ?1,8", nativeQuery = true)
List<GameProjectTb> postRankBot(Integer begin);
@Query(value = "select bot_account from game_project_tb where apply_status=1",nativeQuery = true)
List<String> getAllOnTableProductIds();
}
......@@ -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<String, String> 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());
}
}
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<String, OnProductDetail> PRODUCT_NAME_DETAIL = new HashMap<>();
static final HashMap<String, OnProductDetail> PRODUCT_ID_DETAIL = new HashMap<>();
static final HashMap<String, Map<String,String>> ASIDE_IMG = new HashMap<>();
static final HashMap<String, String> NX2_BOT_TO_HZ1 = new HashMap<>();
static final HashMap<String, String> HZ1_BOT_TO_NX2 = new HashMap<>();
static final List<String> 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<String> botIds = gameProjectTbRepository.getAllOnTableProductIds();
for (String botId: botIds) {
try {
botId = HZ1_BOT_TO_NX2.get(botId);
HashMap<String, String> 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<String, OnProductDetail> getProductNameDetail() {
return PRODUCT_NAME_DETAIL;
}
public static List<GameProjectTb> getRankingList() {
return RANKING_LIST;
}
......@@ -203,11 +257,11 @@ public class ScheduleService implements InitializingBean {
return RECOMMEND_LIST;
}
public static HashMap<String, String> getNx2BotToHz1() {
static HashMap<String, String> getNx2BotToHz1() {
return NX2_BOT_TO_HZ1;
}
public static List<String> getExceptBotAccount() {
static List<String> getExceptBotAccount() {
return EXCEPT_BOT_ACCOUNT;
}
......@@ -230,4 +284,16 @@ public class ScheduleService implements InitializingBean {
public static HashMap<String, List<String>> getCategoryProductIdList() {
return CATEGORY_PRODUCT_ID_LIST;
}
public static String getAsideImgUrl(String botId, String name) {
String url = DEFAULT_ASIDE_IMG_URL;
return url;
// Map<String,String> 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;
}
}
......@@ -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
......
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<property resource="logback.properties"/>
<appender name="CONSOLE-LOG" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<pattern>[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%L] [%-5p] %m%n</pattern>
</layout>
</appender>
<!--获取比info级别高(包括info级别)但除error级别的日志-->
<appender name="INFO-LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<onMatch>DENY</onMatch>
<onMismatch>ACCEPT</onMismatch>
</filter>
<encoder>
<pattern>[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%L] [%-5p] %m%n</pattern>
</encoder>
<!--滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--路径-->
<fileNamePattern>${LOG_INFO_HOME}//%d.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
</appender>
<appender name="ERROR-LOG" class="ch.qos.logback.core.rolling.RollingFileAppender">
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
<encoder>
<pattern>[%d{yyyy-MM-dd' 'HH:mm:ss.sss}] [%C] [%t] [%L] [%-5p] %m%n</pattern>
</encoder>
<!--滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!--路径-->
<fileNamePattern>${LOG_ERROR_HOME}//%d.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
</appender>
<!-- 异步输出 -->
<appender name="ASYNC-INFO" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>256</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref ref="INFO-LOG"/>
</appender>
<appender name="ASYNC-ERROR" class="ch.qos.logback.classic.AsyncAppender">
<!-- 不丢失日志.默认的,如果队列的80%已满,则会丢弃TRACT、DEBUG、INFO级别的日志 -->
<discardingThreshold>0</discardingThreshold>
<!-- 更改默认的队列的深度,该值会影响性能.默认值为256 -->
<queueSize>256</queueSize>
<!-- 添加附加的appender,最多只能添加一个 -->
<appender-ref ref="ERROR-LOG"/>
</appender>
<root level="info">
<appender-ref ref="CONSOLE-LOG" />
<appender-ref ref="ASYNC-INFO" />
<appender-ref ref="ASYNC-ERROR" />
</root>
</configuration>
\ No newline at end of file
{
"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
......@@ -57,7 +57,7 @@
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
<version>1.2.60</version>
</dependency>
</dependencies>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment