Commit 41e7e3b7 by 苗权威

8.30

parent cafc9711
......@@ -254,7 +254,7 @@ public class TTService {
// ResponseCodeWithData data = future.get(60, TimeUnit.SECONDS);
ResponseCodeWithData data = future.get();
if (data.getCode() != 200) {
log.error("下载:{}音频失败, status:{}", data.getCode());
log.error("下载音频失败, status:{}", data.getCode());
TTServiceUtil.buildTTS_lsResponse(response, new TTSResponse(data.getCode()), null, data.getCode());
return;
}
......
......@@ -105,7 +105,9 @@ public class Utils {
String[] names = word.split("、");
List<String> botNames = new ArrayList<>();
for (String name : names) {
botNames.add(name.substring(1, name.length()-1));
int i = name.indexOf(":");
if (i == -1) i = name.length()-1;
botNames.add(name.substring(1, i));
}
return botNames;
}
......
......@@ -2,6 +2,9 @@ package ai.qiwu.com.xiaoduhome.common.temple;
import ai.qiwu.com.xiaoduhome.common.BaseHolder;
import ai.qiwu.com.xiaoduhome.common.Constants;
import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyDocument;
import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyPageItemData;
import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyPojo;
import ai.qiwu.com.xiaoduhome.common.temple.playUpdate.PlayUpdateDocument;
import ai.qiwu.com.xiaoduhome.common.temple.playUpdate.PlayUpdatePojo;
import ai.qiwu.com.xiaoduhome.common.temple.rank.RankBotInfo;
......@@ -63,6 +66,23 @@ public class TempleUtils {
return document;
}
public static FunnyDocument getFunnyDocument(List<OnProductDetail> bots) {
FunnyDocument document = JSON.parseObject(getDPLTemple("static/json/funny.json"), FunnyDocument.class);
List<FunnyPageItemData> datas = new ArrayList<>();
FunnyPojo page = document.getMainTemplate().getItems().get(1).getItems().get(0);
List<FunnyPojo> dataList = new ArrayList<>();
page.setItems(dataList);
for (OnProductDetail bot : bots) {
FunnyPageItemData data = new FunnyPageItemData();
data.setImgSrc(new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString());
data.setText(bot.getIntro());
datas.add(data);
dataList.add(getFunnyPageItemPojo());
}
page.setData(datas);
return document;
}
public static RankingDocument getRanking() {
if (RANKING_DOCUMENT != null) {
return RANKING_DOCUMENT;
......@@ -228,8 +248,71 @@ public class TempleUtils {
return FRAME_CATEGORY;
}
public static void main(String[] args) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
System.out.println(sdf.format(new java.sql.Date(1566887509312L)));
private static FunnyPojo getFunnyPageItemPojo() {
FunnyPojo pojo = new FunnyPojo();
pojo.setType("Container");
pojo.setFlexDirection("row");
pojo.setWidth("100%");
pojo.setHeight("100%");
FunnyPojo image = new FunnyPojo();
image.setSrc("${data.imgSrc}");
image.setType("Image");
image.setMarginTop("30dp");
image.setHeight("400dp");
image.setWidth("400dp");
image.setMarginLeft("25dp");
FunnyPojo textContainer = new FunnyPojo();
textContainer.setType("Container");
textContainer.setWidth("500dp");
textContainer.setHeight("100%");
FunnyPojo text = new FunnyPojo();
text.setType("Text");
text.setText("${data.text}");
text.setFontSize("25dp");
text.setLineHeight("60dp");
text.setMarginTop("20dp");
text.setMarginLeft("10dp");
List<FunnyPojo> textContainerItems = new ArrayList<>();
textContainerItems.add(text);
textContainer.setItems(textContainerItems);
List<FunnyPojo> pojoItems = new ArrayList<>();
pojoItems.add(image);
pojoItems.add(textContainer);
pojo.setItems(pojoItems);
return pojo;
}
public static void main(String[] args) throws IOException, CloneNotSupportedException {
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
// System.out.println(sdf.format(new java.sql.Date(1566887509312L)));
new Thread(() -> {
int i = 3000;
long start = System.currentTimeMillis();
while (i-- > 0) {
try {
FunnyPojo pageItem = JSON.parseObject(getJsonFromName("static/json/funnyPageItem.json"),FunnyPojo.class);
} catch (IOException e) {
e.printStackTrace();
}
}
long end = System.currentTimeMillis();
System.out.println("JSON:"+(end-start));
}).start();
new Thread(() -> {
int i = 3000;
long start = System.currentTimeMillis();
while (i-- > 0) {
getFunnyPageItemPojo();
}
long end = System.currentTimeMillis();
System.out.println("TEST:"+(end-start));
}).start();
}
}
package ai.qiwu.com.xiaoduhome.common.temple.funny;
import com.baidu.dueros.data.response.directive.dpl.Document;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-8-30 上午11:28
*/
@Getter
@Setter
@ToString
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class FunnyDocument extends Document {
private FunnyMainTemplate mainTemplate;
}
package ai.qiwu.com.xiaoduhome.common.temple.funny;
import ai.qiwu.com.xiaoduhome.common.temple.rank.RankingPojo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-8-30 上午11:28
*/
@Data
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class FunnyMainTemplate {
private List<String> parameters = new ArrayList<>();
private List<FunnyPojo> items;
public FunnyMainTemplate() {
this.parameters.add("payload");
this.items = new ArrayList<>();
}
}
package ai.qiwu.com.xiaoduhome.common.temple.funny;
import lombok.Data;
/**
* @author 苗权威
* @dateTime 19-8-30 下午1:09
*/
@Data
public class FunnyPageItemData {
private String imgSrc;
private String text;
}
package ai.qiwu.com.xiaoduhome.common.temple.funny;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-8-30 上午11:18
*/
@Data
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
public class FunnyPojo {
private String type;
private String height;
private String width;
private String position;
private String left;
private String top;
private String src;
private List<FunnyPojo> items;
private String headerTitle;
private Boolean hasBackIcon;
@JsonProperty("flex-direction")
private String flexDirection;
@JsonProperty("margin-top")
private String marginTop;
@JsonProperty("margin-left")
private String marginLeft;
@JsonProperty("font-size")
private String fontSize;
@JsonProperty("line-height")
private String lineHeight;
private List<FunnyPageItemData> data;
private String text;
private String bottom;
private List<String> hints;
private String direction;
private String componentId;
private String looping;
private String autoplay;
private List<Event> onLoaded;
}
......@@ -5,6 +5,7 @@ import ai.qiwu.com.xiaoduhome.service.DplBotService;
import ai.qiwu.com.xiaoduhome.service.ResponseEncapsulation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
......
......@@ -45,7 +45,8 @@ public class AppFlowerTB {
@Column
private Integer status;
@Column(name = "gmt_create")
@CreatedDate
@Column(name = "gmt_create",nullable = false,updatable = false)
private Date createTime;
@Column(name = "gmt_modified")
......
......@@ -5,6 +5,7 @@ import org.springframework.data.domain.Example;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
/**
* @author 苗权威
......@@ -13,9 +14,11 @@ import org.springframework.stereotype.Repository;
@Repository
public interface AppFlowerTBRepository extends JpaRepository<AppFlowerTB, Integer> {
@Transactional
@Query(value = "INSERT INTO app_flower_tb (module,bot_username,user_id,unit_price,number,order_id,status,gmt_create,gmt_modified) VALUES (0,?1,?2,1,1,?3,1,?4,?4)",nativeQuery = true)
void insertOrder(String botId, String userId, String orderId, String time);
@Transactional
@Override
<S extends AppFlowerTB> S save(S s);
......
......@@ -24,10 +24,12 @@ public interface XiaoDuOrderTbRepository extends JpaRepository<XiaoDuOrderTB, In
<S extends XiaoDuOrderTB> S saveAndFlush(S s);
@Transactional
@Query(value = "UPDATE xiaodu_order_id SET creation_timestamp=?2,order_id=?3,status=1,update_time=now() WHERE ch_order_id=?1",nativeQuery = true)
@Query(value = "UPDATE xiaodu_order_tb SET creation_timestamp=?2,order_id=?3,status=1,update_time=now() WHERE ch_order_id=?1",nativeQuery = true)
void updateAterSeccessPayed(String chOrderId, String creationTimestamp, String orderId);
@Transactional
@Override
void delete(XiaoDuOrderTB xiaoDuOrderTB);
void deleteByStatus(Boolean status);
}
......@@ -6,6 +6,7 @@ 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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -44,13 +45,16 @@ public class ScheduleService implements InitializingBean {
private final XiaoDuHistoryTBRepository xiaoDuHistoryTBRepository;
private final XiaoDuOrderTbRepository xiaoDuOrderTbRepository;
@Autowired
public ScheduleService(GameProjectTbRepository gameProjectTbRepository,
ProjectLabelRepository projectLabelRepository, AllOnProductInfoRepository allOnProductInfoRepository, XiaoDuHistoryTBRepository xiaoDuHistoryTBRepository) {
ProjectLabelRepository projectLabelRepository, AllOnProductInfoRepository allOnProductInfoRepository, XiaoDuHistoryTBRepository xiaoDuHistoryTBRepository, XiaoDuOrderTbRepository xiaoDuOrderTbRepository) {
this.gameProjectTbRepository = gameProjectTbRepository;
this.projectLabelRepository = projectLabelRepository;
this.allOnProductInfoRepository = allOnProductInfoRepository;
this.xiaoDuHistoryTBRepository = xiaoDuHistoryTBRepository;
this.xiaoDuOrderTbRepository = xiaoDuOrderTbRepository;
}
@Scheduled(cron = "0 0 19 * * ?")
......@@ -113,6 +117,13 @@ public class ScheduleService implements InitializingBean {
//log.error("清理历史记录数据库出错:{}", e.toString());
}
@Scheduled(cron = "0 0 3 * * ?")
public void deleteUnPayedOrder() {
new Thread(() -> {
xiaoDuOrderTbRepository.deleteByStatus(false);
}).start();
}
@Override
public void afterPropertiesSet() throws Exception {
initAllOnTableProductInfo();
......
{
"type": "DPL",
"version": "1.0",
"mainTemplate": {
"parameters": [
"payload"
],
"items": [
{
"type": "Image",
"height": "100%",
"width": "100%",
"position": "absolute",
"left": "0dp",
"top": "0dp",
"src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg"
},
{
"type": "Container",
"width": "100%",
"height": "100%",
"items": [
{
"type": "Pager",
"direction": "horizontal",
"componentId": "funnyPage",
"width": "100%",
"height": "100%",
"onLoaded": [
{
"type": "AutoPage",
"componentId": "funnyPage",
"durationInMillisecond": 3000
}
]
}
]
},
{
"type": "Audio",
"componentId": "audioCom",
"looping": "false",
"autoplay": "true"
},
{
"type": "Container",
"position": "absolute",
"width": "100%",
"left": "0",
"bottom": "0",
"items": [
{
"type": "Footer",
"hints": [
"返回/回到首页","可左右滑动"
]
}
]
}
]
}
}
\ No newline at end of file
{
"type": "Container",
"flex-direction": "row",
"width": "100%",
"height": "100%",
"items": [
{
"type": "Image",
"margin-top": "30dp",
"height": "400dp",
"width": "400dp",
"margin-left": "25dp",
"src": "${data.imgSrc}"
},
{
"type": "Container",
"width": "500dp",
"height": "100%",
"items": [
{
"type": "Text",
"text": "${data.text}",
"font-size": "25dp",
"line-height":"60dp",
"margin-top": "30dp",
"margin-left": "10dp"
}
]
}
]
}
\ No newline at end of file
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