Commit 7cd517d5 by 苗权威

2.2

parent bd0298ef
......@@ -33,7 +33,7 @@
<module name="open" options="-parameters" />
<module name="rokid" options="-parameters" />
<module name="ruoqi" options="-parameters" />
<module name="spirit" options="-parameters -extdirs $PROJECT_DIR$/spirit/src/main/resources/lib" />
<module name="spirit" options="-parameters -extdirs /usr/local/intellij/workplace/smartbox/spirit/src/main/resources/lib" />
<module name="third_party_load" options="-parameters" />
<module name="tts_offline" options="-parameters" />
<module name="tts_service" options="-parameters" />
......
......@@ -1324,6 +1324,7 @@ public class TTService {
}
if ((res == null || res.getCode() != 200) && !"mp3".equals(data.getFormat())) {
log.warn("requestTemplate:列户小雅兜底调用");
res = dealThirdParty(data.getText(), "Liehu1", filePath);
}
return res;
......
package ai.qiwu.com.tts_service.service;
import ai.qiwu.com.tts_service.common.OkHttp3Utils;
import ai.qiwu.com.tts_service.common.TTSUtils;
import ai.qiwu.com.tts_service.common.sound.SampleRateConverter;
import ai.qiwu.com.tts_service.pojo.TtsLsAudio;
......@@ -7,10 +8,14 @@ import ai.qiwu.com.tts_service.pojo.TtsLsResponse;
import ai.qiwu.com.tts_service.pojo.TtsLsType;
import ai.qiwu.com.tts_service.pojo.upload.UploadOneSenData;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.csvreader.CsvReader;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.util.CollectionUtils;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
......@@ -317,6 +322,17 @@ public class Test {
return num;
}
private static void testLoad(String accessToken){
try {
HashMap<String, String> headers = new HashMap<>();
headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
headers.put("Authorization", new StringBuilder("Bearer ").append(accessToken).toString());
String str = OkHttp3Utils.doGet("https://account-center-test.chewrobot.com/api/sdk/user/info", new HashMap<>(), headers);
log.info("getUserIdByToken:{}",str);
} catch (Exception e) {
log.error("获取郊游天下用户id出错:{}", ExceptionUtils.getStackTrace(e));
}
}
public static void main(String[] args) {
Date date = new Date(1572522571234L);
......@@ -325,17 +341,31 @@ public class Test {
System.out.println(TTSUtils.buildMP3Filename("\uD83C\uDD70会数学的杰瑞的类型为:儿童、简单、益智、休闲、教育、学生、免费\uD83C\uDD71"));
System.out.println(TTSUtils.buildMP3Filename("会数学的杰瑞的类型为:儿童、简单、益智、休闲、教育、学生、免费"));
Pattern pattern = Pattern.compile(TTSUtils.getAbRegex());
String[] notVariableTextArray = pattern.split("\uD83C\uDD70会数学的杰瑞的类型为:儿童、简单、益智、休闲、教育、学生、免费\uD83C\uDD71");
System.out.println(extractNum("27"));
System.out.println(extractNum("二十六"));
System.out.println(extractNum("十六"));
System.out.println(extractNum("六"));
System.out.println(extractNum("第五个"));
System.out.println(extractNum("第十五个"));
System.out.println(extractNum("第二十六个"));
System.out.println(extractNum("第7个"));
System.out.println(extractNum("第17个"));
String sss = "{\n" +
" \"code\": 1,\n" +
" \"msg\": \"成功\",\n" +
" \"data\": {\n" +
" \"flowers\": {\n" +
" \"8343905461\": 1\n" +
" },\n" +
" \"history\": {\n" +
" \"8343905461\": 1579586903000,\n" +
" \"330440914\": 1579586286000,\n" +
" \"652820709\": 1579410432000,\n" +
" \"927936967\": 1579585808000,\n" +
" \"534996073\": 1579524295000,\n" +
" \"225446543\": 1579501308000,\n" +
" \"522878748\": 1579504437000,\n" +
" \"920289968\": 1579499810000\n" +
" },\n" +
" \"favorite\": {}\n" +
" }\n" +
"}";
JSONObject result = JSON.parseObject(sss);
if (NumberUtils.INTEGER_ONE.equals(result.getInteger("code"))) {
result = result.getJSONObject("data");
Map<String, Long> botAccount2FavoriteTime = JSON.parseObject(result.getJSONObject("flowers").toJSONString(), new TypeReference<HashMap<String,Long>>(){});
log.info(botAccount2FavoriteTime.get("8343905461").getClass().getName());
}
}
}
}
\ No newline at end of file
......@@ -271,13 +271,13 @@ public class TempleUtils {
public static List<LunchBotData> buildCategoryDataList(int row) {
ArrayList<LunchBotData> dataList = new ArrayList<>();
int begin = row*3;
int begin = row*4;
String name, imgId, imgSrc;
for (int i = begin; i < begin+3; i++) {
for (int i = begin; i < begin+4; i++) {
name = ScheduleServiceNew.CATEGORY[i];
imgSrc = new StringBuilder(IMG_CUSTOM_PREFIX)
.append(ScheduleServiceNew.CATEGORY_CHARAC[i]).append(".png").toString();
imgId = ScheduleServiceNew.CATEGORY_CHARAC[i];
imgId = Constants.DPL_COMPONENT_ID.PRE_CATEGORY +ScheduleServiceNew.CATEGORY[i];
LunchBotData data = new LunchBotData(imgSrc, imgId, name);
data.setNum(i+1);
dataList.add(data);
......
......@@ -2,6 +2,7 @@ package ai.qiwu.com.xiaoduhome.common.temple.onLunch;
import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils;
import ai.qiwu.com.xiaoduhome.common.temple.productInfo.ProductInfoPojo;
import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
......@@ -25,33 +26,52 @@ public class LunchUtils {
// private static final LunchPojo LUNCH_LOGO_IMG = buildLogoImage();
// private static final LunchPojo LUNCH_HSITORY_IMG = buildHistoryImg();
// private static final LunchPojo LUNCH_COLLECT_IMG = buildCollectImg();
private volatile static LunchDocument lunchDocument = buildLunchNewDocument();
private volatile static LunchDocument lunchDocument = buildLunchNewDocument(0);
private volatile static LunchDocument lunchDocument_part = buildLunchNewDocument(1);
private volatile static LunchDocument categoryDocument = buildCategoryDocument();
private static LunchDocument buildLunchNewDocument() {
private static LunchDocument buildLunchNewDocument(int part) {
LunchDocument document = new LunchDocument();
document.setDuration(240000);
LunchMainTemplate mainTemplate = new LunchMainTemplate();
document.setMainTemplate(mainTemplate);
int size = ScheduleServiceNew.allProjects.size();
List<ProjectData> dataList = ScheduleServiceNew.getTheChannelAllProjectData("baidu-screen-jiaoyou-audio-test");
int size = dataList.size();
int rows = size/4 + (size%4 == 0?0:1);
int i = 0;
int i, bound;
boolean all;
if ((all = part == 0)) {
i = 0;
bound = rows;
} else {
i = 0;
bound = 1;
}
List<LunchPojo> list = new ArrayList<>();
LunchPojo rowCon;
int begin, end;
while (i < rows) {
while (i < bound) {
begin = i*4;
end = begin+4 > size ? size : begin+4;
rowCon = buildLunchList(TempleUtils.buildDataList(ScheduleServiceNew.allProjects.subList(begin, end),begin+1));
rowCon = buildLunchList(TempleUtils.buildDataList(dataList.subList(begin, end),begin+1));
list.add(rowCon);
i++;
}
LunchPojo scroll = buildLunchScroll();
scroll.setItems(list);
LunchPojo scroll;
if (all) {
scroll = buildLunchScroll();
scroll.setItems(list);
mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll,FOOTER));
} else {
scroll = buildLunchPartContainer();
scroll.setItems(list);
mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll));
}
// mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,LUNCH_LOGO_IMG,LUNCH_HSITORY_IMG,LUNCH_COLLECT_IMG,scroll));
mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll,FOOTER));
// mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll,FOOTER));
return document;
}
......@@ -78,7 +98,7 @@ public class LunchUtils {
return document;
}
public static LunchDocument buildCategoryDocument() {
private static LunchDocument buildCategoryDocument() {
LunchDocument document = new LunchDocument();
document.setDuration(90000);
LunchMainTemplate mainTemplate = new LunchMainTemplate();
......@@ -87,6 +107,7 @@ public class LunchUtils {
LunchPojo firstRow = buildLunchCategoryList(TempleUtils.buildCategoryDataList(0));
LunchPojo secondRow = buildLunchCategoryList(TempleUtils.buildCategoryDataList(1));
LunchPojo scroll = buildLunchScroll();
scroll.setMarginTop("240dp");
scroll.setItems(Arrays.asList(firstRow,secondRow));
mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,scroll,CATEGORY_FOOTER));
......@@ -104,18 +125,27 @@ public class LunchUtils {
return scroll;
}
private static LunchPojo buildLunchPartContainer() {
LunchPojo container = new LunchPojo();
container.setType("Container");
container.setMarginTop("180dp");
container.setWidth("100%");
// scroll.setMarginBottom("10dp");
return container;
}
private static LunchPojo buildLunchCategoryList(List<LunchBotData> data) {
LunchPojo container = new LunchPojo();
//container.setMarginTop("25dp");
container.setType("Container");
container.setWidth("100%");
container.setMarginTop("180dp");
container.setAlignItems("center");
container.setMarginBottom("15dp");
// container.setAlignItems("center");
LunchPojo list = new LunchPojo();
list.setType("List");
list.setHeight("310dp");
list.setMarginLeft("30dp");
list.setHeight("280dp");
list.setMarginLeft("44dp");
list.setDirection("horizontal");
list.setData(data);
list.setItems(Collections.singletonList(LUNCH_LIST_CATEGORY_CON));
......@@ -147,7 +177,12 @@ public class LunchUtils {
private static LunchPojo buildCategoryList() {
LunchPojo category = buildImgFrmTxtContainer();
category.getItems().remove(2);
category.getItems().get(0).setWidth("170dp");
category.getItems().get(0).setHeight("170dp");
category.getItems().get(0).setMarginLeft("1dp");
category.getItems().get(1).setMarginLeft("15dp");
category.getItems().get(2).setMarginTop("148dp");
category.getItems().get(2).setMarginLeft("61dp");
return category;
}
......@@ -174,10 +209,10 @@ public class LunchUtils {
//frame
LunchPojo frame = new LunchPojo();
frame.setType("Frame");
frame.setWidth("45dp");
frame.setHeight("45dp");
frame.setWidth("35dp");
frame.setHeight("35dp");
frame.setBackgroundColor("rgb(30,144,255)");
frame.setBorderRadius("25dp");
frame.setBorderRadius("20dp");
LunchPojo frmCon = new LunchPojo();
frmCon.setType("Container");
......@@ -197,8 +232,8 @@ public class LunchUtils {
//text
LunchPojo text = new LunchPojo();
text.setType("Text");
text.setFontSize("28dp");
text.setMarginTop("188dp");
text.setFontSize("24dp");
text.setMarginTop("178dp");
text.setMarginLeft("7dp");
text.setText("${data.imageName}");
......@@ -252,7 +287,7 @@ public class LunchUtils {
LunchPojo footer = new LunchPojo();
footer.setType("Footer");
footer.setHints(Arrays.asList("推荐作品","打开第一个","打开排行榜","打开历史记录","打开收藏"));
footer.setHints(Arrays.asList("打开第一个","打开排行榜","打开历史记录","打开分类","打开收藏","推荐作品"));
footerCon.setItems(Collections.singletonList(footer));
......@@ -323,6 +358,10 @@ public class LunchUtils {
return logo;
}
public static LunchDocument getLunchDocument_part() {
return lunchDocument_part;
}
public static LunchDocument getLunchDocument() {
return lunchDocument;
}
......@@ -330,4 +369,12 @@ public class LunchUtils {
public static void setLunchDocument(LunchDocument lunchDocument) {
LunchUtils.lunchDocument = lunchDocument;
}
public static LunchDocument getCategoryDocument() {
return categoryDocument;
}
public static void setCategoryDocument(LunchDocument categoryDocument) {
LunchUtils.categoryDocument = categoryDocument;
}
}
......@@ -17,7 +17,7 @@ public class PlayUtils {
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_LOGO = buildLogoImage();
private static final PlayPojo PLAY_COLLECT = buildCollect();
// private static final PlayPojo PLAY_UN_COLLECT = buildUnCollect();
......@@ -37,7 +37,7 @@ public class PlayUtils {
dataList.add(data);
}
mainTemplate.setItems(Arrays.asList(PLAY_BACK_IMG, buildLunchHead(correctName(headerName)), PLAY_LOGO,
mainTemplate.setItems(Arrays.asList(PLAY_BACK_IMG, buildLunchHead(correctName(headerName)),
buildConList(audio, dataList), PLAY_COLLECT, PLAY_FLOWER, PLAY_HINT));
return document;
}
......@@ -151,7 +151,7 @@ public class PlayUtils {
document.setMainTemplate(mainTemplate);
PlayPojo collectComponent = PLAY_COLLECT;
//if (!collected) collectComponent = PLAY_UN_COLLECT;
mainTemplate.setItems(Arrays.asList(PLAY_BACK_IMG, buildLunchHead(headerName), PLAY_LOGO,
mainTemplate.setItems(Arrays.asList(PLAY_BACK_IMG, buildLunchHead(headerName),
buildAside(aside), buildAsideImage(asideImg), buildWholeContainer(audio, text)
,collectComponent, PLAY_FLOWER, PLAY_HINT));
return document;
......@@ -448,7 +448,7 @@ public class PlayUtils {
PlayPojo footer = new PlayPojo();
footer.setType("Footer");
footer.setHints(Arrays.asList("我要送花", "收藏", "返回"));
footer.setHints(Arrays.asList("我要送花", "收藏", "退出作品"));
footerCon.setItems(Collections.singletonList(footer));
......
......@@ -203,7 +203,7 @@ public class RecommendUtil {
begin = end;
}
mainTemplate.getItems().addAll(Arrays.asList(RECOM_BACK_IMG,RANK_HEAD,scrollView,
buildPageButton(num+1, list.size()/12 + list.size()%12==0?0:1),RANK_CATEGORY_FOOTER));
buildPageButton(num+1, list.size()/RE_RA_CA_PAGE_SIZE + list.size()%RE_RA_CA_PAGE_SIZE==0?0:1),RANK_CATEGORY_FOOTER));
botIds.deleteCharAt(botIds.length()-1);
String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
......@@ -286,10 +286,10 @@ public class RecommendUtil {
//frame
RecommandPojo frame = new RecommandPojo();
frame.setType("Frame");
frame.setWidth("45dp");
frame.setHeight("45dp");
frame.setWidth("35dp");
frame.setHeight("35dp");
frame.setBackgroundColor("rgb(30,144,255)");
frame.setBorderRadius("25dp");
frame.setBorderRadius("20dp");
RecommandPojo frmCon = new RecommandPojo();
frmCon.setType("Container");
......@@ -301,7 +301,7 @@ public class RecommendUtil {
RecommandPojo frmText = new RecommandPojo();
frmText.setType("Text");
frmText.setText("${data.num}");
frmText.setFontSize("25dp");
frmText.setFontSize("22dp");
frmCon.setItems(Collections.singletonList(frmText));
frame.setItems(Collections.singletonList(frmCon));
......@@ -379,10 +379,10 @@ public class RecommendUtil {
//frame
RecommandPojo frame = new RecommandPojo();
frame.setType("Frame");
frame.setWidth("40dp");
frame.setHeight("40dp");
frame.setBackgroundColor("rgba(0,0,0,0.9)");
frame.setBorderRadius("12dp");
frame.setWidth("35dp");
frame.setHeight("35dp");
frame.setBackgroundColor("rgb(30,144,255)");
frame.setBorderRadius("20dp");
RecommandPojo frmCon = new RecommandPojo();
frmCon.setType("Container");
......@@ -393,7 +393,7 @@ public class RecommendUtil {
RecommandPojo frmText = new RecommandPojo();
frmText.setType("Text");
frmText.setText("4");
frmText.setFontSize("28dp");
frmText.setFontSize("22dp");
frmCon.setItems(Collections.singletonList(frmText));
frame.setItems(Collections.singletonList(frmCon));
......@@ -444,6 +444,7 @@ public class RecommendUtil {
private static List<RecommandBotInfo> getListData(int row,int begin, int end, List<ProjectData> bots, StringBuilder botIds) {
List<RecommandBotInfo> data = new ArrayList<>();
int n = 1+row*4;
end = end > bots.size() ? bots.size() : end;
for (int i = begin; i < end; i++) {
ProjectData bot = bots.get(i);
botIds.append(bot.getBotAccount()).append(File.separator);
......@@ -461,7 +462,7 @@ public class RecommendUtil {
for (int i = begin; i < end; i++) {
ProjectData bot = bots.get(i);
String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
RecommandBotInfo detail = new RecommandBotInfo(bot.getBannerImgUrl(),imageId, TempleUtils.correctName(bot.getName()));
RecommandBotInfo detail = new RecommandBotInfo(bot.getBannerImgUrl(),imageId, bot.getName());
detail.setNum(i-begin+n);
data.add(detail);
}
......@@ -504,10 +505,10 @@ public class RecommendUtil {
//frame
RecommandPojo frame = new RecommandPojo();
frame.setType("Frame");
frame.setWidth("40dp");
frame.setHeight("40dp");
frame.setBackgroundColor("rgba(0,0,0,0.9)");
frame.setBorderRadius("12dp");
frame.setWidth("35dp");
frame.setHeight("35dp");
frame.setBackgroundColor("rgb(30,144,255)");
frame.setBorderRadius("20dp");
RecommandPojo frmCon = new RecommandPojo();
frmCon.setType("Container");
......@@ -518,7 +519,7 @@ public class RecommendUtil {
RecommandPojo frmText = new RecommandPojo();
frmText.setType("Text");
frmText.setText("${data.num}");
frmText.setFontSize("28dp");
frmText.setFontSize("22dp");
frmCon.setItems(Collections.singletonList(frmText));
frame.setItems(Collections.singletonList(frmCon));
......
package ai.qiwu.com.xiaoduhome.pojo;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.csvreader.CsvReader;
import com.csvreader.CsvWriter;
import com.eclipsesource.json.JsonObject;
import lombok.*;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVParser;
import org.apache.commons.csv.CSVPrinter;
import org.apache.commons.csv.CSVRecord;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.util.DigestUtils;
import java.io.*;
import java.net.URLDecoder;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
......
......@@ -28,8 +28,8 @@ public interface XiaoDuOrderTbRepository extends JpaRepository<XiaoDuOrderTB, Lo
@Modifying
@Transactional(rollbackFor = Exception.class)
@Query(value = "UPDATE xiaodu_order_tb SET order_id=?1,status=1,update_time=now() WHERE ch_order_id=?2",nativeQuery = true)
void updateAterSeccessPayed(String orderId,String chOrderId);
@Query(value = "UPDATE xiaodu_order_tb SET order_id=?1,status=1,creation_timestamp=?3,update_time=now() WHERE ch_order_id=?2",nativeQuery = true)
void updateAterSeccessPayed(String orderId,String chOrderId, String createTimestamp);
void deleteByBotIdAndChOrderId(String botId, String chOrderId);
......
......@@ -17,6 +17,7 @@ import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuOrderTbRepository;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baidu.dueros.data.request.pay.event.ChargeEvent;
import com.baidu.dueros.data.request.pay.event.Payload;
import com.baidu.dueros.data.response.directive.pay.Charge;
......@@ -42,7 +43,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static ai.qiwu.com.xiaoduhome.common.Constants.CO_HI_PAGE_SIZE;
import static ai.qiwu.com.xiaoduhome.common.Constants.IMG_PREFIX;
import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.*;
import static ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew.curTime;
......@@ -106,7 +106,7 @@ public class DplbotServiceUtil {
static String getUserIdByToken(String accessToken, String channelId) {
try {
HashMap<String, String> headers = new HashMap<>();
// headers.put("App-Channel-Id", channelId);
headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
headers.put("Authorization", new StringBuilder(BEARER).append(accessToken).toString());
String str = OkHttp3Utils.doGet(USER_ID_BY_TOKEN, new HashMap<>(), headers);
log.info("getUserIdByToken:{}",str);
......@@ -143,20 +143,22 @@ public class DplbotServiceUtil {
Map<String, String> params = new HashMap<>();
params.put("userId", URLEncoder.encode(userId, "UTF-8"));
params.put("channelId", channelId);
params.put("jytUserId", jytUserId);
String response = OkHttp3Utils.doGet(HOST_UTL+"/audio_box/behavior", params);
if (StringUtils.isNotBlank(response)) {
JSONObject result = JSON.parseObject(response);
if (NumberUtils.INTEGER_ONE.equals(result.getInteger("code"))) {
result = result.getJSONObject("data");
Map<String, Long> botAccount2HistoryTime = result.getObject("history", Map.class);
Map<String, Long> botAccount2Flowers = result.getObject("flowers", Map.class);
Map<String, Long> botAccount2FavoriteTime = result.getObject("favorite", Map.class);
Map<String, Long> botAccount2HistoryTime = JSON.parseObject(result.getJSONObject("history").toJSONString(), new TypeReference<HashMap<String,Long>>(){});
Map<String, Long> botAccount2Flowers = JSON.parseObject(result.getJSONObject("flowers").toJSONString(), new TypeReference<HashMap<String,Long>>(){});
Map<String, Long> botAccount2FavoriteTime = JSON.parseObject(result.getJSONObject("favorite").toJSONString(), new TypeReference<HashMap<String,Long>>(){});
UserBehaviorData data = new UserBehaviorData();
if (!CollectionUtils.isEmpty(botAccount2HistoryTime)) data.setUserBotId2History(botAccount2HistoryTime);
if (!CollectionUtils.isEmpty(botAccount2FavoriteTime)) data.setUserBotId2Collected(botAccount2FavoriteTime);
if (!CollectionUtils.isEmpty(botAccount2Flowers)) data.setUserBotId2Flowers(botAccount2Flowers);
if (!CollectionUtils.isEmpty(botAccount2HistoryTime)) data.getUserBotId2History().putAll(botAccount2HistoryTime);
if (!CollectionUtils.isEmpty(botAccount2FavoriteTime)) data.getUserBotId2Collected().putAll(botAccount2FavoriteTime);
if (!CollectionUtils.isEmpty(botAccount2Flowers)) data.getUserBotId2Flowers().putAll(botAccount2Flowers);
data.setJytUserId(jytUserId);
data.setChannel(channelId);
log.info("UserBehaviorData:"+data);
USER_HISTORY.put(userId, data);
}
}
......@@ -171,21 +173,23 @@ public class DplbotServiceUtil {
Map<String, String> params = new HashMap<>();
params.put("userId", userId);
params.put("channelId", channelId);
params.put("jytUserId", jytUserId);
try {
String response = OkHttp3Utils.doGet(HOST_UTL+"/audio_box/behavior", params);
if (StringUtils.isNotBlank(response)) {
JSONObject result = JSON.parseObject(response);
if (NumberUtils.INTEGER_ONE.equals(result.getInteger("code"))) {
result = result.getJSONObject("data");
Map<String, Long> botAccount2HistoryTime = result.getObject("history", Map.class);
Map<String, Long> botAccount2Flowers = result.getObject("flowers", Map.class);
Map<String, Long> botAccount2FavoriteTime = result.getObject("favorite", Map.class);
Map<String, Long> botAccount2HistoryTime = JSON.parseObject(result.getJSONObject("history").toJSONString(), new TypeReference<HashMap<String,Long>>(){});
Map<String, Long> botAccount2Flowers = JSON.parseObject(result.getJSONObject("flowers").toJSONString(), new TypeReference<HashMap<String,Long>>(){});
Map<String, Long> botAccount2FavoriteTime = JSON.parseObject(result.getJSONObject("favorite").toJSONString(), new TypeReference<HashMap<String,Long>>(){});
UserBehaviorData data = new UserBehaviorData();
if (!CollectionUtils.isEmpty(botAccount2HistoryTime)) data.setUserBotId2History(botAccount2HistoryTime);
if (!CollectionUtils.isEmpty(botAccount2FavoriteTime)) data.setUserBotId2Collected(botAccount2FavoriteTime);
if (!CollectionUtils.isEmpty(botAccount2Flowers)) data.setUserBotId2Flowers(botAccount2Flowers);
data.setJytUserId(jytUserId);
data.setChannel(channelId);
log.info("UserBehaviorData:"+data);
USER_HISTORY.put(userId, data);
return data;
}
......@@ -336,6 +340,7 @@ public class DplbotServiceUtil {
xiaoDuOrderTB.setIsBuy(false);
xiaoDuOrderTB.setStatus(false);
xiaoDuOrderTB.setChOrderId(orderId);
xiaoDuOrderTB.setDevice(1);
xiaoDuOrderTB.setTimeStamp(System.currentTimeMillis());
return xiaoDuOrderTB;
}
......@@ -389,7 +394,7 @@ public class DplbotServiceUtil {
// createTimestamp字段与baiduOrderReferenceId字段与之后百度方进行结算使用,
// 现在createTimestamp由于百度方的bug需等到九月份才能获取到
final String baiduOrderReferenceId = payload.getBaiduOrderReferenceId();
final String createTimestamp = "";
final String createTimestamp = payload.getAuthorizationDetails().getCreationTimestamp();
final String num = token.substring(sepIndex+1);
POOL.submit(() -> {
XiaoDuOrderTbRepository repository = BaseHolder.getBean("xiaoDuOrderTbRepository");
......@@ -397,7 +402,7 @@ public class DplbotServiceUtil {
try {
XiaoDuOrderTB tb = repository.getByChOrderId(chOrderId);
id = tb.getId();
repository.updateAterSeccessPayed(baiduOrderReferenceId,chOrderId);
repository.updateAterSeccessPayed(baiduOrderReferenceId,chOrderId, createTimestamp);
} catch (Exception e) {
// StringWriter writer = new StringWriter();
// e.printStackTrace(new PrintWriter(writer,true));
......@@ -486,7 +491,7 @@ public class DplbotServiceUtil {
log.info("favoriteProducts length:{}, start:{}", favoriteProducts.size(), start);
if (favoriteProducts.size() == 0) return null;
ArrayList<HistoryData> projectInfoList = new ArrayList<>();
int j = 1;
int j = start+1;
//log.info("id list:{}", favoriteProducts);
final StringBuilder build = new StringBuilder();
for (String botAccount :favoriteProducts) {
......@@ -543,7 +548,7 @@ public class DplbotServiceUtil {
if (historyProducts.size() == 0) return null;
ArrayList<HistoryData> projectInfoList = new ArrayList<>();
int i = 1;
int i = start+1;
final StringBuilder build = new StringBuilder();
SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
historyProducts.sort((o1, o2) -> (o1.getLastTime()<o2.getLastTime()) ? 1 : (o1.getLastTime().equals(o2.getLastTime())) ? 0 : -1);
......@@ -562,7 +567,7 @@ public class DplbotServiceUtil {
projectInfoList.add(data);
}
CollectHistoryDocument document = CollectHistoryUtils.getDocument(projectInfoList, false,
start, pageNum);
start/CO_HI_PAGE_SIZE +1, pageNum);
String idToken;
if (build.length() != 0) {
build.deleteCharAt(build.length()-1);
......
......@@ -253,7 +253,7 @@ public class ScheduleService implements InitializingBean {
log.info("getChannelAllBots:"+channel2Bots);
}
@Scheduled(cron = "0 */30 * * * ?")
// @Scheduled(cron = "0 */30 * * * ?")
public void getJiaoYouChannelRecordBots() {
String response;
JSONObject jsonObject;
......
......@@ -7,6 +7,7 @@ import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData;
import ai.qiwu.com.xiaoduhome.pojo.data.ProjectDataResult;
import ai.qiwu.com.xiaoduhome.pojo.playAside.AsideImageResponse;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
......@@ -27,7 +28,7 @@ import static ai.qiwu.com.xiaoduhome.common.Constants.UNIT_PRICE;
@Slf4j
@Component
public class ScheduleServiceNew implements InitializingBean {
public static volatile List<ProjectData> allProjects = new ArrayList<>();
private static volatile List<ProjectData> allProjects = new ArrayList<>();
private static volatile Map<String, ProjectData> botAccount2Project = new HashMap<>();
private static volatile Map<String, ProjectData> name2Project = new HashMap<>();
private static volatile Map<String, Map<String, Long>> channel2BotAccountList = new HashMap<>();
......@@ -37,11 +38,13 @@ public class ScheduleServiceNew implements InitializingBean {
static volatile Long curTime = System.currentTimeMillis();
public static final String[] CATEGORY = {"古风", "言情", "灾难", "冒险", "武侠", "穿越"};
public static final String[] CATEGORY_CHARAC={"gufeng","yanqing","zainan","maoxian","wuxia", "chuanyue"};
public static final String[] CATEGORY = {"古风", "言情", "灾难", "冒险", "武侠", "穿越", "答题", "经营"};
public static final String[] CATEGORY_CHARAC={"gufeng","yanqing","zainan","maoxian","wuxia", "chuanyue", "dati", "jingying"};
public static volatile Map<String, List<ProjectData>> category2Bots = new HashMap<>();
static volatile Map<String, List<String>> jiaoyouChannel2Bots = new HashMap<>();
@Override
public void afterPropertiesSet() throws Exception {
getAllProjects();
......@@ -64,9 +67,9 @@ public class ScheduleServiceNew implements InitializingBean {
botAcc.put(projectData.getBotAccount(), projectData);
name.put(projectData.getName(), projectData);
List<ProjectData> bots;
for (int i = 0; i < CATEGORY.length; i++) {
if (projectData.getLabels().contains(CATEGORY[i])) {
bots = category2Bots.computeIfAbsent(CATEGORY_CHARAC[i], s -> new ArrayList<>());
for (String s1 : CATEGORY) {
if (projectData.getLabels().contains(s1)) {
bots = category2Bots.computeIfAbsent(s1, s -> new ArrayList<>());
bots.add(projectData);
}
}
......@@ -117,6 +120,37 @@ public class ScheduleServiceNew implements InitializingBean {
});
}
@Scheduled(cron = "0 */30 * * * ?")
public void getJiaoYouChannelRecordBots() {
String response;
JSONObject jsonObject;
int count = 1;
boolean success = false;
do {
try {
response = OkHttp3Utils.doGet("http://didi-gz5.jiaoyou365.com:18082/api/data/audio/list/jiaoyou");
jsonObject = JSON.parseObject(response).getJSONObject("data");
Map<String, List<String>> map = jsonObject.toJavaObject(Map.class);
if (map != null && map.size() != 0) {
List<String> jiaoyouList = map.get("jiaoyou-audio-adult-test");
if (!CollectionUtils.isEmpty(jiaoyouList)) map.get("jiaoyou-audio-adult-test").add("遇见伽利略");
List<String> xiaoaiJiaoyouList = map.get("xiaoai-jiaoyou-audio-adult-test");
if (!CollectionUtils.isEmpty(xiaoaiJiaoyouList)) map.get("xiaoai-jiaoyou-audio-adult-test").add("遇见伽利略");
jiaoyouChannel2Bots = map;
success = true;
} else {
log.info("getChannelAllBots failed count="+count);
Thread.sleep(count*5);
}
} catch (Exception e) {
log.warn("getChannelAllBots: "+e);
}
count++;
} while (!success && count < 5);
log.info("getChannelAllBots:"+jiaoyouChannel2Bots);
}
static ProjectData getProjectByName(String name) {
return name2Project.get(name);
}
......
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>登录</title>
<script type="text/javascript">
function getToken() {
var state = document.getElementById("state").value;
var phoneNum = document.getElementById("phoneNum").value;
var captcha = document.getElementById("getCaptcha").value;
// alert("phone:"+phoneNum+",captcha:"+captcha);
var ajaxObj = new XMLHttpRequest();
//var uri = '/xiaodu/security/token?phoneNumber='+phoneNum+'&captcha='+captcha;
ajaxObj.open('get', '/xiaodu/security/token?phoneNumber='+phoneNum+'&captcha='+captcha);
ajaxObj.send();
ajaxObj.onreadystatechange = function () {
if (ajaxObj.readyState === 4 && ajaxObj.status === 200) {
if (ajaxObj.responseText === "1") {
// alert(1);
//var redirectUri = "https://xiaodu-dbp.baidu.com/saiya/auth/3428011e7f55ec4c10b2da1b00a1675b?code="+phoneNum;
//var redirectUri = "https://xiaodu.baidu.com/saiya/auth/3428011e7f55ec4c10b2da1b00a1675b?code="+phoneNum;
var redirectUri = "https://xiaodu-dbp.baidu.com/saiya/auth/15966f1c8158104bd82712f95d8a1150?code="+phoneNum;
if (state !== undefined && state !== null && state !== "") {
redirectUri = redirectUri + "&state"+state;
}
window.location.href = redirectUri;
}
}
}
}
function getCaptcha() {
var phoneNum = document.getElementById("phoneNum").value;
var ajaxObj = new XMLHttpRequest();
ajaxObj.open('get', '/xiaodu/security/captcha?phoneNumber='+phoneNum);
ajaxObj.send();
ajaxObj.onreadystatechange = function () {
if (ajaxObj.readyState === 4 && ajaxObj.status === 200) {
document.getElementById("captchaView").hidden = true;
document.getElementById("tokenView").hidden = false;
}
}
}
</script>
<style type="text/css">
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #eee;
margin:0;
}
.container {
width: 80%;
padding-left: 15px;
padding-right: 15px;
margin-right: auto;
margin-left: auto;
}
.whole {
text-align: center;
padding: 10px;
margin: 0 auto;
}
.title {
margin-top: 20px;
margin-bottom: 10px;
font-size: 26px;
}
.input {
margin-bottom: -1px;
border-radius: 4px;
height: auto;
width: 88%;
padding: 10px;
font-size: 16px;
color: #555;
background-color: #fff;
border:1px solid #ccc;
}
.click {
display: block;
font-size: 16px;
border-radius: 4px;
color: #fff;
background-color: #337ab7;
padding: 6px 12px;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
border: 1px solid transparent;
margin:10px auto;
width: 96%;
}
</style>
</head>
<body>
<div class="container">
<input type="text" id="state" th:hidden="true" th:default="*{userInfo.state}"/>
<div class="whole" th:hidden="false" id="captchaView">
<h2 class="title">获取验证码</h2>
<input type="text" id="phoneNum" name="phone" class="input" placeholder="请输入手机号"/>
<input type="button" onclick="getCaptcha()" name="captcha" id="captcha" class="click" value="点击获取验证码"/>
</div>
<div class="whole" th:hidden="true" id="tokenView">
<h2 class="title">请输入验证码</h2>
<input type="text" id="getCaptcha" name="phone" class="input" placeholder="请输入短信验证码"/>
<input type="button" id="toLoad" name="to_load" class="click" value="点击登录" onclick="getToken()"/>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>登录</title>
<script type="text/javascript">
function getToken() {
var state = document.getElementById("state").value;
var phoneNum = document.getElementById("phoneNum").value;
var captcha = document.getElementById("getCaptcha").value;
// alert("phone:"+phoneNum+",captcha:"+captcha);
var ajaxObj = new XMLHttpRequest();
//var uri = '/xiaodu/security/token?phoneNumber='+phoneNum+'&captcha='+captcha;
ajaxObj.open('get', '/xiaodu/security/token?phoneNumber='+phoneNum+'&captcha='+captcha);
ajaxObj.send();
ajaxObj.onreadystatechange = function () {
if (ajaxObj.readyState === 4 && ajaxObj.status === 200) {
if (ajaxObj.responseText === "1") {
// alert(1);
//var redirectUri = "https://xiaodu-dbp.baidu.com/saiya/auth/3428011e7f55ec4c10b2da1b00a1675b?code="+phoneNum;
//var redirectUri = "https://xiaodu.baidu.com/saiya/auth/3428011e7f55ec4c10b2da1b00a1675b?code="+phoneNum;
var redirectUri = "https://xiaodu-dbp.baidu.com/saiya/auth/15966f1c8158104bd82712f95d8a1150?code="+phoneNum;
if (state !== undefined && state !== null && state !== "") {
redirectUri = redirectUri + "&state"+state;
}
window.location.href = redirectUri;
}
}
}
}
function getCaptcha() {
var phoneNum = document.getElementById("phoneNum").value;
var ajaxObj = new XMLHttpRequest();
ajaxObj.open('get', '/xiaodu/security/captcha?phoneNumber='+phoneNum);
ajaxObj.send();
ajaxObj.onreadystatechange = function () {
if (ajaxObj.readyState === 4 && ajaxObj.status === 200) {
document.getElementById("captchaView").hidden = true;
document.getElementById("tokenView").hidden = false;
}
}
}
</script>
<style type="text/css">
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #eee;
margin:0;
}
.container {
width: 80%;
padding-left: 15px;
padding-right: 15px;
margin-right: auto;
margin-left: auto;
}
.whole {
text-align: center;
padding: 10px;
margin: 0 auto;
}
.title {
margin-top: 20px;
margin-bottom: 10px;
font-size: 26px;
}
.input {
margin-bottom: -1px;
border-radius: 4px;
height: auto;
width: 88%;
padding: 10px;
font-size: 16px;
color: #555;
background-color: #fff;
border:1px solid #ccc;
}
.click {
display: block;
font-size: 16px;
border-radius: 4px;
color: #fff;
background-color: #337ab7;
padding: 6px 12px;
font-weight: 400;
text-align: center;
white-space: nowrap;
vertical-align: middle;
cursor: pointer;
border: 1px solid transparent;
margin:10px auto;
width: 96%;
}
</style>
</head>
<body>
<div class="container">
<div id="main">
<div class="header">
<img src="https://didi-gz5.jiaoyou365.com/duai/image/headersimg.png"/>
</div>
<p class="title">欢迎来到晓悟</p>
<div class="inputBox">
<input type="text" id="state" th:hidden="true" th:default="*{userInfo.state}"/>
<div class="whole" th:hidden="false" id="captchaView">
<h2 class="title">获取验证码</h2>
<input type="text" id="phoneNum" name="phone" class="input" placeholder="请输入手机号"/>
<input type="button" onclick="getCaptcha()" name="captcha" id="captcha" class="click" value="点击获取验证码"/>
<div class="phonebox">
<input class="phone" type="text" placeholder="请输入手机号" id="phoneNum" />
</div>
<div class="whole" th:hidden="true" id="tokenView">
<h2 class="title">请输入验证码</h2>
<input type="text" id="getCaptcha" name="phone" class="input" placeholder="请输入短信验证码"/>
<input type="button" id="toLoad" name="to_load" class="click" value="点击登录" onclick="getToken()"/>
<div class="verificationbox">
<button onclick="getCaptcha()" id='logon' >获取验证码</button>
<input class="verification" type="text" placeholder="请输入验证吗" id="getCaptcha"/>
</div>
</div>
<button class="logon" onclick="getToken()">登录</button>
</div>
</body>
</html>
\ No newline at end of file
<style>
#logon{
font-size: 14px;
}
.header{
text-align: center;
width: 100%;
margin-top: 30px;
}
input::-webkit-input-placeholder {
color: #CCCCCC;
/* font-size: 36px; */
}
.title {
text-align: center;
font-size: 18px;
font-weight: 300 !important;
}
.inputBox {
display: flex;
flex-direction: column;
width: 100%;
}
.logon {
width: 80vw;
height: 44px;
border: none;
background: #FFD400;
font-size: 18px;
color: #2A2A2A;
margin-left: 10vw;
text-align: center;
line-height: 44px;
border-radius: 100px;
outline: none;
margin-top: 150px;
}
.phonebox,
.verificationbox {
width: 80vw;
height: 60px;
margin-left: 10vw;
position: relative;
font-size: 16px !important;
/* border: 1px solid red; */
}
.phone,
.verification {
margin-top: 30px;
border: none;
width: 99%;
border-bottom: 1px solid #CCCCCC;
outline: none;
padding-bottom: 5px;
}
.verificationbox button {
width: auto;
height: 30px;
font-size: 16px;
border: 1px solid #CCCCCC;
border-radius: 100px;
position: absolute;
right: 0px;
background: #fff;
top: 18px;
color: #dbdbdb;
outline: none;
}
</style>
<script type="text/javascript">
function getToken() {
var state = document.getElementById("state").value;
var phoneNum = document.getElementById("phoneNum").value;
var captcha = document.getElementById("getCaptcha").value;
// alert("phone:"+phoneNum+",captcha:"+captcha);
var ajaxObj = new XMLHttpRequest();
//var uri = '/xiaodu/security/token?phoneNumber='+phoneNum+'&captcha='+captcha;
ajaxObj.open('get', '/xiaodu/security/token?phoneNumber='+phoneNum+'&captcha='+captcha);
ajaxObj.send();
ajaxObj.onreadystatechange = function () {
if (ajaxObj.readyState === 4 && ajaxObj.status === 200) {
if (ajaxObj.responseText === "1") {
// alert(1);
//var redirectUri = "https://xiaodu-dbp.baidu.com/saiya/auth/3428011e7f55ec4c10b2da1b00a1675b?code="+phoneNum;
//var redirectUri = "https://xiaodu.baidu.com/saiya/auth/3428011e7f55ec4c10b2da1b00a1675b?code="+phoneNum;
// var redirectUri = "https://xiaodu-dbp.baidu.com/saiya/auth/15966f1c8158104bd82712f95d8a1150?code="+phoneNum;
var redirectUri = "https://xiaodu-dbp.baidu.com/saiya/auth/3a0610f8af67a3c92d803a80a1c8976c?code="+phoneNum;
if (state !== undefined && state !== null && state !== "") {
redirectUri = redirectUri + "&state"+state;
}
window.location.href = redirectUri;
}
}
}
}
function getCaptcha() {
var oBtn = document.getElementById('logon');
console.log('点击了');
var time = 60;
var timer = null;
oBtn.innerHTML = time + '秒后重新发送';
oBtn.setAttribute('disabled', 'disabled'); // 禁用按钮
oBtn.setAttribute('class', 'disabled'); // 添加class 按钮样式变灰
timer = setInterval(function(){
if(time === 1){
clearInterval(timer);
oBtn.innerHTML = '重新发送';
oBtn.removeAttribute('disabled');
oBtn.removeAttribute('class');
}else{
time--;
oBtn.innerHTML = time + '秒后重新发送';
}
}, 1000);
var phoneNum = document.getElementById("phoneNum").value;
var ajaxObj = new XMLHttpRequest();
ajaxObj.open('get', '/xiaodu/security/captcha?phoneNumber='+phoneNum);
ajaxObj.send();
ajaxObj.onreadystatechange = function () {
if (ajaxObj.readyState === 4 && ajaxObj.status === 200) {
}
}
}
</script>
</html>
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