Commit b525a320 by 苗权威

9.26

parent 235064dd
...@@ -20,6 +20,7 @@ import java.io.*; ...@@ -20,6 +20,7 @@ import java.io.*;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.*; import java.util.*;
import java.util.concurrent.*; import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
...@@ -1063,7 +1064,7 @@ public class TTService { ...@@ -1063,7 +1064,7 @@ public class TTService {
String encoding = TTSUtils.charset(csvFile); String encoding = TTSUtils.charset(csvFile);
// 所有成功上传的id,若多个id指向同一文件,任何一个成功则都应该将其余的id加入集合中 // 所有成功上传的id,若多个id指向同一文件,任何一个成功则都应该将其余的id加入集合中
final List<String> successUpLoadFileIds = new ArrayList<>(); final Set<String> successUpLoadFileIds = new HashSet<>();
// 所有失败了的id以及失败原因 // 所有失败了的id以及失败原因
HashMap<String,String> allFailUpLoadId2Reason = new HashMap<>(); HashMap<String,String> allFailUpLoadId2Reason = new HashMap<>();
...@@ -1091,21 +1092,25 @@ public class TTService { ...@@ -1091,21 +1092,25 @@ public class TTService {
// filename列不为空代表用户为该句指定了文件 // filename列不为空代表用户为该句指定了文件
if (StringUtils.isNotBlank(audioFileName)) { if (StringUtils.isNotBlank(audioFileName)) {
id2Info.put(arr[0],arr); // 存储该行的详细信息,用于之后展示错误信息使用 id2Info.put(arr[0],arr); // 存储该行的详细信息,用于之后展示错误信息使用
boolean hasSuffix = StringUtils.endsWith(audioFileName,".mp3") || StringUtils.endsWith(audioFileName,".MP3");
// 修正文件名,不包含后缀名的加上.mp3后缀名 // 修正文件名,不包含后缀名的加上.mp3后缀名
audioFileName = StringUtils.endsWith(audioFileName,".mp3") ? audioFileName : audioFileName+".mp3"; if (!hasSuffix) audioFileName = audioFileName+".mp3";
// String previousId; // String previousId;
// 若之前已有相同文件名,则将该文件的id加入集合,以该文件名为key // 若之前已有相同文件名,则将该文件的id加入集合,以该文件名为key
// (previousId = allOldname2Id.putIfAbsent(audioFileName, arr[0])) != null // (previousId = allOldname2Id.putIfAbsent(audioFileName, arr[0])) != null
List<String> repeateIds = repeateName2Ids.computeIfAbsent(audioFileName, s -> new ArrayList<>()); List<String> repeateIds = repeateName2Ids.computeIfAbsent(audioFileName, s -> new ArrayList<>());
if (repeateIds.size() != 0) { if (repeateIds.size() != 0) {
// Set<String> repeateIds = repeateName2Ids.computeIfAbsent(audioFileName, s -> new HashSet<>()); // Set<String> repeateIds = repeateName2Ids.computeIfAbsent(audioFileName, s -> new HashSet<>());
// repeateIds.add(arr[0]); // repeateIds.add(arr[0]);
// repeateIds.add(previousId); // repeateIds.add(previousId);
//遍历指向相同文件的语句,生成text与当前一样的语句的提示信息 //遍历指向相同文件的语句,生成text与当前一样的语句的提示信息
boolean doesBeforeRepeate = false;
boolean beforeSuccess = false; boolean beforeSuccess = false;
hasRepeate = true; hasRepeate = true;
for (String repeateId: repeateIds) { for (String repeateId: repeateIds) {
if (arr[1].equals(id2Info.get(repeateId)[1])) { if (arr[1].equals(id2Info.get(repeateId)[1])) {
doesBeforeRepeate = true;
Set<String> textIdEqualIds = allRepeateName2Info.computeIfAbsent(audioFileName, s -> new HashSet<>()); Set<String> textIdEqualIds = allRepeateName2Info.computeIfAbsent(audioFileName, s -> new HashSet<>());
textIdEqualIds.add(arr[0]); textIdEqualIds.add(arr[0]);
textIdEqualIds.add(repeateId); textIdEqualIds.add(repeateId);
...@@ -1114,7 +1119,7 @@ public class TTService { ...@@ -1114,7 +1119,7 @@ public class TTService {
if (successUpLoadFileIds.contains(repeateId)) beforeSuccess = true; if (successUpLoadFileIds.contains(repeateId)) beforeSuccess = true;
} }
// 之前的重复语句并不一定执行成功,若不成功则放行当前的这条重复语句 // 之前的重复语句并不一定执行成功,若不成功则放行当前的这条重复语句
if (beforeSuccess) { if (beforeSuccess && doesBeforeRepeate) {
repeateIds.add(arr[0]); repeateIds.add(arr[0]);
continue; continue;
} }
...@@ -1126,7 +1131,13 @@ public class TTService { ...@@ -1126,7 +1131,13 @@ public class TTService {
// audio_dir/botname/record/npcname/xxx.mp3 // audio_dir/botname/record/npcname/xxx.mp3
final String usFilename = new StringBuilder(folder).append(File.separator).append(md5Name).toString(); final String usFilename = new StringBuilder(folder).append(File.separator).append(md5Name).toString();
// 压缩包中有该mp3文件 // 压缩包中有该mp3文件
if (TTSUtils.doesFileExist(fileInPackage)) { boolean doesFileExit = TTSUtils.doesFileExist(fileInPackage);
if (!doesFileExit && !hasSuffix) {
fileInPackage = new StringBuilder(zipFolder).append(File.separator)
.append(audioFileName, 0, audioFileName.lastIndexOf(".")).append(".MP3").toString();
doesFileExit = TTSUtils.doesFileExist(fileInPackage);
}
if (doesFileExit) {
File usFile = new File(usFilename); File usFile = new File(usFilename);
boolean result=true; boolean result=true;
// 删除之前的旧文件 // 删除之前的旧文件
...@@ -1136,10 +1147,16 @@ public class TTService { ...@@ -1136,10 +1147,16 @@ public class TTService {
// 删除成功后删除其b64文件,且将压缩包中的文件移到安置目录下,即 // 删除成功后删除其b64文件,且将压缩包中的文件移到安置目录下,即
// /root/TTS-service/mqwZip/audioFilename -> audio_dir/botname/record/npcname/xxx.mp3 // /root/TTS-service/mqwZip/audioFilename -> audio_dir/botname/record/npcname/xxx.mp3
if (result) { if (result) {
POOL.submit(() -> new File(new StringBuilder(usFilename).append(".b64").toString()).delete()); new File(new StringBuilder(usFilename).append(".b64").toString()).delete();
if (new File(fileInPackage).renameTo(usFile)) { try {
Files.copy(new File(fileInPackage).toPath(), usFile.toPath());
successUpLoadFileIds.add(arr[0]); successUpLoadFileIds.add(arr[0]);
} catch (Exception e) {
} }
// if (new File(fileInPackage).renameTo(usFile)) {
// successUpLoadFileIds.add(arr[0]);
// }
}else { }else {
allFailUpLoadId2Reason.put(arr[0], "程序原因,请重新上传"); allFailUpLoadId2Reason.put(arr[0], "程序原因,请重新上传");
log.error("删除之前的就音频失败:{}",fileInPackage); log.error("删除之前的就音频失败:{}",fileInPackage);
...@@ -1159,13 +1176,12 @@ public class TTService { ...@@ -1159,13 +1176,12 @@ public class TTService {
//log.info("repeateName2Ids:{}",repeateName2Ids); //log.info("repeateName2Ids:{}",repeateName2Ids);
if (successUpLoadFileIds.size() != 0) { if (successUpLoadFileIds.size() != 0) {
if (hasRepeate) { if (hasRepeate) {
List<String> repeatNameIdList = new ArrayList<>(); Set<String> repeatNameIdList = new HashSet<>();
for (String successId: successUpLoadFileIds) { for (String successId: successUpLoadFileIds) {
String name = id2Info.get(successId)[3]; String name = id2Info.get(successId)[3];
name = StringUtils.endsWith(name,".mp3") ? name : name+".mp3"; name = StringUtils.endsWith(name,".mp3") ? name : name+".mp3";
List<String> nameRepeats = repeateName2Ids.get(name); Set<String> nameRepeats = allRepeateName2Info.get(name);
if (nameRepeats != null && nameRepeats.size()>0) { if (nameRepeats != null && nameRepeats.size()>0) {
nameRepeats.remove(successId);
repeatNameIdList.addAll(nameRepeats); repeatNameIdList.addAll(nameRepeats);
} }
} }
...@@ -1218,7 +1234,7 @@ public class TTService { ...@@ -1218,7 +1234,7 @@ public class TTService {
StringBuilder msgBuild = new StringBuilder(msg).append(";\n").append("下面为提醒信息,请确认:"); StringBuilder msgBuild = new StringBuilder(msg).append(";\n").append("下面为提醒信息,请确认:");
for (String id : successUpLoadFileIds) { for (String id : successUpLoadFileIds) {
String name = id2Info.get(id)[3]; String name = id2Info.get(id)[3];
name = StringUtils.endsWith(name,".mp3") ? name : name+".mp3"; name = StringUtils.endsWith(name,".mp3") || StringUtils.endsWith(name,".MP3") ? name : name+".mp3";
Set<String> infos = allRepeateName2Info.remove(name); Set<String> infos = allRepeateName2Info.remove(name);
if (infos != null && infos.size() != 0) msgBuild if (infos != null && infos.size() != 0) msgBuild
.append("下面的id列表,其所代表的语句的text皆为:\"").append(id2Info.get(id)[1]).append("\",且他们指向同一个文件,这是您想要的结果吗?").append(":") .append("下面的id列表,其所代表的语句的text皆为:\"").append(id2Info.get(id)[1]).append("\",且他们指向同一个文件,这是您想要的结果吗?").append(":")
......
...@@ -19,8 +19,8 @@ spring: ...@@ -19,8 +19,8 @@ spring:
ansi: ansi:
enabled: detect enabled: detect
logging: logging:
# path: /home/ubuntu/project/tts/logs path: /home/ubuntu/project/tts/logs
path: /root/GameEditor/mqw/project/ttsTest/logs # path: /root/GameEditor/mqw/project/ttsTest/logs
level: level:
root: info root: info
server: server:
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<groupId>ai.qiwu.mi</groupId> <groupId>ai.qiwu.mi</groupId>
<artifactId>xiaoai</artifactId> <artifactId>xiaoai</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging> <!--<packaging>war</packaging>-->
<name>xiaoai</name> <name>xiaoai</name>
<description>Demo project for Spring Boot</description> <description>Demo project for Spring Boot</description>
...@@ -23,12 +23,12 @@ ...@@ -23,12 +23,12 @@
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
<exclusions> <!--<exclusions>-->
<exclusion> <!--<exclusion>-->
<groupId>org.springframework.boot</groupId> <!--<groupId>org.springframework.boot</groupId>-->
<artifactId>spring-boot-starter-tomcat</artifactId> <!--<artifactId>spring-boot-starter-tomcat</artifactId>-->
</exclusion> <!--</exclusion>-->
</exclusions> <!--</exclusions>-->
</dependency> </dependency>
<dependency> <dependency>
...@@ -36,13 +36,13 @@ ...@@ -36,13 +36,13 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--添加servlet-api的依赖,用来打war包 --> <!--&lt;!&ndash;添加servlet-api的依赖,用来打war包 &ndash;&gt;-->
<dependency> <!--<dependency>-->
<groupId>javax.servlet</groupId> <!--<groupId>javax.servlet</groupId>-->
<artifactId>javax.servlet-api</artifactId> <!--<artifactId>javax.servlet-api</artifactId>-->
<version>LATEST</version> <!--<version>LATEST</version>-->
<scope>provided</scope> <!--<scope>provided</scope>-->
</dependency> <!--</dependency>-->
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
......
upload.sh:将jar包上传到服务器
start.sh:服务器上执行该文件,启动项目
\ No newline at end of file
...@@ -6,14 +6,9 @@ import org.springframework.boot.builder.SpringApplicationBuilder; ...@@ -6,14 +6,9 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication @SpringBootApplication
public class XiaoaiApplication extends SpringBootServletInitializer { public class XiaoaiApplication{
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(XiaoaiApplication.class, args); SpringApplication.run(XiaoaiApplication.class, args);
} }
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(XiaoaiApplication.class);
}
} }
server.port=8189
logging.path=/usr/mqw/logs/xiaoai logging.path=/usr/mqw/logs/xiaoai
logging.level.root = info logging.level.root = info
spring.output.ansi.enabled=detect spring.output.ansi.enabled=detect
\ No newline at end of file
nohup java -jar /root/GameEditor/mqw/project/xiaoai/xiaoai.jar > nohup.log 2>&1 &
\ No newline at end of file
scp /usr/local/intellij/workplace/smartbox/xiaoai/target/xiaoai.jar root@aliyun-hz1.chewrobot.com:/root/GameEditor/mqw/project/xiaoai/
\ No newline at end of file
...@@ -33,6 +33,9 @@ public interface Constants { ...@@ -33,6 +33,9 @@ public interface Constants {
String REWARD_FLOWER = "请扫码支付"; String REWARD_FLOWER = "请扫码支付";
String UNIT_PRICE = "1"; String UNIT_PRICE = "1";
Integer CO_HI_PAGE_SIZE = 4;
Integer RE_RA_CA_PAGE_SIZE = 20;
interface DPL_COMPONENT_ID { interface DPL_COMPONENT_ID {
String FLOWE = "flowe"; String FLOWE = "flowe";
String FLOWER_PRODUCT_ID = "190817185926388308"; String FLOWER_PRODUCT_ID = "190817185926388308";
......
...@@ -70,4 +70,10 @@ public class CollectHistoryPagePojo { ...@@ -70,4 +70,10 @@ public class CollectHistoryPagePojo {
private String paddingLeft; private String paddingLeft;
@JsonProperty("scale-type") @JsonProperty("scale-type")
private String scaleType; private String scaleType;
@JsonProperty("background-color")
private String backgroundColor;
@JsonProperty("align-items")
private String alignItems;
@JsonProperty("justify-content")
private String justifyContent;
} }
...@@ -19,7 +19,8 @@ public class CollectHistoryUtils { ...@@ -19,7 +19,8 @@ public class CollectHistoryUtils {
private static final CollectHistoryPagePojo HISTORY_HEAD = buildHistoryHead(); private static final CollectHistoryPagePojo HISTORY_HEAD = buildHistoryHead();
private static final CollectHistoryPagePojo FOOTER = buildFooter(); private static final CollectHistoryPagePojo FOOTER = buildFooter();
public static CollectHistoryDocument getDocument(List<HistoryData> datas, boolean collect) { public static CollectHistoryDocument getDocument(List<HistoryData> datas, boolean collect,
int index, int num) {
CollectHistoryDocument document = new CollectHistoryDocument(); CollectHistoryDocument document = new CollectHistoryDocument();
document.setDuration(120000); document.setDuration(120000);
CollectHistoryMainTemplate mainTemplate = new CollectHistoryMainTemplate(); CollectHistoryMainTemplate mainTemplate = new CollectHistoryMainTemplate();
...@@ -30,7 +31,7 @@ public class CollectHistoryUtils { ...@@ -30,7 +31,7 @@ public class CollectHistoryUtils {
allContainer.setWidth("100%"); allContainer.setWidth("100%");
allContainer.setPaddingRight("15dp"); allContainer.setPaddingRight("15dp");
allContainer.setPaddingLeft("15dp"); allContainer.setPaddingLeft("15dp");
allContainer.setPaddingBottom("120dp"); allContainer.setPaddingBottom("180dp");
CollectHistoryPagePojo list = new CollectHistoryPagePojo(); CollectHistoryPagePojo list = new CollectHistoryPagePojo();
list.setType("List"); list.setType("List");
...@@ -45,7 +46,7 @@ public class CollectHistoryUtils { ...@@ -45,7 +46,7 @@ public class CollectHistoryUtils {
CollectHistoryPagePojo head; CollectHistoryPagePojo head;
if (collect) head = COLLECT_HEAD; if (collect) head = COLLECT_HEAD;
else head = HISTORY_HEAD; else head = HISTORY_HEAD;
mainTemplate.getItems().addAll(Arrays.asList(BACK_IMG, head, allContainer, FOOTER)); mainTemplate.getItems().addAll(Arrays.asList(BACK_IMG, head, allContainer, FOOTER, buildPageButton(index, num)));
return document; return document;
} }
...@@ -121,6 +122,37 @@ public class CollectHistoryUtils { ...@@ -121,6 +122,37 @@ public class CollectHistoryUtils {
return main; return main;
} }
private static CollectHistoryPagePojo buildPageButton(int curIndex, int num) {
CollectHistoryPagePojo fCon = new CollectHistoryPagePojo();
fCon.setType("Container");
fCon.setLeft("447dp");
fCon.setBottom("70dp");
fCon.setPosition("absolute");
CollectHistoryPagePojo frame = new CollectHistoryPagePojo();
frame.setType("Frame");
frame.setBorderRadius("40dp");
frame.setBackgroundColor("rgba(0,0,0,0.5)");
CollectHistoryPagePojo sCon = new CollectHistoryPagePojo();
sCon.setType("Container");
sCon.setWidth("130dp");
sCon.setHeight("35dp");
sCon.setAlignItems("center");
sCon.setJustifyContent("center");
CollectHistoryPagePojo text = new CollectHistoryPagePojo();
text.setType("Text");
text.setFontSize("22dp");
if (num == 0) text.setText("第"+curIndex+"页");
else text.setText(curIndex+"/"+num);
sCon.setItems(Collections.singletonList(text));
frame.setItems(Collections.singletonList(sCon));
fCon.setItems(Collections.singletonList(frame));
return fCon;
}
private static CollectHistoryPagePojo buildFooter() { private static CollectHistoryPagePojo buildFooter() {
CollectHistoryPagePojo footerCon = new CollectHistoryPagePojo(); CollectHistoryPagePojo footerCon = new CollectHistoryPagePojo();
footerCon.setType("Container"); footerCon.setType("Container");
...@@ -131,7 +163,7 @@ public class CollectHistoryUtils { ...@@ -131,7 +163,7 @@ public class CollectHistoryUtils {
CollectHistoryPagePojo footer = new CollectHistoryPagePojo(); CollectHistoryPagePojo footer = new CollectHistoryPagePojo();
footer.setType("Footer"); footer.setType("Footer");
footer.setHints(Arrays.asList("打开第一个","下一页","上一页","返回")); footer.setHints(Arrays.asList("打开第一个","下一页","上一页","返回","跳到第三页"));
footerCon.setItems(Collections.singletonList(footer)); footerCon.setItems(Collections.singletonList(footer));
return footerCon; return footerCon;
} }
......
...@@ -9,6 +9,7 @@ import org.springframework.data.annotation.LastModifiedDate; ...@@ -9,6 +9,7 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date; import java.util.Date;
/** /**
...@@ -36,9 +37,9 @@ public class AppFavoriteTB { ...@@ -36,9 +37,9 @@ public class AppFavoriteTB {
@CreatedDate @CreatedDate
@Column(name = "gmt_create", updatable = false, nullable = false) @Column(name = "gmt_create", updatable = false, nullable = false)
private Date createTime; private Timestamp createTime;
@LastModifiedDate @LastModifiedDate
@Column(name = "gmt_modified", nullable = false) @Column(name = "gmt_modified", nullable = false)
private Date updateTime; private Timestamp updateTime;
} }
...@@ -48,9 +48,9 @@ public class AppFlowerTB { ...@@ -48,9 +48,9 @@ public class AppFlowerTB {
@CreatedDate @CreatedDate
@Column(name = "gmt_create", updatable = false, nullable = false) @Column(name = "gmt_create", updatable = false, nullable = false)
private Date createTime; private Timestamp createTime;
@LastModifiedDate @LastModifiedDate
@Column(name = "gmt_modified", nullable = false) @Column(name = "gmt_modified", nullable = false)
private Date updateTime; private Timestamp updateTime;
} }
...@@ -7,6 +7,7 @@ import org.springframework.data.annotation.CreatedDate; ...@@ -7,6 +7,7 @@ import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date; import java.util.Date;
/** /**
...@@ -29,5 +30,5 @@ public class AppUserTB { ...@@ -29,5 +30,5 @@ public class AppUserTB {
@CreatedDate @CreatedDate
@Column(name = "gmt_create", updatable = false, nullable = false) @Column(name = "gmt_create", updatable = false, nullable = false)
private Date createTime; private Timestamp createTime;
} }
...@@ -5,6 +5,7 @@ import lombok.Setter; ...@@ -5,6 +5,7 @@ import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -38,7 +39,7 @@ public class OnProductDetail { ...@@ -38,7 +39,7 @@ public class OnProductDetail {
private Integer applyStatus; private Integer applyStatus;
@Column(name = "gmt_create") @Column(name = "gmt_create")
private Date createTime; private Timestamp createTime;
@Column(name = "user_nickname") @Column(name = "user_nickname")
private String authorName; private String authorName;
......
...@@ -3,12 +3,12 @@ package ai.qiwu.com.xiaoduhome.entity.secondary; ...@@ -3,12 +3,12 @@ package ai.qiwu.com.xiaoduhome.entity.secondary;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.CreatedDate; import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate; import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date; import java.util.Date;
/** /**
...@@ -36,9 +36,9 @@ public class XiaoDuHistoryTB { ...@@ -36,9 +36,9 @@ public class XiaoDuHistoryTB {
@CreatedDate @CreatedDate
@Column(name = "create_time", updatable = false, nullable = false) @Column(name = "create_time", updatable = false, nullable = false)
private Date createTime; private Timestamp createTime;
@LastModifiedDate @LastModifiedDate
@Column(name = "update_time") @Column(name = "update_time")
private Date updateTime; private Timestamp updateTime;
} }
...@@ -7,6 +7,7 @@ import org.springframework.data.annotation.LastModifiedDate; ...@@ -7,6 +7,7 @@ import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener; import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*; import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Date; import java.util.Date;
/** /**
...@@ -58,9 +59,9 @@ public class XiaoDuOrderTB { ...@@ -58,9 +59,9 @@ public class XiaoDuOrderTB {
@CreatedDate @CreatedDate
@Column(name = "create_time", updatable = false, nullable = false) @Column(name = "create_time", updatable = false, nullable = false)
private Date createTime; private Timestamp createTime;
@LastModifiedDate @LastModifiedDate
@Column(name = "update_time", nullable = false) @Column(name = "update_time", nullable = false)
private Date updateTime; private Timestamp updateTime;
} }
...@@ -191,11 +191,11 @@ public class TestBuild { ...@@ -191,11 +191,11 @@ public class TestBuild {
public static void main(String[] args) throws IOException { public static void main(String[] args) throws IOException {
String target = "/home/yf01/下载/tts/target.csv"; String target = "/home/yf01/下载/tts/target.csv";
String src = "/home/yf01/下载/齐齐-人工配音关系对于表(1).csv"; String src = "/home/yf01/下载/齐齐-人工配音关系对于表(2).csv";
String srcModify = "/home/yf01/下载/%E6%B0%B4%E5%BF%83%E6%B9%96.csv"; String srcModify = "/home/yf01/下载/qiOld.csv";
String v2 = "/home/yf01/下载/齐齐-人工配音关系对于表.csv"; String v2 = "/home/yf01/下载/qiNew.csv";
//csvUtil(target, src, srcModify, v2); //csvUtil(target, src, srcModify, v2);
//check(src, srcModify, target); check(src, srcModify, target);
} }
} }
...@@ -20,9 +20,9 @@ public class UserBehaviorData { ...@@ -20,9 +20,9 @@ public class UserBehaviorData {
// 用户对作品所送花的数目 // 用户对作品所送花的数目
private volatile HashMap<String, Long> userBotId2Flowers = new HashMap<>(); private volatile HashMap<String, Long> userBotId2Flowers = new HashMap<>();
// 用户是否收藏该作品 // 用户是否收藏该作品
private volatile HashMap<String, Byte> userBotId2Collected = new HashMap<>(); private volatile HashMap<String, Long> userBotId2Collected = new HashMap<>();
// 标记清除,每半小时标记一次 // 标记清除,每半小时标记一次
private volatile Byte mark = 1; private volatile Byte mark = 0;
private volatile String jytUserId; private volatile String jytUserId;
} }
...@@ -23,8 +23,10 @@ public interface AppFavoriteTBRepository extends JpaRepository<AppFavoriteTB, In ...@@ -23,8 +23,10 @@ public interface AppFavoriteTBRepository extends JpaRepository<AppFavoriteTB, In
@Transactional @Transactional
void deleteByBotIdAndUserId(String botId, Long userId); void deleteByBotIdAndUserId(String botId, Long userId);
@Query(value="SELECT bot_username from app_favorite_tb where user_id=?1", nativeQuery = true) List<AppFavoriteTB> getByUserId(Long userId);
List<String> getFavoriteBotIds(Long userId);
@Query(value = "select bot_username from app_favorite_tb where user_id=?1 order by gmt_create desc limit ?2,10", nativeQuery = true)
List<String> getFavoriteLimit(Long userId, Integer start);
@Override @Override
<S extends AppFavoriteTB> long count(Example<S> example); <S extends AppFavoriteTB> long count(Example<S> example);
......
...@@ -2,6 +2,7 @@ package ai.qiwu.com.xiaoduhome.repository.secondary; ...@@ -2,6 +2,7 @@ package ai.qiwu.com.xiaoduhome.repository.secondary;
import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryBotIdTime; import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryBotIdTime;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import java.util.List; import java.util.List;
...@@ -11,4 +12,7 @@ import java.util.List; ...@@ -11,4 +12,7 @@ import java.util.List;
*/ */
public interface XiaoDuHistoryBotTimeRepository extends JpaRepository<XiaoDuHistoryBotIdTime, Integer> { public interface XiaoDuHistoryBotTimeRepository extends JpaRepository<XiaoDuHistoryBotIdTime, Integer> {
List<XiaoDuHistoryBotIdTime> getByXiaoduUserId(String xiaoduUserId); List<XiaoDuHistoryBotIdTime> getByXiaoduUserId(String xiaoduUserId);
@Query(value = "select bot_id,last_time from xiaodu_history_tb where xiaodu_user_id=?1 order by last_time desc limit ?2,10",nativeQuery = true)
List<XiaoDuHistoryBotIdTime> getByXiaoduUserIdLimit(String xiaoduUserId, Integer start);
} }
...@@ -43,7 +43,9 @@ import java.util.concurrent.ArrayBlockingQueue; ...@@ -43,7 +43,9 @@ import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import static ai.qiwu.com.xiaoduhome.common.Constants.CO_HI_PAGE_SIZE;
import static ai.qiwu.com.xiaoduhome.common.Constants.IMG_PREFIX; import static ai.qiwu.com.xiaoduhome.common.Constants.IMG_PREFIX;
import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.*; import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.*;
import static ai.qiwu.com.xiaoduhome.service.ScheduleService.curTime; import static ai.qiwu.com.xiaoduhome.service.ScheduleService.curTime;
...@@ -54,9 +56,6 @@ import static ai.qiwu.com.xiaoduhome.service.ScheduleService.curTime; ...@@ -54,9 +56,6 @@ import static ai.qiwu.com.xiaoduhome.service.ScheduleService.curTime;
*/ */
@Slf4j @Slf4j
public class DplbotServiceUtil { public class DplbotServiceUtil {
private static final byte BYTE_FILL = 1;
private static final int CORE = Runtime.getRuntime().availableProcessors(); private static final int CORE = Runtime.getRuntime().availableProcessors();
static final ThreadPoolExecutor POOL = new ThreadPoolExecutor(CORE+1, 1500, static final ThreadPoolExecutor POOL = new ThreadPoolExecutor(CORE+1, 1500,
...@@ -68,10 +67,11 @@ public class DplbotServiceUtil { ...@@ -68,10 +67,11 @@ public class DplbotServiceUtil {
AppFavoriteTBRepository favoriteTBRepository = BaseHolder.getBean("appFavoriteTBRepository"); AppFavoriteTBRepository favoriteTBRepository = BaseHolder.getBean("appFavoriteTBRepository");
try { try {
UserBehaviorData data = USER_HISTORY.computeIfAbsent(userId, s -> new UserBehaviorData()); UserBehaviorData data = USER_HISTORY.computeIfAbsent(userId, s -> new UserBehaviorData());
List<String> favoriteBotIDS = favoriteTBRepository.getFavoriteBotIds(Long.valueOf(usUserId)); List<AppFavoriteTB> favoriteBots = favoriteTBRepository.getByUserId(Long.valueOf(usUserId));
for(String botId : favoriteBotIDS) { for(AppFavoriteTB bot : favoriteBots) {
data.getUserBotId2Collected().put(botId, BYTE_FILL); data.getUserBotId2Collected().put(bot.getBotId(), bot.getCreateTime().getTime());
} }
log.info("UserBotId2Collected:"+data.getUserBotId2Collected());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -99,7 +99,7 @@ public class DplbotServiceUtil { ...@@ -99,7 +99,7 @@ public class DplbotServiceUtil {
return usId; return usId;
} }
private static String getUserIdByToken(String accessToken) { static String getUserIdByToken(String accessToken) {
try { try {
HashMap<String, String> headers = new HashMap<>(); HashMap<String, String> headers = new HashMap<>();
headers.put("App-Channel-Id", "JIAOYOUTIANXIA"); headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
...@@ -235,8 +235,8 @@ public class DplbotServiceUtil { ...@@ -235,8 +235,8 @@ public class DplbotServiceUtil {
static boolean didUserCollecThisProduct(String botAccount, String userID, String accessToken, String jytUserId) { static boolean didUserCollecThisProduct(String botAccount, String userID, String accessToken, String jytUserId) {
UserBehaviorData data = USER_HISTORY.get(userID); UserBehaviorData data = USER_HISTORY.get(userID);
if (data != null) { if (data != null) {
Byte count = data.getUserBotId2Collected().get(botAccount); Long time = data.getUserBotId2Collected().get(botAccount);
return count != null; return time != null;
} else { } else {
onLunchFillUserBehaviorData(accessToken, userID); onLunchFillUserBehaviorData(accessToken, userID);
if (jytUserId == null) { if (jytUserId == null) {
...@@ -293,7 +293,7 @@ public class DplbotServiceUtil { ...@@ -293,7 +293,7 @@ public class DplbotServiceUtil {
} }
UserBehaviorData behaviorData = USER_HISTORY.get(userId); UserBehaviorData behaviorData = USER_HISTORY.get(userId);
if (behaviorData != null) { if (behaviorData != null) {
behaviorData.getUserBotId2Collected().put(botAccount, BYTE_FILL); behaviorData.getUserBotId2Collected().put(botAccount, curTime);
} else { } else {
if (jytUserId != null) { if (jytUserId != null) {
UserBehaviorData data = USER_HISTORY.computeIfAbsent(userId, s -> new UserBehaviorData()); UserBehaviorData data = USER_HISTORY.computeIfAbsent(userId, s -> new UserBehaviorData());
...@@ -402,7 +402,7 @@ public class DplbotServiceUtil { ...@@ -402,7 +402,7 @@ public class DplbotServiceUtil {
if (historyTB.getLastTime().equals(time)) continue; if (historyTB.getLastTime().equals(time)) continue;
historyTB.setLastTime(time); historyTB.setLastTime(time);
} }
repository.saveAndFlush(historyTB); repository.save(historyTB);
} }
} }
}); });
...@@ -496,15 +496,34 @@ public class DplbotServiceUtil { ...@@ -496,15 +496,34 @@ public class DplbotServiceUtil {
}); });
} }
static CollectHistoryDocument getCollectPage(String userId, String accessToken, String jytId) { static CollectHistoryDocument getCollectPage(String userId, String accessToken, String jytId, int start) {
Collection<String> favoriteProducts; List<String> favoriteProducts = new ArrayList<>();
UserBehaviorData behaviorData = USER_HISTORY.get(userId); UserBehaviorData behaviorData = USER_HISTORY.get(userId);
int pageNum = 0;
if (behaviorData == null) { if (behaviorData == null) {
onLunchFillUserBehaviorData(accessToken, userId); onLunchFillUserBehaviorData(accessToken, userId);
if (jytId == null) jytId = getUserIdByToken(accessToken);
if (jytId != null) {
AppFavoriteTBRepository favorite = BaseHolder.getBean("appFavoriteTBRepository"); AppFavoriteTBRepository favorite = BaseHolder.getBean("appFavoriteTBRepository");
favoriteProducts = favorite.getFavoriteBotIds(Long.parseLong(jytId)); favoriteProducts = favorite.getFavoriteLimit(Long.parseLong(jytId), start);
}
}else { }else {
favoriteProducts = behaviorData.getUserBotId2Collected().keySet(); int bound = behaviorData.getUserBotId2Collected().size();
if (start >= bound) {
return null;
}
pageNum = bound/CO_HI_PAGE_SIZE + (bound%CO_HI_PAGE_SIZE == 0 ? 0 : 1);
TreeMap<Long, String> order = new TreeMap<>((o1, o2) -> (o1 < o2) ? 1 : ((o1.equals(o2)) ? 0 : -1));
for (Map.Entry<String, Long> entry: behaviorData.getUserBotId2Collected().entrySet()) {
order.put(entry.getValue(), entry.getKey());
}
int i = 0, e = start+CO_HI_PAGE_SIZE;
for (Map.Entry<Long, String> entry: order.entrySet()) {
if (i == e) break;
if (i++ >= start) {
favoriteProducts.add(entry.getValue());
}
}
} }
if (favoriteProducts.size() == 0) return null; if (favoriteProducts.size() == 0) return null;
ArrayList<HistoryData> projectInfoList = new ArrayList<>(); ArrayList<HistoryData> projectInfoList = new ArrayList<>();
...@@ -524,7 +543,8 @@ public class DplbotServiceUtil { ...@@ -524,7 +543,8 @@ public class DplbotServiceUtil {
data.setAuthorName(productDetail.getAuthorName()); data.setAuthorName(productDetail.getAuthorName());
projectInfoList.add(data); projectInfoList.add(data);
} }
CollectHistoryDocument collectHistoryDocument = CollectHistoryUtils.getDocument(projectInfoList, true); CollectHistoryDocument collectHistoryDocument = CollectHistoryUtils.getDocument(projectInfoList, true,
start/CO_HI_PAGE_SIZE+1, pageNum);
String idToken; String idToken;
if (build.length() != 0) { if (build.length() != 0) {
build.deleteCharAt(build.length()-1); build.deleteCharAt(build.length()-1);
...@@ -534,21 +554,33 @@ public class DplbotServiceUtil { ...@@ -534,21 +554,33 @@ public class DplbotServiceUtil {
return collectHistoryDocument; return collectHistoryDocument;
} }
static CollectHistoryDocument getHistory(String userId, String accessToken) { static CollectHistoryDocument getHistory(String userId, String accessToken, int start) {
List<XiaoDuHistoryBotIdTime> historyProducts = new ArrayList<>(); List<XiaoDuHistoryBotIdTime> historyProducts = new ArrayList<>();
UserBehaviorData behaviorData = USER_HISTORY.get(userId); UserBehaviorData behaviorData = USER_HISTORY.get(userId);
int pageNum = 0;
if (behaviorData == null) { if (behaviorData == null) {
onLunchFillUserBehaviorData(accessToken, userId); onLunchFillUserBehaviorData(accessToken, userId);
XiaoDuHistoryBotTimeRepository historyRepository = BaseHolder.getBean("xiaoDuHistoryBotTimeRepository"); XiaoDuHistoryBotTimeRepository historyRepository = BaseHolder.getBean("xiaoDuHistoryBotTimeRepository");
historyProducts = historyRepository.getByXiaoduUserId(userId); historyProducts = historyRepository.getByXiaoduUserIdLimit(userId, start);
} else { } else {
try { try {
int bound = behaviorData.getUserBotId2History().size();
if (start >= bound) return null;
pageNum = bound/CO_HI_PAGE_SIZE + (bound%CO_HI_PAGE_SIZE == 0 ? 0 : 1);
TreeMap<Long, String> order = new TreeMap<>((o1, o2) -> (o1 < o2) ? 1 : ((o1.equals(o2)) ? 0 : -1));
for (Map.Entry<String, Long> entry: behaviorData.getUserBotId2History().entrySet()) { for (Map.Entry<String, Long> entry: behaviorData.getUserBotId2History().entrySet()) {
order.put(entry.getValue(), entry.getKey());
}
int i = 0, end = start+CO_HI_PAGE_SIZE;
for (Map.Entry<Long, String> entry: order.entrySet()) {
if (i == end) break;
if (i++ >= start) {
XiaoDuHistoryBotIdTime history = new XiaoDuHistoryBotIdTime(); XiaoDuHistoryBotIdTime history = new XiaoDuHistoryBotIdTime();
history.setBotId(entry.getKey()); history.setBotId(entry.getValue());
history.setLastTime(entry.getValue()); history.setLastTime(entry.getKey());
historyProducts.add(history); historyProducts.add(history);
} }
}
} catch (Exception e){} } catch (Exception e){}
} }
if (historyProducts.size() == 0) return null; if (historyProducts.size() == 0) return null;
...@@ -557,6 +589,7 @@ public class DplbotServiceUtil { ...@@ -557,6 +589,7 @@ public class DplbotServiceUtil {
int i = 1; int i = 1;
final StringBuilder build = new StringBuilder(); final StringBuilder build = new StringBuilder();
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm"); SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
historyProducts.sort((o1, o2) -> (o1.getLastTime()<o2.getLastTime()) ? 1 : (o1.getLastTime().equals(o2.getLastTime())) ? 0 : -1);
for (XiaoDuHistoryBotIdTime historyInfo: historyProducts) { for (XiaoDuHistoryBotIdTime historyInfo: historyProducts) {
String botAccount = historyInfo.getBotId(); String botAccount = historyInfo.getBotId();
build.append(botAccount).append(File.separator); build.append(botAccount).append(File.separator);
...@@ -572,7 +605,8 @@ public class DplbotServiceUtil { ...@@ -572,7 +605,8 @@ public class DplbotServiceUtil {
data.setAuthorName(lastTime); data.setAuthorName(lastTime);
projectInfoList.add(data); projectInfoList.add(data);
} }
CollectHistoryDocument document = CollectHistoryUtils.getDocument(projectInfoList, false); CollectHistoryDocument document = CollectHistoryUtils.getDocument(projectInfoList, false,
start/CO_HI_PAGE_SIZE+1, pageNum);
String idToken; String idToken;
if (build.length() != 0) { if (build.length() != 0) {
build.deleteCharAt(build.length()-1); build.deleteCharAt(build.length()-1);
......
package ai.qiwu.com.xiaoduhome.service; package ai.qiwu.com.xiaoduhome.service;
import ai.qiwu.com.xiaoduhome.common.BaseHolder;
import ai.qiwu.com.xiaoduhome.common.Config; import ai.qiwu.com.xiaoduhome.common.Config;
import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils; import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import ai.qiwu.com.xiaoduhome.common.temple.onLunch.LunchUtils; import ai.qiwu.com.xiaoduhome.common.temple.onLunch.LunchUtils;
import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb; import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail; import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryTB;
import ai.qiwu.com.xiaoduhome.pojo.UserBehaviorData; import ai.qiwu.com.xiaoduhome.pojo.UserBehaviorData;
import ai.qiwu.com.xiaoduhome.pojo.playAside.AsideImageResponse; import ai.qiwu.com.xiaoduhome.pojo.playAside.AsideImageResponse;
import ai.qiwu.com.xiaoduhome.repository.primary.AllOnProductInfoRepository; import ai.qiwu.com.xiaoduhome.repository.primary.AllOnProductInfoRepository;
...@@ -90,7 +92,28 @@ public class ScheduleService implements InitializingBean { ...@@ -90,7 +92,28 @@ public class ScheduleService implements InitializingBean {
UserBehaviorData data = DplbotServiceUtil.USER_HISTORY.get(userId); UserBehaviorData data = DplbotServiceUtil.USER_HISTORY.get(userId);
if (data != null) { if (data != null) {
if (data.getMark() == 1) data.setMark((byte) 0); if (data.getMark() == 1) data.setMark((byte) 0);
else needClear.add(userId); else {
needClear.add(userId);
XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
for (Map.Entry<String, Long> entry: data.getUserBotId2History().entrySet()) {
String botId = entry.getKey();
Long time = entry.getValue();
XiaoDuHistoryTB historyTB = repository.getByXiaoduUserIdAndBotId(userId, botId);
if (historyTB == null) {
historyTB = new XiaoDuHistoryTB();
historyTB.setLastTime(time);
historyTB.setBotId(botId);
historyTB.setXiaoduUserId(userId);
} else {
if (historyTB.getLastTime().equals(time)) continue;
historyTB.setLastTime(time);
}
repository.save(historyTB);
}
data.setUserBotId2Collected(null);
data.setUserBotId2Flowers(null);
data.setUserBotId2History(null);
}
} }
} }
for (String userId: needClear) DplbotServiceUtil.USER_HISTORY.remove(userId); for (String userId: needClear) DplbotServiceUtil.USER_HISTORY.remove(userId);
......
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