Commit b4080f3e by 苗权威

7.6

parent a1fd2b1a
......@@ -7,20 +7,26 @@
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="dingdong" />
<module name="jdwhale" />
<module name="ruoqi" />
<module name="smartbox" />
<module name="spirit" />
<module name="xiaoai" />
<module name="xiaodu" />
<module name="xiaoya" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="rokid" target="1.8" />
<module name="RokidBox" target="1.8" />
</bytecodeTargetLevel>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="dingdong" options="-parameters" />
<module name="jdwhale" options="-parameters" />
<module name="rokid" options="-parameters" />
<module name="ruoqi" options="-parameters" />
<module name="spirit" options="-parameters" />
<module name="spirit" options="-parameters -extdirs /usr/local/intellij/workplace/smartbox/spirit/src/main/resources/lib" />
<module name="xiaoai" options="-parameters" />
<module name="xiaodu" options="-parameters" />
<module name="xiaoya" options="-parameters" />
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM">
<file url="file://$PROJECT_DIR$/RokidBox" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/dingdong" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/jdwhale" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/rokid" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/ruoqi" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/spirit" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/xiaoai" charset="UTF-8" />
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$/dingdong" />
<file type="web" url="file://$PROJECT_DIR$/jdwhale" />
<file type="web" url="file://$PROJECT_DIR$/RokidBox" />
<file type="web" url="file://$PROJECT_DIR$/spirit" />
<file type="web" url="file://$PROJECT_DIR$/xiaodu" />
<file type="web" url="file://$PROJECT_DIR$/xiaoya" />
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
......@@ -11,6 +19,8 @@
<option value="$PROJECT_DIR$/xiaoya/pom.xml" />
<option value="$PROJECT_DIR$/dingdong/pom.xml" />
<option value="$PROJECT_DIR$/ruoqi/pom.xml" />
<option value="$PROJECT_DIR$/rokid/pom.xml" />
<option value="$PROJECT_DIR$/jdwhale/pom.xml" />
</list>
</option>
</component>
......
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="4a2f3afc-3cd8-46bb-9e78-9759246c43dc" name="Default Changelist" comment="" />
<list default="true" id="4a2f3afc-3cd8-46bb-9e78-9759246c43dc" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/compiler.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/compiler.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/encodings.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/encodings.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/misc.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dingdong/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/dingdong/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/DingdongApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/DingdongApplication.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/Constants.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/controller/DingDongController.java" beforeDir="false" afterPath="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/controller/DingDongController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseServiceCompromise.java" beforeDir="false" afterPath="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseServiceCompromise.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/dingdong/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/dingdong/src/main/resources/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ruoqi/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/ruoqi/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/ruoqi/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/ruoqi/src/main/resources/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spirit/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/spirit/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/spirit/src/main/java/ai/qiwu/tmall/spirit/SpiritApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/spirit/src/main/java/ai/qiwu/tmall/spirit/SpiritApplication.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xiaoai/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/xiaoai/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xiaodu/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/xiaodu/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/XiaoduApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/XiaoduApplication.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Constants.java" beforeDir="false" afterPath="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Constants.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java" beforeDir="false" afterPath="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/ResponseEncapsulation.java" beforeDir="false" afterPath="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/ResponseEncapsulation.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xiaodu/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/xiaodu/src/main/resources/application.properties" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xiaoya/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/xiaoya/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xiaoya/src/main/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/xiaoya/src/main/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplication.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/xiaoya/src/main/resources/application.properties" beforeDir="false" afterPath="$PROJECT_DIR$/xiaoya/src/main/resources/application.properties" afterDir="false" />
</list>
<ignored path="$PROJECT_DIR$/out/" />
<ignored path="$PROJECT_DIR$/target/" />
<ignored path="$PROJECT_DIR$/spirit/target/" />
......@@ -10,86 +36,71 @@
<ignored path="$PROJECT_DIR$/xiaoya/target/" />
<ignored path="$PROJECT_DIR$/dingdong/target/" />
<ignored path="$PROJECT_DIR$/ruoqi/target/" />
<ignored path="$PROJECT_DIR$/rokid/target/" />
<ignored path="$PROJECT_DIR$/RokidBox/target/" />
<ignored path="$PROJECT_DIR$/jdwhale/target/" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="DatabaseView">
<option name="SHOW_INTERMEDIATE" value="true" />
<option name="GROUP_DATA_SOURCES" value="true" />
<option name="GROUP_SCHEMA" value="true" />
<option name="GROUP_CONTENTS" value="false" />
<option name="SORT_POSITIONED" value="false" />
<option name="SHOW_EMPTY_GROUPS" value="false" />
<option name="AUTO_SCROLL_FROM_SOURCE" value="false" />
<option name="HIDDEN_KINDS">
<set />
</option>
<expand />
<select />
</component>
<component name="FavoritesManager">
<favorites_list name="smartbox" />
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/RequestTerminal.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="865">
<caret line="57" column="51" lean-forward="true" selection-start-line="57" selection-start-column="51" selection-end-line="57" selection-end-column="51" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/ResponseEncapsulation.java">
<entry file="file://$PROJECT_DIR$/spirit/src/main/java/ai/qiwu/tmall/spirit/service/SpiritService.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1019">
<caret line="27" column="3" lean-forward="true" selection-start-line="27" selection-start-column="3" selection-end-line="27" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
<state relative-caret-position="1364">
<caret line="102" column="13" lean-forward="true" selection-start-line="102" selection-start-column="13" selection-end-line="102" selection-end-column="13" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/service/XiaoAiService.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="491">
<caret line="26" column="27" selection-start-line="26" selection-start-column="27" selection-end-line="26" selection-end-column="27" />
<state relative-caret-position="533">
<caret line="49" column="9" lean-forward="true" selection-start-line="49" selection-start-column="9" selection-end-line="49" selection-end-column="9" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/bot/BaseBot.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="58">
<caret line="321" column="16" selection-start-line="321" selection-start-column="16" selection-end-line="321" selection-end-column="16" />
<folding>
<element signature="e#11937#11938#0" expanded="true" />
<element signature="e#11983#11984#0" expanded="true" />
<element signature="e#12017#12018#0" expanded="true" />
<element signature="e#12062#12063#0" expanded="true" />
<element signature="e#5505#5506#0" expanded="true" />
<element signature="e#5564#5565#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="true">
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/certificate/Certificate.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/controller/XiaoAiController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="89" column="52" lean-forward="true" selection-start-line="89" selection-start-column="52" selection-end-line="89" selection-end-column="52" />
<folding>
<element signature="e#4481#4482#0" expanded="true" />
<element signature="e#4525#4526#0" expanded="true" />
</folding>
<state relative-caret-position="132">
<caret line="6" column="29" selection-start-line="6" selection-start-column="29" selection-end-line="6" selection-end-column="29" />
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/bot/AudioPlayer.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/commons/XiaoAiConstants.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="132">
<caret line="22" column="36" selection-start-line="22" selection-start-column="36" selection-end-line="22" selection-end-column="36" />
<state relative-caret-position="440">
<caret line="20" column="48" selection-start-line="20" selection-start-column="48" selection-end-line="20" selection-end-column="48" />
</state>
</provider>
</entry>
......@@ -108,39 +119,73 @@
<find>response</find>
</findStrings>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/jdwhale/src/main/java/ai/qiwu/mqw/jdwhale/model/RequestModel/DingDongRequest.java" />
<option value="$PROJECT_DIR$/jdwhale/src/main/java/ai/qiwu/mqw/jdwhale/service/ParseService.java" />
<option value="$PROJECT_DIR$/jdwhale/src/main/java/ai/qiwu/mqw/jdwhale/service/ParseServiceWithoutLRU.java" />
<option value="$PROJECT_DIR$/jdwhale/src/main/java/ai/qiwu/mqw/jdwhale/controller/DingDongController.java" />
<option value="$PROJECT_DIR$/pom.xml" />
<option value="$PROJECT_DIR$/xiaoya/src/main/java/ai/qiwu/xiaoya/xiaoya/XiaoyaApplication.java" />
<option value="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/XiaoduApplication.java" />
<option value="$PROJECT_DIR$/xiaodu/src/main/resources/application.properties" />
<option value="$PROJECT_DIR$/xiaoya/src/main/resources/application.properties" />
<option value="$PROJECT_DIR$/xiaodu/pom.xml" />
<option value="$PROJECT_DIR$/spirit/src/main/java/ai/qiwu/tmall/spirit/SpiritApplication.java" />
<option value="$PROJECT_DIR$/jdwhale/src/main/java/ai/qiwu/mqw/jdwhale/JdwhaleApplication.java" />
<option value="$PROJECT_DIR$/jdwhale/pom.xml" />
<option value="$PROJECT_DIR$/xiaoya/pom.xml" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/DingdongApplication.java" />
<option value="$PROJECT_DIR$/dingdong/pom.xml" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/applicationInfo/ApplicationInfo.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/session/Session.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/user/User.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/DingDongRequest.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/DirectiveItem.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/Directive.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/resources/application.properties" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/card/Card.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/DingDongResponse.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/SnowFlake.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/LastPresponseTimeAndAudio.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/LastResponseTimeAndAudio.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/Constants.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/controller/DingDongController.java" />
<option value="$PROJECT_DIR$/xiaodu/pom.xml" />
<option value="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/pojo/AudioUrlAndText.java" />
<option value="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Constants.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseService.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseServiceCompromise.java" />
<option value="$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/Utils.java" />
<option value="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Utils.java" />
<option value="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/XiaoDuService.java" />
<option value="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/RequestTerminal.java" />
<option value="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/ResponseEncapsulation.java" />
<option value="$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java" />
<option value="$PROJECT_DIR$/spirit/src/main/java/ai/qiwu/tmall/spirit/controller/SpiritController.java" />
<option value="$PROJECT_DIR$/spirit/pom.xml" />
<option value="$PROJECT_DIR$/xiaoya/src/main/java/ai/qiwu/xiaoya/xiaoya/controller/XiaoYaController.java" />
<option value="$PROJECT_DIR$/xiaoya/src/main/resources/logback.xml" />
<option value="$PROJECT_DIR$/xiaodu/src/main/resources/logback.xml" />
<option value="$PROJECT_DIR$/spirit/src/main/resources/logback.xml" />
<option value="$PROJECT_DIR$/jdwhale/src/main/resources/logback.xml" />
<option value="$PROJECT_DIR$/dingdong/src/main/resources/logback.xml" />
<option value="$PROJECT_DIR$/xiaoai/pom.xml" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/session/Application.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/session/User.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/session/Session.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/context/ClientAppInfo.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/context/Context.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/innerRequest/EventProperty.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/innerRequest/slot/Slot.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/innerRequest/SlotInfo.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/XiaoAiRequest.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/toSpeak/ToSpeak.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/toDisplay/UITemplate/Item/Item.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/toDisplay/UITemplate/UITemplate.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/toDisplay/ToDisplay.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/directive/AudioItem/AudioStream.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/directive/AudioItem/AudioItem.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/directive/ttsItem/TTSItem.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/directive/Directive.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/actionProperty/ActionProperty.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/registerEvent/RegisterEvent.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/XiaoAiResponse.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/Response.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/innerRequest/Request.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/commons/Utils.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/commons/XiaoAiConstants.java" />
<option value="$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/service/XiaoAiService.java" />
</list>
</option>
</component>
<component name="MavenImportPreferences">
<option name="generalSettings">
<MavenGeneralSettings>
<option name="userSettingsFile" value="$PROJECT_DIR$/../../../../maven/apache-maven-3.6.0/conf/settings.xml" />
</MavenGeneralSettings>
</option>
</component>
<component name="MavenProjectNavigator">
<treeState>
<expand />
......@@ -151,17 +196,19 @@
<option name="skipTests" value="true" />
</component>
<component name="ProjectFrameBounds">
<option name="x" value="605" />
<option name="y" value="65" />
<option name="width" value="1416" />
<option name="x" value="515" />
<option name="y" value="51" />
<option name="width" value="1417" />
<option name="height" value="1002" />
</component>
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="1" id="Add" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
......@@ -172,25 +219,25 @@
<path>
<item name="smartbox" type="b2602c69:ProjectViewProjectNode" />
<item name="smartbox" type="462c0819:PsiDirectoryNode" />
<item name="xiaodu" type="462c0819:PsiDirectoryNode" />
<item name="xiaoai" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="smartbox" type="b2602c69:ProjectViewProjectNode" />
<item name="smartbox" type="462c0819:PsiDirectoryNode" />
<item name="xiaodu" type="462c0819:PsiDirectoryNode" />
<item name="xiaoai" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="smartbox" type="b2602c69:ProjectViewProjectNode" />
<item name="smartbox" type="462c0819:PsiDirectoryNode" />
<item name="xiaodu" type="462c0819:PsiDirectoryNode" />
<item name="xiaoai" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="smartbox" type="b2602c69:ProjectViewProjectNode" />
<item name="smartbox" type="462c0819:PsiDirectoryNode" />
<item name="xiaodu" type="462c0819:PsiDirectoryNode" />
<item name="xiaoai" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
......@@ -198,27 +245,18 @@
<path>
<item name="smartbox" type="b2602c69:ProjectViewProjectNode" />
<item name="smartbox" type="462c0819:PsiDirectoryNode" />
<item name="xiaodu" type="462c0819:PsiDirectoryNode" />
<item name="xiaoai" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="xiaodu" type="462c0819:PsiDirectoryNode" />
</path>
<path>
<item name="smartbox" type="b2602c69:ProjectViewProjectNode" />
<item name="smartbox" type="462c0819:PsiDirectoryNode" />
<item name="xiaodu" type="462c0819:PsiDirectoryNode" />
<item name="src" type="462c0819:PsiDirectoryNode" />
<item name="main" type="462c0819:PsiDirectoryNode" />
<item name="java" type="462c0819:PsiDirectoryNode" />
<item name="xiaodu" type="462c0819:PsiDirectoryNode" />
<item name="service" type="462c0819:PsiDirectoryNode" />
<item name="xiaoai" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
<pane id="PackagesPane" />
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
......@@ -228,9 +266,31 @@
<property name="RequestMappingsPanelWidth1" value="75" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1561806107734" />
<property name="com.android.tools.idea.instantapp.provision.ProvisionBeforeRunTaskProvider.myTimeStamp" value="1562383657744" />
<property name="nodejs_interpreter_path.stuck_in_default_project" value="undefined stuck path" />
<property name="nodejs_npm_path_reset_for_default_project" value="true" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.0" />
<property name="project.structure.side.proportion" value="0.254023" />
<property name="settings.editor.selected.configurable" value="preferences.externalResources" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/spirit/src/main/resources/static/aligenie" />
<recent name="$PROJECT_DIR$/spirit/src/main/resources/lib" />
<recent name="$PROJECT_DIR$/ruoqi/src/main/resources/lib" />
</key>
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="ai.qiwu.mqw.rokid.dispatcher" />
<recent name="ai.qiwu.mqw.rokid" />
</key>
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/dingdong/src/main/resources" />
<recent name="$PROJECT_DIR$/jdwhale/src/main/resources" />
<recent name="$PROJECT_DIR$/xiaoya/src/main/resources" />
<recent name="$PROJECT_DIR$/xiaodu/src/main/resources" />
<recent name="$PROJECT_DIR$/jdwhale/src/main/java/ai/qiwu/mqw/jdwhale" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
......@@ -244,8 +304,8 @@
</list>
</option>
</component>
<component name="RunManager" selected="ECS on Alibaba Cloud.ECS on Alibaba Cloud">
<configuration name="ECS on Alibaba Cloud" type="ECS_RUN_CONFIGRATION" factoryName="Ecs configuration factory">
<component name="RunManager" selected="ECS on Alibaba Cloud.rokid">
<configuration name="dingdong" type="ECS_RUN_CONFIGRATION" factoryName="Ecs configuration factory">
<option name="address" />
<option name="alreadyReset" value="true" />
<option name="autoOpen" value="false" />
......@@ -275,6 +335,66 @@
<option name="Maven.BeforeRunTask" enabled="true" file="$PROJECT_DIR$/dingdong//pom.xml" goal="clean install" />
</method>
</configuration>
<configuration name="rokid" type="ECS_RUN_CONFIGRATION" factoryName="Ecs configuration factory">
<option name="address" />
<option name="alreadyReset" value="true" />
<option name="autoOpen" value="false" />
<option name="command" value="sh $PROJECT_DIR$/../../../../springbootdemo/rokid/restart.sh" />
<option name="defaultTabIdx" value="0" />
<option name="ecsInstance">
<EcsInstance>
<option name="instanceId" value="i-hp3fcvrhszjkd3cs1one" />
<option name="instanceName" value="launch-advisor-20180824" />
<option name="netType" value="vpc" />
<option name="privateIps" value="172.24.163.142" />
<option name="publicIps" value="39.104.83.143" />
<option name="regionId" value="cn-huhehaote" />
<option name="tags">
<list />
</option>
</EcsInstance>
</option>
<option name="hostTagId" value="0" />
<option name="location" value="$PROJECT_DIR$/../../../../springbootdemo/rokid/" />
<option name="pathOrUrl" value="$PROJECT_DIR$/target/smartbox-1.0-SNAPSHOT.pom" />
<option name="tagId" value="0" />
<option name="terminalCommand" />
<option name="type" value="ECS" />
<option name="uploadType" value="MAVEN" />
<method v="2">
<option name="Maven.BeforeRunTask" enabled="true" file="$PROJECT_DIR$/ruoqi/pom.xml" goal="clean install" />
</method>
</configuration>
<configuration name="xiaodu" type="ECS_RUN_CONFIGRATION" factoryName="Ecs configuration factory">
<option name="address" />
<option name="alreadyReset" value="true" />
<option name="autoOpen" value="false" />
<option name="command" value="sh $PROJECT_DIR$/../../../../springbootdemo/xiaodu/restart.sh" />
<option name="defaultTabIdx" value="0" />
<option name="ecsInstance">
<EcsInstance>
<option name="instanceId" value="i-hp3fcvrhszjkd3cs1one" />
<option name="instanceName" value="launch-advisor-20180824" />
<option name="netType" value="vpc" />
<option name="privateIps" value="172.24.163.142" />
<option name="publicIps" value="39.104.83.143" />
<option name="regionId" value="cn-huhehaote" />
<option name="tags">
<list />
</option>
</EcsInstance>
</option>
<option name="hostTagId" value="0" />
<option name="location" value="$PROJECT_DIR$/../../../../springbootdemo/xiaodu/" />
<option name="pathOrUrl" value="$PROJECT_DIR$/target/smartbox-1.0-SNAPSHOT.pom" />
<option name="tagId" value="0" />
<option name="terminalCommand" />
<option name="type" value="ECS" />
<option name="uploadType" value="MAVEN" />
<method v="2">
<option name="Maven.BeforeRunTask" enabled="true" file="$PROJECT_DIR$/xiaodu/pom.xml" goal="clean install" />
</method>
</configuration>
<configuration name="DingdongApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="dingdong" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ai.qiwu.dong.dingdong.DingdongApplication" />
......@@ -282,6 +402,20 @@
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="JdwhaleApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="jdwhale" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ai.qiwu.mqw.jdwhale.JdwhaleApplication" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="RokidApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="rokid" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ai.qiwu.mqw.rokid.RokidApplication" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="RuoqiApplication" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot">
<module name="ruoqi" />
<option name="SPRING_BOOT_MAIN_CLASS" value="ai.qiwu.rokid.ruoqi.RuoqiApplication" />
......@@ -318,13 +452,17 @@
</method>
</configuration>
<list>
<item itemvalue="ECS on Alibaba Cloud.ECS on Alibaba Cloud" />
<item itemvalue="ECS on Alibaba Cloud.dingdong" />
<item itemvalue="ECS on Alibaba Cloud.xiaodu" />
<item itemvalue="ECS on Alibaba Cloud.rokid" />
<item itemvalue="Spring Boot.DingdongApplication" />
<item itemvalue="Spring Boot.RuoqiApplication" />
<item itemvalue="Spring Boot.SpiritApplication" />
<item itemvalue="Spring Boot.XiaoaiApplication" />
<item itemvalue="Spring Boot.XiaoduApplication" />
<item itemvalue="Spring Boot.XiaoyaApplication" />
<item itemvalue="Spring Boot.RokidApplication" />
<item itemvalue="Spring Boot.JdwhaleApplication" />
</list>
</component>
<component name="SvnConfiguration">
......@@ -341,506 +479,595 @@
<workItem from="1561598755901" duration="21557000" />
<workItem from="1561686159112" duration="25124000" />
<workItem from="1561723387207" duration="4372000" />
<workItem from="1561772168078" duration="29034000" />
<workItem from="1561772168078" duration="31124000" />
<workItem from="1561945871096" duration="30183000" />
<workItem from="1562030208353" duration="6676000" />
<workItem from="1562044274558" duration="16038000" />
<workItem from="1562118531762" duration="19427000" />
<workItem from="1562144308273" duration="7116000" />
<workItem from="1562225104415" duration="9703000" />
<workItem from="1562299642713" duration="19061000" />
<workItem from="1562375216495" duration="8185000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="80911000" />
<option name="totallyTimeSpent" value="199390000" />
</component>
<component name="ToolWindowManager">
<frame x="257" y="45" width="1416" height="1002" extended-state="0" />
<frame x="515" y="51" width="1417" height="1002" extended-state="0" />
<layout>
<window_info id="Structure" order="0" sideWeight="0.5017626" side_tool="true" weight="0.25730994" />
<window_info id="Structure" order="0" sideWeight="0.50294465" side_tool="true" weight="0.25657895" />
<window_info id="Designer" order="1" />
<window_info id="Image Layers" order="2" />
<window_info id="Capture Tool" order="3" />
<window_info id="UI Designer" order="4" />
<window_info id="Favorites" order="5" sideWeight="0.5017626" side_tool="true" weight="0.25730994" />
<window_info content_ui="combo" id="Project" order="6" sideWeight="0.49823737" weight="0.25730994" />
<window_info id="Alibaba Cloud Explorer" order="7" />
<window_info id="Web" order="8" side_tool="true" />
<window_info id="Alibaba Cloud Explorer" order="6" sideWeight="0.49941108" weight="0.32894737" />
<window_info id="Web" order="7" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="8" sideWeight="0.49705535" visible="true" weight="0.24543463" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" weight="0.31022328" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Run" order="2" weight="0.30035335" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39929327" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Spring" order="7" />
<window_info anchor="bottom" id="Terminal" order="8" />
<window_info anchor="bottom" id="Terminal" order="8" weight="0.3286219" />
<window_info anchor="bottom" id="Docker" order="9" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" weight="0.32979977" />
<window_info anchor="bottom" id="Java Enterprise" order="11" />
<window_info anchor="bottom" id="Database Changes" order="12" />
<window_info anchor="bottom" id="Version Control" order="13" />
<window_info anchor="bottom" id="Alibaba Cloud View" order="14" />
<window_info anchor="bottom" id="Messages" order="15" weight="0.42890716" />
<window_info anchor="bottom" id="Version Control" order="13" weight="0.32975295" />
<window_info anchor="bottom" id="Alibaba Cloud View" order="14" weight="0.32979977" />
<window_info anchor="bottom" id="Messages" order="15" weight="0.30270907" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Maven" order="3" weight="0.32967836" />
<window_info anchor="right" id="Maven" order="3" weight="0.20745069" />
<window_info anchor="right" id="Palette" order="4" />
<window_info anchor="right" id="Capture Analysis" order="5" />
<window_info anchor="right" id="Database" order="6" />
<window_info anchor="right" id="Database" order="6" weight="0.32967836" />
<window_info anchor="right" id="Palette&#9;" order="7" />
<window_info anchor="right" id="Theme Preview" order="8" />
<window_info anchor="right" id="Bean Validation" order="9" />
</layout>
<layout-to-restore>
<window_info id="Structure" order="0" sideWeight="0.50294465" side_tool="true" weight="0.25657895" />
<window_info id="Designer" order="1" />
<window_info id="Image Layers" order="2" />
<window_info id="Capture Tool" order="3" />
<window_info id="UI Designer" order="4" />
<window_info id="Favorites" order="5" sideWeight="0.5017626" side_tool="true" weight="0.25730994" />
<window_info id="Alibaba Cloud Explorer" order="6" sideWeight="0.49941108" weight="0.32894737" />
<window_info id="Web" order="7" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="8" sideWeight="0.49705535" visible="true" weight="0.24543463" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" weight="0.30035335" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.39929327" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="bottom" id="Spring" order="7" />
<window_info anchor="bottom" id="Terminal" order="8" weight="0.3286219" />
<window_info anchor="bottom" id="Docker" order="9" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" weight="0.32979977" />
<window_info anchor="bottom" id="Java Enterprise" order="11" />
<window_info anchor="bottom" id="Database Changes" order="12" />
<window_info anchor="bottom" id="Version Control" order="13" weight="0.32975295" />
<window_info anchor="bottom" id="Alibaba Cloud View" order="14" weight="0.32979977" />
<window_info anchor="bottom" id="Messages" order="15" weight="0.30270907" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
<window_info anchor="right" id="Maven" order="3" weight="0.20745069" />
<window_info anchor="right" id="Palette" order="4" />
<window_info anchor="right" id="Capture Analysis" order="5" />
<window_info anchor="right" id="Database" order="6" weight="0.32967836" />
<window_info anchor="right" id="Palette&#9;" order="7" />
<window_info anchor="right" id="Theme Preview" order="8" />
<window_info anchor="right" id="Bean Validation" order="9" />
</layout-to-restore>
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="editorHistoryManager">
<entry file="jar://$PROJECT_DIR$/../../../../java/jdk1.8.0_211/src.zip!/java/lang/Long.java">
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="464">
<caret line="547" column="23" selection-start-line="547" selection-start-column="23" selection-end-line="547" selection-end-column="23" />
<state>
<caret column="6" selection-start-column="6" selection-end-column="6" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/resources/application.properties">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/DingdongApplication.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="22">
<caret line="1" lean-forward="true" selection-start-line="1" selection-end-line="1" />
<state relative-caret-position="242">
<caret line="16" column="58" selection-start-line="16" selection-start-column="58" selection-end-line="16" selection-end-column="58" />
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../../../../java/jdk1.8.0_211/src.zip!/java/util/Random.java">
<entry file="file://$PROJECT_DIR$/jdwhale/src/main/resources/application.properties">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/jdwhale/src/main/java/ai/qiwu/mqw/jdwhale/JdwhaleApplication.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="408">
<caret line="197" column="18" selection-start-line="197" selection-start-column="18" selection-end-line="197" selection-end-column="18" />
<folding>
<element signature="e#11985#11986#0" expanded="true" />
<element signature="e#12016#12017#0" expanded="true" />
</folding>
<state relative-caret-position="242">
<caret line="16" column="57" selection-start-line="16" selection-start-column="57" selection-end-line="16" selection-end-column="57" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/applicationInfo/ApplicationInfo.java">
<entry file="file://$PROJECT_DIR$/spirit/src/main/resources/application.properties">
<provider selected="true" editor-type-id="text-editor" />
</entry>
<entry file="file://$PROJECT_DIR$/jdwhale/src/main/java/ai/qiwu/mqw/jdwhale/controller/DingDongController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="15" column="19" selection-start-line="15" selection-start-column="19" selection-end-line="15" selection-end-column="19" />
<state relative-caret-position="374">
<caret line="26" column="52" selection-start-line="26" selection-start-column="52" selection-end-line="26" selection-end-column="52" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../../../../java/jdk1.8.0_211/src.zip!/java/util/concurrent/ConcurrentHashMap.java">
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/XiaoduApplication.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="318">
<caret line="1097" column="5" lean-forward="true" selection-start-line="1097" selection-start-column="5" selection-end-line="1097" selection-end-column="5" />
<folding>
<element signature="e#48122#48123#0" expanded="true" />
<element signature="e#48173#48174#0" expanded="true" />
<element signature="e#65240#65241#0" expanded="true" />
<element signature="e#65287#65288#0" expanded="true" />
</folding>
<state relative-caret-position="308">
<caret line="19" lean-forward="true" selection-start-line="19" selection-end-line="19" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/DirectiveItem.java">
<entry file="file://$PROJECT_DIR$/spirit/src/main/java/ai/qiwu/tmall/spirit/SpiritApplication.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="15" column="27" selection-start-line="15" selection-start-column="27" selection-end-line="15" selection-end-column="27" />
<folding>
<element signature="imports" expanded="true" />
</folding>
<state relative-caret-position="242">
<caret line="16" column="56" lean-forward="true" selection-start-line="16" selection-start-column="56" selection-end-line="16" selection-end-column="56" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/directive/Directive.java">
<entry file="file://$PROJECT_DIR$/spirit/src/main/java/ai/qiwu/tmall/spirit/controller/SpiritController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="330">
<caret line="15" column="13" selection-start-line="15" selection-start-column="13" selection-end-line="15" selection-end-column="13" />
<state relative-caret-position="332">
<caret line="43" column="25" selection-start-line="43" selection-start-column="25" selection-end-line="43" selection-end-column="25" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/response/DingDongResponse.java">
<entry file="file://$PROJECT_DIR$/xiaoya/src/main/java/ai/qiwu/xiaoya/xiaoya/controller/XiaoYaController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="484">
<caret line="22" column="17" selection-start-line="22" selection-start-column="17" selection-end-line="22" selection-end-column="17" />
<state relative-caret-position="352">
<caret line="32" column="36" selection-start-line="32" selection-start-column="36" selection-end-line="32" selection-end-column="36" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#1120#1121#0" expanded="true" />
<element signature="e#1175#1176#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/LastResponseTimeAndAudio.java">
<entry file="file://$PROJECT_DIR$/dingdong/src/main/resources/logback.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="308">
<caret line="14" column="1" selection-start-line="14" selection-start-column="1" selection-end-line="14" selection-end-column="1" />
<folding>
<element signature="imports" expanded="true" />
</folding>
<state relative-caret-position="242">
<caret line="23" column="44" lean-forward="true" selection-start-line="23" selection-start-column="44" selection-end-line="23" selection-end-column="44" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/EntityAttribute.class">
<entry file="file://$PROJECT_DIR$/jdwhale/src/main/resources/logback.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="88">
<caret line="7" column="22" selection-start-line="7" selection-start-column="22" selection-end-line="7" selection-end-column="22" />
<state relative-caret-position="374">
<caret line="23" column="36" selection-start-line="23" selection-start-column="36" selection-end-line="23" selection-end-column="36" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/request/RequestBody.class">
<entry file="file://$PROJECT_DIR$/spirit/src/main/resources/logback.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="274">
<caret line="45" column="22" selection-start-line="45" selection-start-column="22" selection-end-line="45" selection-end-column="22" />
<state relative-caret-position="308">
<caret line="23" column="35" selection-start-line="23" selection-start-column="35" selection-end-line="23" selection-end-column="35" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/request/LaunchRequest.class">
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/resources/logback.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="198">
<caret line="14" column="42" lean-forward="true" selection-start-line="14" selection-start-column="42" selection-end-line="14" selection-end-column="42" />
<state relative-caret-position="506">
<caret line="23" column="35" lean-forward="true" selection-start-line="23" selection-start-column="35" selection-end-line="23" selection-end-column="35" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/Entity.class">
<entry file="file://$PROJECT_DIR$/jdwhale/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="638">
<caret line="48" lean-forward="true" selection-start-line="48" selection-end-line="48" />
<caret line="44" column="21" selection-start-line="44" selection-start-column="21" selection-end-line="44" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/Resource.class">
<entry file="file://$PROJECT_DIR$/spirit/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="110">
<caret line="8" column="17" selection-start-line="8" selection-start-column="17" selection-end-line="8" selection-end-column="17" />
<state relative-caret-position="594">
<caret line="100" column="57" selection-start-line="100" selection-start-column="57" selection-end-line="100" selection-end-column="57" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/model/request/DingDongRequest.java">
<entry file="file://$PROJECT_DIR$/xiaodu/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="396">
<caret line="18" column="13" selection-start-line="18" selection-start-column="13" selection-end-line="18" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
<state relative-caret-position="259">
<caret line="67" column="37" selection-start-line="67" selection-start-column="37" selection-end-line="67" selection-end-column="37" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/controller/DingDongController.java">
<entry file="file://$PROJECT_DIR$/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="403">
<caret line="37" lean-forward="true" selection-start-line="37" selection-end-line="37" />
<folding>
<element signature="imports" expanded="true" />
<element signature="e#958#959#0" expanded="true" />
<element signature="e#1016#1017#0" expanded="true" />
</folding>
<state relative-caret-position="198">
<caret line="9" column="35" selection-start-line="9" selection-start-column="35" selection-end-line="9" selection-end-column="35" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.11/httpcore-4.4.11.jar!/org/apache/http/HttpResponse.class">
<entry file="file://$PROJECT_DIR$/xiaoya/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="418">
<caret line="22" column="15" selection-start-line="22" selection-start-column="15" selection-end-line="22" selection-end-column="15" />
<state relative-caret-position="220">
<caret line="64" column="37" selection-start-line="64" selection-start-column="37" selection-end-line="64" selection-end-column="37" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.11/httpcore-4.4.11.jar!/org/apache/http/HttpEntity.class">
<entry file="file://$PROJECT_DIR$/xiaoya/src/main/resources/logback.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="132">
<caret line="11" column="17" selection-start-line="11" selection-start-column="17" selection-end-line="11" selection-end-column="17" />
<state relative-caret-position="-52">
<caret line="20" column="30" selection-start-line="20" selection-start-column="30" selection-end-line="20" selection-end-column="30" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.11/httpcore-4.4.11.jar!/org/apache/http/message/BasicHttpResponse.class">
<entry file="file://$PROJECT_DIR$/dingdong/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="242">
<caret line="22" column="29" selection-start-line="22" selection-start-column="23" selection-end-line="22" selection-end-column="29" />
<folding>
<element signature="e#2322#2323#0" expanded="true" />
<element signature="e#2356#2357#0" expanded="true" />
</folding>
<state relative-caret-position="330">
<caret line="51" column="20" lean-forward="true" selection-start-line="51" selection-start-column="20" selection-end-line="51" selection-end-column="20" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.11/httpcore-4.4.11.jar!/org/apache/http/util/EntityUtils.class">
<entry file="file://$PROJECT_DIR$/xiaoai/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="190">
<caret line="116" column="26" selection-start-line="116" selection-start-column="26" selection-end-line="116" selection-end-column="26" />
<state relative-caret-position="498">
<caret line="48" column="21" selection-start-line="48" selection-start-column="21" selection-end-line="48" selection-end-column="21" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/alibaba/fastjson/1.2.58/fastjson-1.2.58.jar!/com/alibaba/fastjson/JSON.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/session/Application.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="256">
<caret line="102" column="25" selection-start-line="102" selection-start-column="25" selection-end-line="102" selection-end-column="25" />
<state relative-caret-position="264">
<caret line="12" column="9" selection-start-line="12" selection-start-column="9" selection-end-line="12" selection-end-column="9" />
<folding>
<element signature="e#3866#3867#0" expanded="true" />
<element signature="e#3924#3925#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/OutputSpeech.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264">
<caret line="15" column="71" lean-forward="true" selection-start-line="15" selection-start-column="71" selection-end-line="15" selection-end-column="71" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/request/SessionEndedRequest.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/session/User.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-528">
<caret line="14" column="13" selection-start-line="14" selection-start-column="13" selection-end-line="14" selection-end-column="13" />
<state relative-caret-position="374">
<caret line="17" column="26" selection-start-line="17" selection-start-column="26" selection-end-line="17" selection-end-column="26" />
<folding>
<element signature="e#1328#1329#0" expanded="true" />
<element signature="e#1362#1363#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/common/Constants.java">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/session/Session.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="154">
<caret line="7" column="77" lean-forward="true" selection-start-line="7" selection-start-column="77" selection-end-line="7" selection-end-column="77" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/directive/AudioPlayerDirective.class">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="88">
<caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
<state relative-caret-position="308">
<caret line="14" column="9" selection-start-line="14" selection-start-column="9" selection-end-line="14" selection-end-column="9" />
<folding>
<element signature="e#343#344#0" expanded="true" />
<element signature="e#391#392#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/directive/audioplayer/AudioPlayerDirective.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/context/ClientAppInfo.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264">
<caret line="17" column="11" selection-start-line="17" selection-start-column="11" selection-end-line="17" selection-end-column="11" />
<state relative-caret-position="330">
<caret line="15" column="32" selection-start-line="15" selection-start-column="32" selection-end-line="15" selection-end-column="32" />
<folding>
<element signature="e#510#511#0" expanded="true" />
<element signature="e#561#562#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../../../../java/jdk1.8.0_211/jre/lib/ext/nashorn.jar!/jdk/nashorn/internal/objects/annotations/Getter.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/context/Context.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="14" column="18" selection-start-line="14" selection-start-column="18" selection-end-line="14" selection-end-column="18" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/pom.xml">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="616">
<caret line="49" column="19" lean-forward="true" selection-start-line="49" selection-start-column="19" selection-end-line="49" selection-end-column="19" />
<state relative-caret-position="396">
<caret line="18" column="41" selection-start-line="18" selection-start-column="41" selection-end-line="18" selection-end-column="41" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/xiaodu/pom.xml">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/innerRequest/EventProperty.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="455">
<caret line="48" column="21" selection-start-line="48" selection-start-column="21" selection-end-line="48" selection-end-column="21" />
<state relative-caret-position="330">
<caret line="15" column="31" selection-start-line="15" selection-start-column="31" selection-end-line="15" selection-end-column="31" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseServiceCompromise.java">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/innerRequest/slot/Slot.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="411">
<caret line="102" column="57" lean-forward="true" selection-start-line="102" selection-start-column="57" selection-end-line="102" selection-end-column="57" />
<state relative-caret-position="264">
<caret line="12" column="9" lean-forward="true" selection-start-line="12" selection-start-column="9" selection-end-line="12" selection-end-column="9" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/dingdong/src/main/java/ai/qiwu/dong/dingdong/service/ParseService.java">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/innerRequest/SlotInfo.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="450">
<caret line="169" column="57" selection-start-line="169" selection-start-column="57" selection-end-line="169" selection-end-column="57" />
<state relative-caret-position="352">
<caret line="16" column="13" selection-start-line="16" selection-start-column="13" selection-end-line="16" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$PROJECT_DIR$/../../../../java/jdk1.8.0_211/src.zip!/java/util/Objects.java">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/XiaoAiRequest.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="274">
<caret line="200" column="24" selection-start-line="200" selection-start-column="24" selection-end-line="200" selection-end-column="24" />
<state relative-caret-position="462">
<caret line="21" column="14" lean-forward="true" selection-start-line="21" selection-start-column="14" selection-end-line="21" selection-end-column="14" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Utils.java">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/XiaoAiResponse.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="418">
<caret line="19" column="41" lean-forward="true" selection-start-line="19" selection-start-column="41" selection-end-line="19" selection-end-column="41" />
<state relative-caret-position="440">
<caret line="20" column="16" selection-start-line="20" selection-start-column="16" selection-end-line="20" selection-end-column="16" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/model/Response.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/toSpeak/ToSpeak.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="198">
<caret line="15" column="20" lean-forward="true" selection-start-line="15" selection-start-column="20" selection-end-line="15" selection-end-column="20" />
<state relative-caret-position="286">
<caret line="13" column="13" selection-start-line="13" selection-start-column="13" selection-end-line="13" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/pojo/AudioUrlAndText.java">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/toDisplay/UITemplate/Item/Item.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="198">
<caret line="9" column="7" selection-start-line="9" selection-start-column="7" selection-end-line="9" selection-end-column="7" />
<state relative-caret-position="330">
<caret line="15" column="13" selection-start-line="15" selection-start-column="13" selection-end-line="15" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Constants.java">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/toDisplay/UITemplate/UITemplate.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="638">
<caret line="29" column="59" selection-start-line="29" selection-start-column="59" selection-end-line="29" selection-end-column="59" />
<state relative-caret-position="440">
<caret line="20" column="15" selection-start-line="20" selection-start-column="15" selection-end-line="20" selection-end-column="15" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/directive/Stream.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/toDisplay/ToDisplay.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="132">
<caret line="9" column="13" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
<state relative-caret-position="396">
<caret line="18" column="16" lean-forward="true" selection-start-line="18" selection-start-column="16" selection-end-line="18" selection-end-column="16" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/directive/AudioItem.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/directive/AudioItem/AudioStream.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="88">
<caret line="7" column="13" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
<state relative-caret-position="286">
<caret line="13" column="13" selection-start-line="13" selection-start-column="13" selection-end-line="13" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/directive/audioplayer/Play.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/directive/AudioItem/AudioItem.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="12" column="11" selection-start-line="12" selection-start-column="11" selection-end-line="12" selection-end-column="11" />
<state relative-caret-position="308">
<caret line="14" column="22" selection-start-line="14" selection-start-column="22" selection-end-line="14" selection-end-column="22" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/directive/audioplayer/AudioItem.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/directive/ttsItem/TTSItem.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264">
<caret line="15" column="11" selection-start-line="15" selection-start-column="11" selection-end-line="15" selection-end-column="11" />
<state relative-caret-position="286">
<caret line="13" column="13" selection-start-line="13" selection-start-column="13" selection-end-line="13" selection-end-column="13" />
<folding>
<element signature="e#1040#1041#0" expanded="true" />
<element signature="e#1074#1075#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/directive/audioplayer/Stream.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/directive/Directive.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1144">
<caret line="59" column="32" selection-start-line="59" selection-start-column="20" selection-end-line="59" selection-end-column="32" />
<state relative-caret-position="396">
<caret line="18" column="14" lean-forward="true" selection-start-line="18" selection-start-column="14" selection-end-line="18" selection-end-column="14" />
<folding>
<element signature="e#1517#1518#0" expanded="true" />
<element signature="e#1557#1558#0" expanded="true" />
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/directive/audioplayer/PlayerInfo.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/actionProperty/ActionProperty.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="274">
<caret line="28" column="37" lean-forward="true" selection-start-line="28" selection-start-column="37" selection-end-line="28" selection-end-column="37" />
<state relative-caret-position="330">
<caret line="15" column="13" selection-start-line="15" selection-start-column="13" selection-end-line="15" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/directive/audioplayer/Content.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/registerEvent/RegisterEvent.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="264">
<caret line="15" column="38" lean-forward="true" selection-start-line="15" selection-start-column="38" selection-end-line="15" selection-end-column="38" />
<state relative-caret-position="286">
<caret line="13" column="13" selection-start-line="13" selection-start-column="13" selection-end-line="13" selection-end-column="13" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/bot/AudioPlayer.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/response/innerResponse/Response.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="132">
<caret line="22" column="36" selection-start-line="22" selection-start-column="36" selection-end-line="22" selection-end-column="36" />
<state relative-caret-position="528">
<caret line="24" column="20" selection-start-line="24" selection-start-column="20" selection-end-line="24" selection-end-column="20" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/data/response/directive/Play.class">
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/common/Utils.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="176">
<caret line="12" column="11" selection-start-line="12" selection-start-column="11" selection-end-line="12" selection-end-column="11" />
<state relative-caret-position="638">
<caret line="33" column="1" lean-forward="true" selection-start-line="33" selection-start-column="1" selection-end-line="33" selection-end-column="1" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/RequestTerminal.java">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/commons/Utils.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="865">
<caret line="57" column="51" lean-forward="true" selection-start-line="57" selection-start-column="51" selection-end-line="57" selection-end-column="51" />
<state relative-caret-position="357">
<caret line="20" column="52" lean-forward="true" selection-start-line="20" selection-start-column="52" selection-end-line="20" selection-end-column="52" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/service/ResponseEncapsulation.java">
<entry file="file://$PROJECT_DIR$/spirit/src/main/java/ai/qiwu/tmall/spirit/service/SpiritService.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-1019">
<caret line="27" column="3" lean-forward="true" selection-start-line="27" selection-start-column="3" selection-end-line="27" selection-end-column="3" />
<folding>
<element signature="imports" expanded="true" />
</folding>
<state relative-caret-position="1364">
<caret line="102" column="13" lean-forward="true" selection-start-line="102" selection-start-column="13" selection-end-line="102" selection-end-column="13" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/xiaodu/src/main/java/ai/qiwu/baidu/xiaodu/controller/XiaoDuController.java">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/model/request/innerRequest/Request.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="491">
<caret line="26" column="27" selection-start-line="26" selection-start-column="27" selection-end-line="26" selection-end-column="27" />
<state relative-caret-position="374">
<caret line="17" column="19" selection-start-line="17" selection-start-column="19" selection-end-line="17" selection-end-column="19" />
<folding>
<element signature="imports" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/org/apache/tomcat/embed/tomcat-embed-core/9.0.21/tomcat-embed-core-9.0.21.jar!/javax/servlet/ServletRequest.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/commons/XiaoAiConstants.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="274">
<caret line="29" column="23" selection-start-line="29" selection-start-column="23" selection-end-line="29" selection-end-column="23" />
<state relative-caret-position="440">
<caret line="20" column="48" selection-start-line="20" selection-start-column="48" selection-end-line="20" selection-end-column="48" />
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/bot/BaseBot.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/service/XiaoAiService.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="58">
<caret line="321" column="16" selection-start-line="321" selection-start-column="16" selection-end-line="321" selection-end-column="16" />
<state relative-caret-position="533">
<caret line="49" column="9" lean-forward="true" selection-start-line="49" selection-start-column="9" selection-end-line="49" selection-end-column="9" />
<folding>
<element signature="e#11937#11938#0" expanded="true" />
<element signature="e#11983#11984#0" expanded="true" />
<element signature="e#12017#12018#0" expanded="true" />
<element signature="e#12062#12063#0" expanded="true" />
<element signature="imports" expanded="true" />
<element signature="e#5505#5506#0" expanded="true" />
<element signature="e#5564#5565#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="jar://$MAVEN_REPOSITORY$/com/baidu/dueros/bot-sdk/1.1.9/bot-sdk-1.1.9.jar!/com/baidu/dueros/certificate/Certificate.class">
<entry file="file://$PROJECT_DIR$/xiaoai/src/main/java/ai/qiwu/mi/xiaoai/controller/XiaoAiController.java">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="272">
<caret line="89" column="52" lean-forward="true" selection-start-line="89" selection-start-column="52" selection-end-line="89" selection-end-column="52" />
<folding>
<element signature="e#4481#4482#0" expanded="true" />
<element signature="e#4525#4526#0" expanded="true" />
</folding>
<state relative-caret-position="132">
<caret line="6" column="29" selection-start-line="6" selection-start-column="29" selection-end-line="6" selection-end-column="29" />
</state>
</provider>
</entry>
</component>
<component name="masterDetails">
<states>
<state key="ArtifactsStructureConfigurable.UI">
<settings>
<artifact-editor />
<last-edited>RokidBox:war</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
<option value="0.5" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="FacetStructureConfigurable.UI">
<settings>
<last-edited>Spring</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.254023" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="GlobalLibrariesConfigurable.UI">
<settings>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.254023" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="JdkListConfigurable.UI">
<settings>
<last-edited>1.8</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.2" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ModuleStructureConfigurable.UI">
<settings>
<last-edited>RokidBox</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.254023" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
<state key="ProjectJDKs.UI">
<settings>
<last-edited>1.8</last-edited>
......@@ -853,6 +1080,18 @@
</splitter-proportions>
</settings>
</state>
<state key="ProjectLibrariesConfigurable.UI">
<settings>
<last-edited>Maven: aopalliance:aopalliance:1.0</last-edited>
<splitter-proportions>
<option name="proportions">
<list>
<option value="0.254023" />
</list>
</option>
</splitter-proportions>
</settings>
</state>
</states>
</component>
</project>
\ No newline at end of file
......@@ -11,6 +11,7 @@
<groupId>ai.qiwu.dong</groupId>
<artifactId>dingdong</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>dingdong</name>
<description>Demo project for Spring Boot</description>
......@@ -22,6 +23,19 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--添加servlet-api的依赖,用来打war包 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
......@@ -50,6 +64,7 @@
</dependencies>
<build>
<finalName>dingdong</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
......
......@@ -2,12 +2,18 @@ package ai.qiwu.dong.dingdong;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class DingdongApplication {
public class DingdongApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(DingdongApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(DingdongApplication.class);
}
}
......@@ -27,6 +27,7 @@ public interface Constants {
String RECOMMEND = "recommend";
String START_BY_ANSWER = "startByAnswer";
String END_BY_END = "endByEnd";
String ALL = "all";
}
interface Status {
......
package ai.qiwu.dong.dingdong.common;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-7-2 下午2:22
*/
@Getter
@Setter
public class Holder {
private volatile String word;
private volatile String lastAudioUrl;
}
......@@ -18,16 +18,16 @@ public class DingDongController {
private static final Logger logger = LoggerFactory.getLogger(ParseService.class);
// @Autowired
// private ParseServiceCompromise compromise;
@Autowired
private ParseService parseService;
private ParseServiceCompromise compromise;
// @Autowired
// private ParseService parseService;
@RequestMapping("/ding")
public @ResponseBody DingDongResponse dingdong(@RequestBody DingDongRequest request) {
logger.info("Request params : "+ request);
return parseService.getResponse(request);
return compromise.getResponse(request);
}
@RequestMapping("/ding/callback")
......
......@@ -3,6 +3,7 @@ package ai.qiwu.dong.dingdong.service;
import ai.qiwu.dong.dingdong.common.Constants;
import ai.qiwu.dong.dingdong.common.Constants.Intent;
import ai.qiwu.dong.dingdong.common.Constants.Status;
import ai.qiwu.dong.dingdong.common.Holder;
import ai.qiwu.dong.dingdong.model.request.DingDongRequest;
import ai.qiwu.dong.dingdong.model.request.user.User;
import ai.qiwu.dong.dingdong.model.response.DingDongResponse;
......@@ -23,6 +24,7 @@ import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author 苗权威
......@@ -33,6 +35,8 @@ public class ParseServiceCompromise {
private final static Logger logger = LoggerFactory.getLogger(ParseServiceCompromise.class);
private final static ConcurrentHashMap<String, Holder> USER_LAST_ALL_WORD_AudioUrl = new ConcurrentHashMap<>();
public DingDongResponse getResponse(DingDongRequest request) {
String userId = null;
User user = request.getUser();
......@@ -127,10 +131,11 @@ public class ParseServiceCompromise {
}
switch (intentKey) {
case Intent.END_BY_END : return parseWordInItsIntent(request, false, true, userId);
case Intent.XIAO_WU : return parseWordInItsIntent(request, true, true, userId);
case Intent.END_BY_END : return parseWordInItsIntent(request, false, true, userId);
case Intent.XIAO_WU : return parseWordInItsIntent(request, true, true, userId);
case Intent.START_BY_ANSWER : return parseWordInItsIntent(request, true, true, userId);
case Intent.RECOMMEND : return parseWordInItsIntent(request, false, false, userId);
case Intent.RECOMMEND : return parseWordInItsIntent(request, true, false, userId);
case Intent.ALL : return parseWordInItsIntent(request, false, false, userId);
default: {
logger.info("没有匹配到任何已有意图,本次请求的意图名:"+intentKey);
return buildErrorResponse(request, userId);
......@@ -141,14 +146,17 @@ public class ParseServiceCompromise {
else if (slots.size() <= 1) {
logger.info("slots不为null,但是没有映射到任何意图");
return buildErrorResponse(request, userId);
} else if (slots.size() == 3 && slots.containsKey(Intent.RECOMMEND)) {
return requestQiWuInterface(userId, request);
} else {
logger.info("Intent请求slots大小>=3,预料之外");
logger.info("Intent请求slots大小>3,或是等于3但是没有recommend意图,预料之外");
return buildErrorResponse(request, userId);
}
}
private DingDongResponse parseWordInItsIntent(DingDongRequest request, boolean font, boolean needToCut, String userId) {
String word = request.getInput_text();
Holder holder = USER_LAST_ALL_WORD_AudioUrl.get(userId);
DingDongResponse response;
if (needToCut) {
if (font) {
......@@ -171,8 +179,40 @@ public class ParseServiceCompromise {
}
}
}
// 处理ALL意图
else if (!font) {
if (holder != null && word.equals(holder.getWord())) {
logger.info("本次ALL意图的话语与上次相同,认定是用户说的话");
} else {
if (holder == null) {
holder = new Holder();
USER_LAST_ALL_WORD_AudioUrl.put(userId, holder);
}
holder.setWord(word);
DingDongResponse forbidResponse;
if (holder.getLastAudioUrl() != null) {
logger.info("本次ALL意图的话语与上次不同,重复播放上次音频");
forbidResponse = buildResponse(request, userId);
forbidResponse.getDirective().getDirective_items().get(0).setContent(holder.getLastAudioUrl());
} else {
logger.info("本次ALL意图的话语与上次不同,提醒用户再说一遍");
forbidResponse = buildErrorResponse(request, userId);
}
return forbidResponse;
}
}
logger.info("此次解析得到的用户的话是:"+word);
response = requestQiWuInterface(userId, request);
String audioUrl = response.getDirective().getDirective_items().get(0).getContent();
if (holder == null) {
holder = new Holder();
holder.setLastAudioUrl(audioUrl);
USER_LAST_ALL_WORD_AudioUrl.put(userId, holder);
} else {
holder.setLastAudioUrl(audioUrl);
}
return response;
}
......@@ -210,11 +250,6 @@ public class ParseServiceCompromise {
}
private DingDongResponse dealLaunchIntent(DingDongRequest request, String userId) {
Map<String, String> slots = request.getSlots();
if (slots.containsKey(Intent.RECOMMEND)) {
request.setInput_text("推荐作品");
return requestQiWuInterface(userId, request);
}
DingDongResponse launchResponse = buildErrorResponse(request, userId);
launchResponse.getDirective().getDirective_items().get(0).setContent("欢迎,这里有海量的作品,希望您玩的开心");
return launchResponse;
......@@ -230,6 +265,8 @@ public class ParseServiceCompromise {
case Constants.DEV_SERVICE_RESP_PACK_ERROR: logger.info("status为NOTICE:开发者服务回包数据错误");break;
case Constants.NOTICE_OPEN_PLATFORM_ERROR: logger.info("status为NOTICE:开放平台系统异常");break;
}
if (USER_LAST_ALL_WORD_AudioUrl.remove(userId) != null) logger.info("非正常结束,平台发出NOTICE信息,在此处删除缓存成功");
return buildErrorResponse(request, userId);
}
......@@ -248,6 +285,8 @@ public class ParseServiceCompromise {
}
DingDongResponse response = buildErrorResponse(request, userId);
response.getDirective().getDirective_items().get(0).setContent("我们的作品库在不断扩充,欢迎下次再来玩");
if (USER_LAST_ALL_WORD_AudioUrl.remove(userId) != null) logger.info("平台发出END信息,代表技能退出,在此处删除缓存成功");
return response;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--控制台日志输出配置-->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!--对输出日志进行格式化-->
<encoder>
<!-- %d日期,%p日志级别,%file文件名,%line所在行数,%m输出的信息,%n换行 -->
<pattern>%d %p (%file:%line\)- %m%n</pattern>
<!--字符编码-->
<charset>UTF-8</charset><!--此处设置字符集-->
</encoder>
</appender>
<!--指定日志输出等级-->
<root level="info">
<appender-ref ref="STDOUT" />
</root>
<!--上述配置表名将 >=info级别的日志都输出到控制台-->
<!--日志文件配置-->
<appender name="dingdongLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--被写入的文件名,可以是相对目录,也可以是绝对目录,如果上级目录不存在会自动创建,没有默认值。-->
<File>/usr/mqw/logs/dingdong/</File>
<!--滚动记录文件:根据时间来制定滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/usr/mqw/logs/dingdong/base.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="qi.qiwu.dingdong" level="DEBUG">
<appender-ref ref="dingdongLog" />
</logger>
</configuration>
\ No newline at end of file
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Properties;
public class MavenWrapperDownloader {
/**
* Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided.
*/
private static final String DEFAULT_DOWNLOAD_URL =
"https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar";
/**
* Path to the maven-wrapper.properties file, which might contain a downloadUrl property to
* use instead of the default one.
*/
private static final String MAVEN_WRAPPER_PROPERTIES_PATH =
".mvn/wrapper/maven-wrapper.properties";
/**
* Path where the maven-wrapper.jar will be saved to.
*/
private static final String MAVEN_WRAPPER_JAR_PATH =
".mvn/wrapper/maven-wrapper.jar";
/**
* Name of the property which should be used to override the default download url for the wrapper.
*/
private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl";
public static void main(String args[]) {
System.out.println("- Downloader started");
File baseDirectory = new File(args[0]);
System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath());
// If the maven-wrapper.properties exists, read it and check if it contains a custom
// wrapperUrl parameter.
File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH);
String url = DEFAULT_DOWNLOAD_URL;
if (mavenWrapperPropertyFile.exists()) {
FileInputStream mavenWrapperPropertyFileInputStream = null;
try {
mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile);
Properties mavenWrapperProperties = new Properties();
mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream);
url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url);
} catch (IOException e) {
System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'");
} finally {
try {
if (mavenWrapperPropertyFileInputStream != null) {
mavenWrapperPropertyFileInputStream.close();
}
} catch (IOException e) {
// Ignore ...
}
}
}
System.out.println("- Downloading from: : " + url);
File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH);
if (!outputFile.getParentFile().exists()) {
if (!outputFile.getParentFile().mkdirs()) {
System.out.println(
"- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'");
}
}
System.out.println("- Downloading to: " + outputFile.getAbsolutePath());
try {
downloadFileFromURL(url, outputFile);
System.out.println("Done");
System.exit(0);
} catch (Throwable e) {
System.out.println("- Error downloading");
e.printStackTrace();
System.exit(1);
}
}
private static void downloadFileFromURL(String urlString, File destination) throws Exception {
URL website = new URL(urlString);
ReadableByteChannel rbc;
rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
fos.close();
rbc.close();
}
}
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven2 Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
# TODO classpath?
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`which java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
wget "$jarUrl" -O "$wrapperJarPath"
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
curl -o "$wrapperJarPath" "$jarUrl"
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven2 Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat"
if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd"
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"
FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
echo Found %WRAPPER_JAR%
) else (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"
echo Finished downloading %WRAPPER_JAR%
)
@REM End of extension
%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat"
if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%" == "on" pause
if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE%
exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>ai.qiwu.mqw</groupId>
<artifactId>jdwhale</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>jdwhale</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!--添加servlet-api的依赖,用来打war包 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.8</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>JDWhale</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
package ai.qiwu.mqw.jdwhale;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class JdwhaleApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(JdwhaleApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(JdwhaleApplication.class);
}
}
package ai.qiwu.mqw.jdwhale.common;
/**
* @author 苗权威
* @dateTime 19-6-25 下午5:57
*/
public interface Constants {
String QI_WU_INTERFACE = "http://aliyun-hz1.chewrobot.com:8070/api/chat";
String SERVICE_NAME = "DINGDONG";
String CANCEL_INTENT = "Alpha.CancelIntent";
String HELP_INTENT = "Alpha.HelpIntent";
}
package ai.qiwu.mqw.jdwhale.common;
import java.util.concurrent.locks.ReentrantLock;
/**
* @author 苗权威
* @dateTime 19-6-26 下午2:59
*/
public class MqwLru<K, V> {
private static final int DEFAULT_SINGLE_SEGMENT_ENTRYS = 100;
private static final float DEFAULT_LOAD_FACTOR = 0.75f;
private static final int DEFAULT_SEGMENT_ARRAY_LENGTH = 16;
private static final int MAXIMUM_CAPACITY = 1 << 30;
private static final int MAX_SEGMENT_ARRAY_LENGTH = 1 << 16;
final Segment[] segments;
public MqwLru(int arrCapacity, int loadFactor, int segementCapacity) {
int arrayLength = tableSizeFor(arrCapacity);
this.segments = new Segment[arrayLength];
for (int i = 0; i < arrayLength; i++) {
segments[i] = new Segment(segementCapacity, loadFactor);
}
}
private static int tableSizeFor(int cap) {
int n = cap - 1;
n |= n >>> 1;
n |= n >>> 2;
n |= n >>> 4;
n |= n >>> 8;
n |= n >>> 16;
return (n < 0) ? 1 : (n >= MAXIMUM_CAPACITY) ? MAXIMUM_CAPACITY : n + 1;
}
private static int hash(int h) {
h += (h << 15) ^ 0xffffcd7d;
h ^= (h >>> 10);
h += (h << 3);
h ^= (h >>> 6);
h += (h << 2) + (h << 14);
return h ^ (h >>> 16);
}
static final class Entry<K,V> {
final K key;
volatile V value;
final int hash;
Entry<K,V> doubleLinkedBefore;
Entry<K,V> doubleLinkedAfter;
Entry(K key, V value, int hash) {
this.key = key;
this.value = value;
this.hash = hash;
}
}
static final class Segment<K, V> extends ReentrantLock {
volatile int count;
int threshold;
final float loadFactor;
final int maxCapacity;
volatile Entry<K,V> header;
volatile Entry<K,V> tail;
Segment(int segmentCapacity, float loadFactor) {
this.maxCapacity = segmentCapacity;
this.loadFactor = loadFactor;
this.threshold = (int) (maxCapacity*loadFactor);
}
V put(K key, V value, int hash) {
lock();
try {
int c = count;
//if (c++ >= threshold) rehash();
} finally {
unlock();
}
return null;
}
}
}
package ai.qiwu.mqw.jdwhale.controller;
import ai.qiwu.mqw.jdwhale.model.RequestModel.DingDongRequest;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.DingDongResponse;
import ai.qiwu.mqw.jdwhale.service.ParseServiceWithoutLRU;
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;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:51
*/
@RestController
public class DingDongController {
private static final Logger logger = LoggerFactory.getLogger(DingDongController.class);
@Autowired
private ParseServiceWithoutLRU serviceWithoutLRU;
@RequestMapping("/dingdong")
public @ResponseBody
DingDongResponse dingdong(@RequestBody DingDongRequest request) {
logger.info("Request params: "+request);
return serviceWithoutLRU.getResponse(request);
}
}
package ai.qiwu.mqw.jdwhale.model.RequestModel;
import ai.qiwu.mqw.jdwhale.model.RequestModel.request.TripleRequest;
import ai.qiwu.mqw.jdwhale.model.RequestModel.session.DingDongSession;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:30
*/
@Getter
@Setter
@ToString
public class DingDongRequest {
private String version;
private DingDongSession session;
private TripleRequest request;
}
package ai.qiwu.mqw.jdwhale.model.RequestModel.request;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Map;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:45
*/
@Getter
@Setter
@ToString
public class IntentRequestIntent {
private String name;
private String confirmResult;
private Map<String, IntentRequestSlot> map;
}
package ai.qiwu.mqw.jdwhale.model.RequestModel.request;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:46
*/
@Getter
@Setter
public class IntentRequestSlot {
private String name;
private String value;
private boolean matched;
private String confirmResult;
}
package ai.qiwu.mqw.jdwhale.model.RequestModel.request;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:49
*/
@Getter
@Setter
@ToString
public class SessionEndRequestReason {
private String type;
private String message;
}
package ai.qiwu.mqw.jdwhale.model.RequestModel.request;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:43
*/
@Getter
@Setter
@ToString
public class TripleRequest {
private String type;
private String requestId;
private Long timestamp;
private String dialogState;
private IntentRequestIntent intent;
private String original;
private SessionEndRequestReason reason;
}
package ai.qiwu.mqw.jdwhale.model.RequestModel.session;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:31
*/
@Getter
@Setter
@ToString
public class DingDongSession {
private boolean isNew;
private String sessionId;
private Object contexts;
private SessionApp application;
private SessionUser user;
private SessionDevice device;
}
package ai.qiwu.mqw.jdwhale.model.RequestModel.session;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:33
*/
@Getter
@Setter
@ToString
public class SessionApp {
private String applicationId;
}
package ai.qiwu.mqw.jdwhale.model.RequestModel.session;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:36
*/
@Getter
@Setter
@ToString
public class SessionDevice {
private String deviceId;
}
package ai.qiwu.mqw.jdwhale.model.RequestModel.session;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:34
*/
@Getter
@Setter
@ToString
public class SessionUser {
private String userId;
private String accessToken;
}
package ai.qiwu.mqw.jdwhale.model.ResponseModel;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.directives.audio.AudioPlayerDirective;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.response.OutputResponse;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Map;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:52
*/
@Getter
@Setter
public class DingDongResponse {
private String version;
private boolean shouldEndSession;
private Map<String, String> contexts;
private OutputResponse response;
private List<AudioPlayerDirective> directives;
}
package ai.qiwu.mqw.jdwhale.model.ResponseModel.directives.audio;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 下午5:08
*/
@Getter
@Setter
public class AudioPlayerDirective {
private String type;
private String playBehavior;
private AudioStream audioStream;
}
package ai.qiwu.mqw.jdwhale.model.ResponseModel.directives.audio;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 下午5:10
*/
@Getter
@Setter
public class AudioStream {
private String name;
private String url;
private String token;
private Long offsetInMilliseconds;
}
package ai.qiwu.mqw.jdwhale.model.ResponseModel.response;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:58
*/
@Getter
@Setter
public class Output {
private String type;
private String text;
}
package ai.qiwu.mqw.jdwhale.model.ResponseModel.response;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:57
*/
@Getter
@Setter
public class OutputResponse {
private Output output;
private Reprompt reprompt;
}
package ai.qiwu.mqw.jdwhale.model.ResponseModel.response;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 下午4:59
*/
@Getter
@Setter
public class Reprompt {
private String type;
private String text;
}
package ai.qiwu.mqw.jdwhale.service;
import ai.qiwu.mqw.jdwhale.common.Constants;
import ai.qiwu.mqw.jdwhale.model.RequestModel.DingDongRequest;
import ai.qiwu.mqw.jdwhale.model.RequestModel.request.TripleRequest;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.DingDongResponse;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.directives.audio.AudioPlayerDirective;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.directives.audio.AudioStream;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.response.Output;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.response.OutputResponse;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.response.Reprompt;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
/**
* @author 苗权威
* @dateTime 19-6-25 下午5:13
*/
@Service("service")
public class ParseService {
private static final Logger logger = LoggerFactory.getLogger(ParseService.class);
private static final ConcurrentHashMap<String, DingDongResponse> userResponseMap = new ConcurrentHashMap<>();
public DingDongResponse getResponse(DingDongRequest request) {
String userId = request.getSession().getUser().getUserId();
if (userId == null) userId = request.getSession().getApplication().getApplicationId();
TripleRequest unknowRequest = request.getRequest();
switch (unknowRequest.getType()) {
case "LaunchRequest": return dealLaunchRequest();
case "IntentRequest": return dealIntentRequest(unknowRequest, userId);
case "SessionEndedRequest": dealSessionEndedRequest(unknowRequest, userId); return null;
default: logger.info("ERROR DIRECTIVE"); return dealLaunchRequest();
}
}
private DingDongResponse dealLaunchRequest() {
DingDongResponse response = new DingDongResponse();
buildResponse(response);
response.getResponse().getOutput().setText("欢迎来到有声互动小说,请说推荐作品");
response.getResponse().getReprompt().setText("请说推荐作品");
return response;
}
private DingDongResponse dealIntentRequest(TripleRequest request, String userId) {
// 处理Alpha.CancelIntent意图,该意图是平台默认的意图,用户说退出则退出技能,
// 我们这里需要对该意图进行判断处理.
// "request": {
// "dialogState": "STARTED",
// "intent": {
// "name": "Alpha.CancelIntent"
// },
// "requestId": "42d7d9f2-4134-4979-82fc-44dafe408171_6006_test",
// "timestamp": 1561510754347,
// "type": "IntentRequest"
// },
if (Constants.CANCEL_INTENT.equals(request.getIntent().getName())) {
dealSessionEndedRequest(request, userId);
return null;
}
if (Constants.HELP_INTENT.equals(request.getIntent().getName())) {
DingDongResponse response = new DingDongResponse();
buildResponse(response);
response.getResponse().setReprompt(null);
response.getResponse().getOutput().setText("请明确一些说帮或不帮");
return response;
}
DingDongResponse response = userResponseMap.get(userId);
if (response == null) {
response = buildResponseTemplate();
userResponseMap.put(userId, response);
}
String userWord = request.getOriginal();
requestQiWuInterface(userId, userWord, response);
return response;
}
private void dealSessionEndedRequest(TripleRequest request, String userId) {
DingDongResponse response = userResponseMap.remove(userId);
logger.info("用户:"+userId+" 的缓存删除成功, " + response);
}
private void requestQiWuInterface(String userId, String userWord, DingDongResponse response) {
String audioUrl = "";
String textContent = "请说推荐作品";
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(Constants.QI_WU_INTERFACE);
HashMap<String, String> params = new HashMap<>();
params.put("user_id", String.valueOf(userId));
params.put("text", userWord);
params.put("access",Constants.SERVICE_NAME);
String paramsJsonFormat = JSON.toJSONString(params);
StringEntity body = new StringEntity(paramsJsonFormat, "UTF-8");
post.setHeader("Content-Type", "application/json;charset=utf-8");
post.setEntity(body);
httpResponse = httpClient.execute(post);
HttpEntity responseBody = httpResponse.getEntity();
if (responseBody != null) {
String responseContent = EntityUtils.toString(responseBody);
logger.info("齐悟接口返回: "+ responseContent);
JSONObject responseJsonFormat = JSONObject.parseObject(responseContent);
audioUrl = (String) responseJsonFormat.get("audio");
textContent = (String) responseJsonFormat.get("text");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (httpClient != null) httpClient.close();
if (httpResponse != null) httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
addUrlAndTextToResponse(audioUrl, textContent, response);
}
private void addUrlAndTextToResponse(String url, String text, DingDongResponse response) {
//response.getResponse().getOutput().setText(text);
response.getDirectives().get(0).getAudioStream().setUrl(url);
}
private DingDongResponse buildResponseTemplate() {
DingDongResponse response = new DingDongResponse();
response.setVersion("1.0");
response.setShouldEndSession(true);
buildDirectives(response);
return response;
}
private void buildResponse(DingDongResponse response) {
response.setShouldEndSession(true);
response.setVersion("1.0");
OutputResponse outResponse = new OutputResponse();
Output output = new Output();
output.setType("PlainText");
outResponse.setOutput(output);
Reprompt reprompt = new Reprompt();
reprompt.setType("PlainText");
reprompt.setText("哈哈,是不是后悔刚才的选择了,下次可要好好考虑考虑哦");
outResponse.setReprompt(reprompt);
response.setResponse(outResponse);
}
private void buildDirectives(DingDongResponse response) {
AudioPlayerDirective audioDirective = new AudioPlayerDirective();
audioDirective.setType("AudioPlayer.Play");
audioDirective.setPlayBehavior("REPLACE_ALL");
AudioStream audioStream = new AudioStream();
audioStream.setToken("654987123");
audioDirective.setAudioStream(audioStream);
List<AudioPlayerDirective> directives = new ArrayList<>();
directives.add(audioDirective);
response.setDirectives(directives);
}
}
package ai.qiwu.mqw.jdwhale.service;
import ai.qiwu.mqw.jdwhale.common.Constants;
import ai.qiwu.mqw.jdwhale.model.RequestModel.DingDongRequest;
import ai.qiwu.mqw.jdwhale.model.RequestModel.request.TripleRequest;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.DingDongResponse;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.directives.audio.AudioPlayerDirective;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.directives.audio.AudioStream;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.response.Output;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.response.OutputResponse;
import ai.qiwu.mqw.jdwhale.model.ResponseModel.response.Reprompt;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-6-26 下午4:09
*/
@Service("serviceWithoutLRU")
public class ParseServiceWithoutLRU {
private static final Logger logger = LoggerFactory.getLogger(ParseService.class);
public DingDongResponse getResponse(DingDongRequest request) {
String userId = request.getSession().getUser().getUserId();
if (userId == null) userId = request.getSession().getApplication().getApplicationId();
TripleRequest unknowRequest = request.getRequest();
switch (unknowRequest.getType()) {
case "LaunchRequest": return dealLaunchRequest();
case "IntentRequest": return dealIntentRequest(unknowRequest, userId);
case "SessionEndedRequest": dealSessionEndedRequest(userId); return null;
default: logger.info("ERROR DIRECTIVE"); return dealLaunchRequest();
}
}
private DingDongResponse dealLaunchRequest() {
DingDongResponse response = new DingDongResponse();
buildResponse(response);
response.getResponse().getOutput().setText("欢迎来到有声互动小说,请说推荐作品");
response.getResponse().getReprompt().setText("请说推荐作品");
return response;
}
private DingDongResponse dealIntentRequest(TripleRequest request, String userId) {
// 处理Alpha.CancelIntent意图,该意图是平台默认的意图,用户说退出则退出技能,
// 我们这里需要对该意图进行判断处理.
// "request": {
// "dialogState": "STARTED",
// "intent": {
// "name": "Alpha.CancelIntent"
// },
// "requestId": "42d7d9f2-4134-4979-82fc-44dafe408171_6006_test",
// "timestamp": 1561510754347,
// "type": "IntentRequest"
// },
if (Constants.CANCEL_INTENT.equals(request.getIntent().getName())) {
dealSessionEndedRequest(userId);
return null;
}
if (Constants.HELP_INTENT.equals(request.getIntent().getName())) {
DingDongResponse response = new DingDongResponse();
buildResponse(response);
response.getResponse().setReprompt(null);
response.getResponse().getOutput().setText("请明确一些说帮或不帮");
return response;
}
DingDongResponse response = buildResponseInTTS();
String userWord = request.getOriginal();
requestQiWuInterface(userId, userWord, response);
return response;
}
private void dealSessionEndedRequest(String userId) {
logger.info("用户 "+userId+" 会话结束");
}
private void requestQiWuInterface(String userId, String userWord, DingDongResponse response) {
String audioUrl = "";
String textContent = "请说推荐作品";
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(Constants.QI_WU_INTERFACE);
HashMap<String, String> params = new HashMap<>();
params.put("user_id", String.valueOf(userId));
params.put("text", userWord);
params.put("access",Constants.SERVICE_NAME);
String paramsJsonFormat = JSON.toJSONString(params);
StringEntity body = new StringEntity(paramsJsonFormat, "UTF-8");
post.setHeader("Content-Type", "application/json;charset=utf-8");
post.setEntity(body);
httpResponse = httpClient.execute(post);
HttpEntity responseBody = httpResponse.getEntity();
if (responseBody != null) {
String responseContent = EntityUtils.toString(responseBody);
logger.info("齐悟接口返回: "+ responseContent);
JSONObject responseJsonFormat = JSONObject.parseObject(responseContent);
audioUrl = (String) responseJsonFormat.get("audio");
textContent = (String) responseJsonFormat.get("text");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (httpClient != null) httpClient.close();
if (httpResponse != null) httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
addUrlAndTextToResponse(audioUrl, textContent, response);
}
private void addUrlAndTextToResponse(String url, String text, DingDongResponse response) {
response.getResponse().getOutput().setText(text);
response.getDirectives().get(0).getAudioStream().setUrl(url);
}
/**
* 语音指令调用该方法生成Response
* @return
*/
private DingDongResponse buildResponseInDirective() {
DingDongResponse response = new DingDongResponse();
response.setVersion("1.0");
response.setShouldEndSession(true);
buildDirectives(response);
return response;
}
/**
* TTS模式
* @return
*/
private DingDongResponse buildResponseInTTS() {
DingDongResponse response = new DingDongResponse();
buildResponse(response);
buildDirectives(response);
return response;
}
private void buildResponse(DingDongResponse response) {
response.setShouldEndSession(false);
response.setVersion("1.0");
OutputResponse outResponse = new OutputResponse();
Output output = new Output();
output.setType("PlainText");
outResponse.setOutput(output);
Reprompt reprompt = new Reprompt();
reprompt.setType("PlainText");
reprompt.setText("哈哈,是不是后悔刚才的选择了,下次可要好好考虑考虑哦");
outResponse.setReprompt(reprompt);
response.setResponse(outResponse);
}
private void buildDirectives(DingDongResponse response) {
AudioPlayerDirective audioDirective = new AudioPlayerDirective();
audioDirective.setType("AudioPlayer.Play");
audioDirective.setPlayBehavior("REPLACE_ALL");
AudioStream audioStream = new AudioStream();
audioStream.setToken("654987123");
audioDirective.setAudioStream(audioStream);
List<AudioPlayerDirective> directives = new ArrayList<>();
directives.add(audioDirective);
response.setDirectives(directives);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--控制台日志输出配置-->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!--对输出日志进行格式化-->
<encoder>
<!-- %d日期,%p日志级别,%file文件名,%line所在行数,%m输出的信息,%n换行 -->
<pattern>%d %p (%file:%line\)- %m%n</pattern>
<!--字符编码-->
<charset>UTF-8</charset><!--此处设置字符集-->
</encoder>
</appender>
<!--指定日志输出等级-->
<root level="info">
<appender-ref ref="STDOUT" />
</root>
<!--上述配置表名将 >=info级别的日志都输出到控制台-->
<!--日志文件配置-->
<appender name="whaleLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--被写入的文件名,可以是相对目录,也可以是绝对目录,如果上级目录不存在会自动创建,没有默认值。-->
<File>/usr/mqw/logs/jdWhale/</File>
<!--滚动记录文件:根据时间来制定滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/usr/mqw/logs/jdWhale/base.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="qi.qiwu.mqw" level="DEBUG">
<appender-ref ref="whaleLog" />
</logger>
</configuration>
\ No newline at end of file
package ai.qiwu.mqw.jdwhale;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class JdwhaleApplicationTests {
@Test
public void contextLoads() {
}
}
......@@ -6,6 +6,7 @@
<groupId>ai.qiwu</groupId>
<artifactId>smartbox</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
......
......@@ -16,6 +16,16 @@
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<file.encoding>UTF-8</file.encoding>
<maven.test.skip>true</maven.test.skip>
<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
<!-- dependency version -->
<commons_lang_version>2.6</commons_lang_version>
<codehaus_jackson_version>1.9.13</codehaus_jackson_version>
<google_code_gson_version>2.8.5</google_code_gson_version>
</properties>
<dependencies>
......@@ -29,6 +39,35 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Commons -->
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>${commons_lang_version}</version>
</dependency>
<!-- Json Parse -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${google_code_gson_version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.8</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
</dependencies>
<build>
......
package ai.qiwu.rokid.ruoqi.common;
/**
* @author 苗权威
* @dateTime 19-7-2 下午7:36
*/
public interface Constants {
String QI_WU_INTERFACE = "http://aliyun-hz1.chewrobot.com:8070/api/chat";
String SERVICE_NAME = "DINGDONG";
}
package ai.qiwu.rokid.ruoqi.common.exception;
public class ProtocolException extends Exception {
/**
*
*/
private static final long serialVersionUID = 8914106243553844621L;
public ProtocolException(String message) {
super(message);
}
public ProtocolException(String message, Throwable throwable) {
super(message, throwable);
}
public ProtocolException(Throwable throwable) {
super(throwable);
}
}
package ai.qiwu.rokid.ruoqi.common.exception;
import org.springframework.http.HttpStatus;
/**
* 通用异常情况
*
* @author Bassam
*
*/
public class RokidException extends Exception {
private static final long serialVersionUID = 9135801019232303753L;
// 默认提供了一定的错误定义///
public static final String ERROR_CODE_SUCCESS = HttpStatus.OK.name();// 成功
public static final String ERROR_CODE_NOTFOUND = "NotFound";// 没有找到
public static final String ERROR_CODE_DATABASE = "DatabaseError";// 数据库错误
public static final String ERROR_CODE_REDIS = "RedisError";// Redis错误
public static final String ERROR_CODE_REDISFOUND = "RedisNotFound";// Redis数据没有找到
public static final String ERROR_CODE_SECURITY = "SecurityError";// 安全检查错误
public static final String ERROR_CODE_INVALIDHEAD = "InvalidHead";// 请求头有误
public static final String ERROR_CODE_INVALIDBODY = "InvalidBody";// 请求数据有误
public static final String ERROR_CODE_INVALIDARGUMENT = "InvalidArgument";// 无效的参数
public static final String ERROR_CODE_RESONSE = "ResponseError";// 响应错误
public static final String ERROR_CODE_MISSINGARGUMENT = "MissingArgument";// 参数缺失
public static final String ERROR_CODE_METHODNOTALLOWED = "MethodNotAllowed";// 方法不支持
public static final String ERROR_CODE_INTERNAL = "InternalError";// 内部错误
public static final String ERROR_CODE_ACCESS = "AccessDenied";// 接入出错
private int httpStatusCode;// Http状态码
private String errorCode;// 操作码
public int getHttpStatusCode() {
return httpStatusCode;
}
public void setHttpStatusCode(int httpStatusCode) {
this.httpStatusCode = httpStatusCode;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public RokidException(int httpStatusCode, String errorCode) {
super();
this.httpStatusCode = httpStatusCode;
this.errorCode = errorCode;
}
public RokidException(int httpStatusCode, String errorCode, String message) {
super(message);
this.httpStatusCode = httpStatusCode;
this.errorCode = errorCode;
}
public RokidException(int httpStatusCode, String errorCode, String message, Throwable throwable) {
super(message, throwable);
this.httpStatusCode = httpStatusCode;
this.errorCode = errorCode;
}
public RokidException(int httpStatusCode, String errorCode, Throwable throwable) {
super(throwable);
this.httpStatusCode = httpStatusCode;
this.errorCode = errorCode;
}
}
package ai.qiwu.rokid.ruoqi.common.exception;
/**
* 语音业务异常情况
*
* @author Bassam
*
*/
public class RokidSpeechletException extends RokidException {
private static final long serialVersionUID = 9135801019232303753L;
private String actionType;
private String actionName;
public RokidSpeechletException(int httpStatusCode, String errorCode, String message, Throwable throwable) {
super(httpStatusCode, errorCode, message, throwable);
}
public RokidSpeechletException(int httpStatusCode, String errorCode, String message) {
super(httpStatusCode, errorCode, message);
}
public RokidSpeechletException(int httpStatusCode, String errorCode, Throwable throwable) {
super(httpStatusCode, errorCode, throwable);
}
public RokidSpeechletException(int httpStatusCode, String errorCode) {
super(httpStatusCode, errorCode);
}
public RokidSpeechletException(int httpStatusCode, String errorCode, String actionType, String actionName) {
super(httpStatusCode, errorCode);
this.actionType = actionType;
this.actionName = actionName;
}
public RokidSpeechletException(int httpStatusCode, String errorCode, String actionType, String actionName,
Throwable throwable) {
super(httpStatusCode, errorCode, throwable);
this.actionType = actionType;
this.actionName = actionName;
}
public RokidSpeechletException(int httpStatusCode, String errorCode, String actionType, String actionName,
String message, Throwable throwable) {
super(httpStatusCode, errorCode, message, throwable);
this.actionType = actionType;
this.actionName = actionName;
}
public RokidSpeechletException(int httpStatusCode, String errorCode, String actionType, String actionName,
String message) {
super(httpStatusCode, errorCode, message);
this.actionType = actionType;
this.actionName = actionName;
}
public String getActionType() {
return actionType;
}
public void setActionType(String actionType) {
this.actionType = actionType;
}
public String getActionName() {
return actionName;
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
}
package ai.qiwu.rokid.ruoqi.common.utils;
import java.util.List;
import ai.qiwu.rokid.ruoqi.common.exception.ProtocolException;
import ai.qiwu.rokid.ruoqi.model.response.response.action.ResAction;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.confirm.ResConfirm;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.media.ResMedia;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.media.mediaitem.ResMediaItem;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.pickup.ResPickup;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.voice.ResVoice;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.voice.item.ResVoiceItem;
import org.apache.commons.lang.StringUtils;
public class ActionUtils {
/**
*
* @param actionVersion
* @param actionType
* @param shouldEndSession
* @return
* @throws ProtocolException
*/
public static ResAction getEmptyAction(String actionVersion, String actionType, boolean shouldEndSession)
throws ProtocolException {
ResAction resAction = new ResAction();
if (StringUtils.isBlank(actionVersion)) {
throw new ProtocolException("actionVersion is isBlank");
}
resAction.setVersion(actionVersion);
if (StringUtils.isBlank(actionType) || (!ResAction.ACTION_TYPE_NORMAL.equals(actionType)
&& !ResAction.ACTION_TYPE_EXIT.equals(actionType))) {
throw new ProtocolException("actionType is error");
}
resAction.setType(actionType);
resAction.setShouldEndSession(shouldEndSession);
return resAction;
}
/**
* 构建Voice节点
*
* @param voiceAction
* 详见 ResVoice.VOICE_ACTION
* @param disableEvent
* 是否关闭Event事件
* @param itemId
* @param voiceContent
* @return
* @throws ProtocolException
*/
public static ResVoice getResVoice(String voiceAction, boolean disableEvent, String itemId, String voiceContent)
throws ProtocolException {
if (checkVoiceAction(voiceAction)) {
ResVoice resVoice = new ResVoice();
resVoice.setAction(voiceAction);
resVoice.setDisableEvent(disableEvent);
if (ResVoice.VOICE_ACTION_PLAY.equals(voiceAction)) {
if (StringUtils.isBlank(voiceContent)) {
throw new ProtocolException("voiceContent is isBlank");
}
ResVoiceItem voiceItem = new ResVoiceItem();
voiceItem.setItemId(itemId);
voiceItem.setTts(voiceContent);
resVoice.setItem(voiceItem);
}
return resVoice;
}
throw new ProtocolException("voiceAction is error");
}
/**
* 构建Confirm节点
*
* @param confirmIntent
* @param confirmSlot
* @param optionWords
* @return
* @throws ProtocolException
*/
public static ResConfirm getResConfirm(String confirmIntent, String confirmSlot, List<String> optionWords)
throws ProtocolException {
if (!StringUtils.isBlank(confirmIntent) && !StringUtils.isBlank(confirmSlot)) {
ResConfirm resConfirm = new ResConfirm();
resConfirm.setConfirmIntent(confirmIntent);
resConfirm.setConfirmSlot(confirmSlot);
resConfirm.setOptionWords(optionWords);
return resConfirm;
} else {
throw new ProtocolException("confirmIntent or confirmSlot isBlank");
}
}
/**
* 检查Voice的Action事件
*
* @param voiceAction
* @return
* @throws ProtocolException
*/
public static boolean checkVoiceAction(String voiceAction) throws ProtocolException {
if (StringUtils.isBlank(voiceAction)) {
throw new ProtocolException("Voice Directive's action is blank");
}
if (!ResVoice.VOICE_ACTION_PLAY.equals(voiceAction) && !ResVoice.VOICE_ACTION_PAUSE.equals(voiceAction)
&& !ResVoice.VOICE_ACTION_RESUME.equals(voiceAction)
&& !ResVoice.VOICE_ACTION_STOP.equals(voiceAction)) {
throw new ProtocolException("Voice Directive's action is error");
}
return true;
}
/**
* 构建 ResMedia节点
*
* @param mediaAction
* @param disableEvent
* @param itemId
* @param mediaToken
* @param mediaType
* @param mediaUrl
* @param mediaOffset
* @return
* @throws ProtocolException
*/
public static ResMedia getResMeida(String mediaAction, boolean disableEvent, String itemId, String mediaToken,
String mediaType, String mediaUrl, long mediaOffset) throws ProtocolException {
if (checkMediaAction(mediaAction)) {
ResMedia resMedia = new ResMedia();
resMedia.setDisableEvent(disableEvent);
resMedia.setAction(mediaAction);
if (ResMedia.MEDIA_ACTION_PLAY.equals(mediaAction)) {
ResMediaItem resMediaItem = new ResMediaItem();
if (StringUtils.isBlank(mediaUrl)) {
throw new ProtocolException("mediaUrl isBlank");
}
resMediaItem.setUrl(mediaUrl);
if (StringUtils.isBlank(mediaType) || (!ResMediaItem.MEDIA_TYPE_AUDIO.equals(mediaType)
&& !ResMediaItem.MEDIA_TYPE_VIDEO.equals(mediaType))) {
throw new ProtocolException("mediaType is error");
}
resMediaItem.setType(mediaType);
resMediaItem.setToken(mediaToken);
if (mediaOffset < 0) {
throw new ProtocolException("mediaOffset is error");
}
resMediaItem.setOffsetInMilliseconds(mediaOffset);
resMedia.setItem(resMediaItem);
}
}
throw new ProtocolException("Error mediaAction:" + mediaAction);
}
/**
* 检查VoiceAction
*
* @param mediaAction
* @return
* @throws ProtocolException
*/
public static boolean checkMediaAction(String mediaAction) throws ProtocolException {
if (StringUtils.isBlank(mediaAction)) {
throw new ProtocolException("Media Directive's action is blank");
}
if (!ResMedia.MEDIA_ACTION_PLAY.equals(mediaAction) && !ResMedia.MEDIA_ACTION_PAUSE.equals(mediaAction)
&& !ResMedia.MEDIA_ACTION_RESUME.equals(mediaAction)
&& !ResMedia.MEDIA_ACTION_STOP.equals(mediaAction)) {
throw new ProtocolException("Media Directive's action is error");
}
return true;
}
/**
* 获取ResPickUp节点
*
* @param enable
* @param durationInMilliseconds
* @return
* @throws ProtocolException
*/
public static ResPickup getResPickup(boolean enable, long durationInMilliseconds) throws ProtocolException {
ResPickup resPickup = new ResPickup();
resPickup.setEnable(enable);
if (durationInMilliseconds < 0) {
throw new ProtocolException("durationInMilliseconds is error");
}
resPickup.setDurationInMilliseconds(durationInMilliseconds);
return resPickup;
}
/**
* 检查Action类型
*
* @param actionType
* @return
* @throws ProtocolException
*/
public static boolean checkActionType(String actionType) throws ProtocolException {
if (ResAction.ACTION_TYPE_EXIT.equals(actionType) || ResAction.ACTION_TYPE_NORMAL.equals(actionType)) {
return true;
}
throw new ProtocolException("actionType is error");
}
/**
* 检查ResVoice的合法性
*
* @param resVoice
* @return
* @throws ProtocolException
*/
public static boolean checkVoice(ResVoice resVoice) throws ProtocolException {
if (resVoice != null) {
if (!checkVoiceAction(resVoice.getAction())) {
throw new ProtocolException("Voice Directive is error");
}
if (ResVoice.VOICE_ACTION_PLAY.equals(resVoice.getAction())) {
if (resVoice.getItem() == null) {
throw new ProtocolException("Voice Directive's action is play,but item is null");
}
if (StringUtils.isBlank(resVoice.getItem().getTts())) {
throw new ProtocolException("Voice Directive's action is play,but item's tts is blank");
}
}
}
return true;
}
/**
* 检查Media节点的合法性
*
* @param resMedia
* @return
* @throws ProtocolException
*/
public static boolean checkMedia(ResMedia resMedia) throws ProtocolException {
if (resMedia != null) {
if (!checkMediaAction(resMedia.getAction())) {
throw new ProtocolException("Media Directivei is error");
}
if (ResMedia.MEDIA_ACTION_PLAY.equals(resMedia.getAction())) {
if (resMedia.getItem() == null) {
throw new ProtocolException("Meida Directive's action is play,but item is null");
}
if (StringUtils.isBlank(resMedia.getItem().getUrl())) {
throw new ProtocolException("Meida Directive's action is play,but item's url is Blank");
}
if (resMedia.getItem().getOffsetInMilliseconds() < 0) {
throw new ProtocolException(
"Meida Directive's action is play,but item's OffsetInMilliseconds is <0");
}
}
}
return true;
}
/**
* 检查PickUp节点
*
* @param resPickup
* @return
* @throws ProtocolException
*/
public static boolean checkPickup(ResPickup resPickup) throws ProtocolException {
if (resPickup != null) {
if (resPickup.getDurationInMilliseconds() < 0) {
throw new ProtocolException("PickUp Directive's DurationInMilliseconds is <0");
}
}
return true;
}
/**
* 检查confirm节点
*
* @param resConfirm
* @return
* @throws ProtocolException
*/
public static boolean checkConfirm(ResConfirm resConfirm) throws ProtocolException {
if (resConfirm != null) {
if (StringUtils.isBlank(resConfirm.getConfirmIntent())
|| StringUtils.isBlank(resConfirm.getConfirmSlot())) {
throw new ProtocolException("Confirm Directive's Intent or slot is blank");
}
}
return true;
}
}
package ai.qiwu.rokid.ruoqi.common.utils;
import ai.qiwu.rokid.ruoqi.common.exception.ProtocolException;
import ai.qiwu.rokid.ruoqi.common.exception.RokidException;
import ai.qiwu.rokid.ruoqi.model.response.ResResponse;
import org.springframework.http.HttpStatus;
public class ProtocolUtils {
/**
* 忽略事件,比如Voice.STARTED的EventRequest来的时候我们可以使用这个操作忽略这个请求
*
* @return
* @throws ProtocolException
*/
public static final ResResponse igonre() {
try {
return ResponseUtils.buildIngoreEventResponse();
} catch (ProtocolException e) {
e.printStackTrace();
return null;
}
}
/**
* 退出
*
* @举例 若琪停止播放
* @return
* @throws ProtocolException
*/
public static final ResResponse exit() throws RokidException {
try {
return ResponseUtils.buildExitNowResponse();
} catch (ProtocolException e) {
return null;
}
}
/**
* 从0开始播放音乐,并且停止TTS
*
* @param songId
* @param songUrl
* @return
* @throws RokidException
*/
public static final ResResponse playSongAndFinished(String songId, String songUrl) throws RokidException {
try {
return ResponseBuilder.build().audioPlay(songId, null, songUrl, 0).mediaEventDisable().afterFinish()
.create();
} catch (ProtocolException e) {
throw new RokidException(HttpStatus.INTERNAL_SERVER_ERROR.value(), RokidException.ERROR_CODE_RESONSE,
e.getCause());
}
}
/**
* 暂停音乐
*
* @举例 若琪暂停播放
* @return
* @throws ProtocolException
*/
public static final ResResponse pauseMusic() throws RokidException {
try {
return ResponseBuilder.build().mediaPause().mediaEventDisable().create();
} catch (ProtocolException e) {
throw new RokidException(HttpStatus.INTERNAL_SERVER_ERROR.value(), RokidException.ERROR_CODE_RESONSE,
e.getCause());
}
}
public static final ResResponse playTTs(String content) throws RokidException {
try {
return ResponseBuilder.build().voicePlay(null, content).sendChatCard(content).create();
} catch (ProtocolException e) {
throw new RokidException(HttpStatus.INTERNAL_SERVER_ERROR.value(), RokidException.ERROR_CODE_RESONSE,
e.getCause());
}
}
/**
* 播放完tts退出示例
* @param content
* @return
* @throws RokidException
*/
public static final ResResponse playTts(String content) throws RokidException{
try {
return ResponseBuilder.build().voicePlay(null, content).sendChatCard(content).afterFinish().create();
} catch (ProtocolException e) {
throw new RokidException(HttpStatus.INTERNAL_SERVER_ERROR.value(), RokidException.ERROR_CODE_RESONSE,
e.getCause());
}
}
/**
* 进入六十秒拾音状态
* @param content
* @return
* @throws RokidException
*/
public static final ResResponse pickUp(String content) throws RokidException{
try {
return ResponseBuilder.build().voicePlay(null, content).pickupOpen().sendChatCard(content).create();
} catch (ProtocolException e) {
throw new RokidException(HttpStatus.INTERNAL_SERVER_ERROR.value(), RokidException.ERROR_CODE_RESONSE,
e.getCause());
}
}
/**
* 继续播放音乐
*
* @举例 若琪继续播放音乐
* @return
* @throws ProtocolException
*/
public static final ResResponse resumeMusic() throws RokidException {
try {
return ResponseBuilder.build().mediaResume().mediaEventDisable().afterFinish().create();
} catch (ProtocolException e) {
throw new RokidException(HttpStatus.INTERNAL_SERVER_ERROR.value(), RokidException.ERROR_CODE_RESONSE,
e.getCause());
}
}
}
package ai.qiwu.rokid.ruoqi.common.utils;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
public class ReqBasicInfo implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String protocolVersion;// 当前协议版本
private String requestId;// 请求ID
private String sessionId;// SessionId
private String appId;// 应用ID
private String deviceId;// 设备ID
private String deviceType;// 设备类型
private String deviceVendor;// 厂商ID
private String masterId;// 设备主人的ID
private String userId;// 用户id
private String locale;// 用户语言
private String actionType;// 操作类型
private String actionName;// 操作名称
private long timestamp;// 设备时间戳
private String voicetrigger;// 当前设备激活词
public String getProtocolVersion() {
return protocolVersion;
}
public String getRequestId() {
return requestId;
}
public String getSessionId() {
return sessionId;
}
public String getAppId() {
return appId;
}
public String getDeviceId() {
return deviceId;
}
public String getDeviceType() {
return deviceType;
}
public String getDeviceVendor() {
return deviceVendor;
}
public String getMasterId() {
return masterId;
}
public String getUserId() {
return userId;
}
public String getLocale() {
return locale;
}
public String getActionType() {
return actionType;
}
public String getActionName() {
return actionName;
}
public long getTimestamp() {
return timestamp;
}
public void setProtocolVersion(String protocolVersion) {
this.protocolVersion = protocolVersion;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public void setDeviceVendor(String deviceVendor) {
this.deviceVendor = deviceVendor;
}
public void setMasterId(String masterId) {
this.masterId = masterId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setLocale(String locale) {
this.locale = locale;
}
public void setActionType(String actionType) {
this.actionType = actionType;
}
public void setActionName(String actionName) {
this.actionName = actionName;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
public String getVoicetrigger() {
return voicetrigger;
}
public void setVoicetrigger(String voicetrigger) {
this.voicetrigger = voicetrigger;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.common.utils;
import java.util.HashMap;
import ai.qiwu.rokid.ruoqi.common.exception.ProtocolException;
import ai.qiwu.rokid.ruoqi.model.request.ReqRequest;
import ai.qiwu.rokid.ruoqi.model.request.context.application.media.ReqApplicationMedia;
import ai.qiwu.rokid.ruoqi.model.request.context.application.voice.ReqApplicationVoice;
import ai.qiwu.rokid.ruoqi.model.request.context.device.location.ReqLocation;
import ai.qiwu.rokid.ruoqi.model.request.request.ReqRequestValue;
import ai.qiwu.rokid.ruoqi.model.request.request.content.extra.media.ReqExtraMedia;
import ai.qiwu.rokid.ruoqi.model.request.request.content.extra.voice.ReqExtraVoice;
import ai.qiwu.rokid.ruoqi.model.request.request.content.slot.Slot;
import org.apache.commons.lang.StringUtils;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
/**
* 请求处理工具类
*
* @author Bassam
*
*/
public class RequestUtils {
/**
* 获取ReqRequest对象
*
* @param resuest
* @return
* @throws ProtocolException
*/
public static ReqRequest getRequest(String resuest) throws ProtocolException {
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
return gson.fromJson(resuest, ReqRequest.class);
}
/**
* 获得基本请求信息
*
* @param reqRequest
* @return
*/
public static ReqBasicInfo getBasicInfo(ReqRequest reqRequest) {
ReqBasicInfo reqBasicInfo = new ReqBasicInfo();
if (reqRequest != null) {
reqBasicInfo.setProtocolVersion(reqRequest.getVersion());
if (reqRequest.getSession() != null) {
reqBasicInfo.setSessionId(reqRequest.getSession().getSessionId());
}
if (reqRequest.getContext() != null) {
if (reqRequest.getContext().getApplication() != null) {
reqBasicInfo.setAppId(reqRequest.getContext().getApplication().getApplicationId());
}
if (reqRequest.getContext().getDevice() != null
&& reqRequest.getContext().getDevice().getBasic() != null) {
reqBasicInfo.setDeviceId(reqRequest.getContext().getDevice().getBasic().getDeviceId());
reqBasicInfo.setDeviceType(reqRequest.getContext().getDevice().getBasic().getDeviceType());
reqBasicInfo.setDeviceVendor(reqRequest.getContext().getDevice().getBasic().getVendor());
reqBasicInfo.setTimestamp(reqRequest.getContext().getDevice().getBasic().getTimestamp());
reqBasicInfo.setMasterId(reqRequest.getContext().getDevice().getBasic().getMasterId());
reqBasicInfo.setLocale(reqRequest.getContext().getDevice().getBasic().getLocale());
reqBasicInfo.setVoicetrigger(reqRequest.getContext().getDevice().getBasic().getVoicetrigger());
}
if (reqRequest.getContext().getUser() != null) {
reqBasicInfo.setUserId(reqRequest.getContext().getUser().getUserId());
}
}
if (reqRequest.getRequest() != null) {
reqBasicInfo.setRequestId(reqRequest.getRequest().getReqId());
reqBasicInfo.setActionType(reqRequest.getRequest().getReqType());
if (reqRequest.getRequest().getContent() != null) {
if (ReqRequestValue.REQTYPE_EVENT.equals(reqBasicInfo.getActionType())) {
reqBasicInfo.setActionName(reqRequest.getRequest().getContent().getEvent());
} else if (ReqRequestValue.REQTYPE_INTENT.equals(reqBasicInfo.getActionType())) {
reqBasicInfo.setActionName(reqRequest.getRequest().getContent().getIntent());
}
}
}
}
return reqBasicInfo;
}
/**
* 获得Media状态信息
*
* @param reqRequest
* @return
*/
public static ReqApplicationMedia getMediaState(ReqRequest reqRequest) {
ReqApplicationMedia reqApplicationMedia = null;
if (reqRequest != null && reqRequest.getContext() != null && reqRequest.getContext().getApplication() != null) {
reqApplicationMedia = reqRequest.getContext().getApplication().getMedia();
}
if (reqApplicationMedia == null) {
reqApplicationMedia = new ReqApplicationMedia();
}
if (StringUtils.isBlank(reqApplicationMedia.getState())) {
reqApplicationMedia.setState(ReqApplicationMedia.STATE_IDLE);
}
return reqApplicationMedia;
}
/**
* 获得VoiceState
*
* @param reqRequest
* @return
*/
public static ReqApplicationVoice getVoiceState(ReqRequest reqRequest) {
ReqApplicationVoice reqApplicationVoice = null;
if (reqRequest != null && reqRequest.getContext() != null && reqRequest.getContext().getApplication() != null) {
reqApplicationVoice = reqRequest.getContext().getApplication().getVoice();
}
if (reqApplicationVoice == null) {
reqApplicationVoice = new ReqApplicationVoice();
}
if (StringUtils.isBlank(reqApplicationVoice.getState())) {
reqApplicationVoice.setState(ReqApplicationVoice.STATE_IDLE);
}
return reqApplicationVoice;
}
/**
* 获取位置信息
*
* @param reqRequest
* @return
*/
public static ReqLocation getLocation(ReqRequest reqRequest) {
ReqLocation reqLocation = null;
if (reqRequest != null && reqRequest.getContext() != null && reqRequest.getContext().getDevice() != null) {
reqLocation = reqRequest.getContext().getDevice().getLocation();
}
if (reqLocation == null) {
reqLocation = new ReqLocation();
}
return reqLocation;
}
/**
* 获取Media拓展信息
*
* @param reqRequest
* @return
*/
public static ReqExtraMedia getMediaExtra(ReqRequest reqRequest) {
ReqExtraMedia reqExtraMedia = null;
if (reqRequest != null && reqRequest.getRequest() != null && reqRequest.getRequest().getContent() != null
&& reqRequest.getRequest().getContent().getExtra() != null) {
reqExtraMedia = reqRequest.getRequest().getContent().getExtra().getMedia();
}
if (reqExtraMedia == null) {
reqExtraMedia = new ReqExtraMedia();
}
return reqExtraMedia;
}
/**
* 获取Voice拓展信息
*
* @param reqRequest
* @return
*/
public static ReqExtraVoice getVoiceExtra(ReqRequest reqRequest) {
ReqExtraVoice reqExtraVoice = null;
if (reqRequest != null && reqRequest.getRequest() != null && reqRequest.getRequest().getContent() != null
&& reqRequest.getRequest().getContent().getExtra() != null) {
reqExtraVoice = reqRequest.getRequest().getContent().getExtra().getVoice();
}
if (reqExtraVoice == null) {
reqExtraVoice = new ReqExtraVoice();
}
return reqExtraVoice;
}
/**
* 获取属性信息
*
* @param reqRequest
* @return
*/
public static HashMap<String, Object> getAttributes(ReqRequest reqRequest) {
HashMap<String, Object> attributes = null;
if (reqRequest != null && reqRequest.getSession() != null && reqRequest.getSession().getAttributes() != null) {
attributes = reqRequest.getSession().getAttributes();
}
if (attributes == null) {
attributes = new HashMap<>();
}
return attributes;
}
/**
* 获取Slots
*
* @param reqRequest
* @return
*/
public static HashMap<String, Slot> getSlots(ReqRequest reqRequest) {
HashMap<String, Slot> slots = null;
if (reqRequest != null && reqRequest.getRequest() != null && reqRequest.getRequest().getContent() != null) {
slots = reqRequest.getRequest().getContent().getSlots();
}
if (slots == null) {
slots = new HashMap<>();
}
return slots;
}
/**
* 获取Intent Request的ASR结果
*
* @param reqRequest
* @return
*/
public static String getSentence(ReqRequest reqRequest) {
String scentence = "";
if (reqRequest != null && reqRequest.getRequest() != null && reqRequest.getRequest().getContent() != null) {
scentence = reqRequest.getRequest().getContent().getSentence();
}
return scentence;
}
}
package ai.qiwu.rokid.ruoqi.common.utils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import ai.qiwu.rokid.ruoqi.common.exception.ProtocolException;
import ai.qiwu.rokid.ruoqi.model.response.ResResponse;
import ai.qiwu.rokid.ruoqi.model.response.response.ResResponseContent;
import ai.qiwu.rokid.ruoqi.model.response.response.action.ResAction;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.ResDirective;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.confirm.ResConfirm;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.media.ResMedia;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.media.mediaitem.ResMediaItem;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.pickup.ResPickup;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.voice.ResVoice;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.voice.item.ResVoiceItem;
import ai.qiwu.rokid.ruoqi.model.response.response.card.ResCard;
import ai.qiwu.rokid.ruoqi.model.response.response.card.chat.ResChatCard;
import ai.qiwu.rokid.ruoqi.model.response.session.ResSession;
import org.apache.commons.lang.StringUtils;
public class ResponseBuilder {
private ResResponse response;
private boolean shouldEndSession = false;// 执行完这个action完毕
private String actionType = ResAction.ACTION_TYPE_NORMAL;
private HashMap<String, Object> attributes;
private ResVoice resVoice;
private ResConfirm resConfirm;
private ResMedia resMedia;
private ResPickup pickup;
private ResCard card;
public static ResponseBuilder build() {
return new ResponseBuilder();
}
public ResponseBuilder() {
response = buildEmptyActionResponse(ResResponse.RES_VERSION_V2, null, ResAction.ACTION_VERSION_V2, actionType,
shouldEndSession);
}
/**
* 下一次请求原样带回的参数
*
* @param attributes
* @return
*/
public ResponseBuilder setAttributes(HashMap<String, Object> attributes) {
this.attributes = attributes;
return this;
}
/**
* 播放TTS
*
* @param voiceId
* @param voiceContent
* @return
*/
public ResponseBuilder voicePlay(String voiceId, String voiceContent) {
if (resVoice == null) {
resVoice = new ResVoice();
}
ResVoiceItem resVoiceItem = new ResVoiceItem();
resVoiceItem.setItemId(voiceId);
resVoiceItem.setTts(voiceContent);
resVoice.setAction(ResVoice.VOICE_ACTION_PLAY);
resVoice.setItem(resVoiceItem);
return this;
}
/**
* 暂停Media
*
* @return
*/
public ResponseBuilder voicePause() {
if (resVoice == null) {
resVoice = new ResVoice();
}
resVoice.setAction(ResVoice.VOICE_ACTION_PAUSE);
return this;
}
/**
* 继续播放TTS
*
* @return
*/
public ResponseBuilder voiceResume() {
if (resVoice == null) {
resVoice = new ResVoice();
}
resVoice.setAction(ResVoice.VOICE_ACTION_RESUME);
return this;
}
/**
* 停止播放TTS
*
* @return
*/
public ResponseBuilder voiceStop() {
if (resVoice == null) {
resVoice = new ResVoice();
}
resVoice.setAction(ResVoice.VOICE_ACTION_STOP);
return this;
}
/**
* 关闭Voice的EventRequest
*
* @return
*/
public ResponseBuilder voiceEventDisable() {
if (resVoice == null) {
resVoice = new ResVoice();
}
resVoice.setDisableEvent(true);
return this;
}
/**
* 发起confirm
*
* @param confirmIntent
* @param confirmSlot
* @param optionWords
* @return
*/
public ResponseBuilder confirmOpen(String confirmIntent, String confirmSlot, List<String> optionWords) {
if (resConfirm == null) {
resConfirm = new ResConfirm();
}
resConfirm.setConfirmSlot(confirmSlot);
resConfirm.setConfirmIntent(confirmIntent);
resConfirm.setOptionWords(optionWords);
return this;
}
/**
* 播放音频
*
* @param audioId
* @param audioToken
* @param audioUrl
* @param offsetInMilliseconds
* @return
*/
public ResponseBuilder audioPlay(String audioId, String audioToken, String audioUrl, long offsetInMilliseconds) {
return mediaPlay(audioId, audioToken, ResMediaItem.MEDIA_TYPE_AUDIO, audioUrl, offsetInMilliseconds);
}
/**
* 播放视频
*
* @param mediaId
* @param videoToken
* @param videoUrl
* @param offsetInMilliseconds
* @return
*/
public ResponseBuilder videoPlay(String mediaId, String videoToken, String videoUrl, long offsetInMilliseconds) {
return mediaPlay(mediaId, videoToken, ResMediaItem.MEDIA_TYPE_VIDEO, videoUrl, offsetInMilliseconds);
}
/**
* 播放Media
*
* @param mediaType
* @param mediaId
* @param mediaToken
* @param mediaUrl
* @param offsetInMilliseconds
* @return
*/
public ResponseBuilder mediaPlay(String mediaId, String mediaToken, String mediaType, String mediaUrl,
long offsetInMilliseconds) {
if (resMedia == null) {
resMedia = new ResMedia();
}
ResMediaItem resMediaItem = new ResMediaItem();
resMediaItem.setItemId(mediaId);
resMediaItem.setType(mediaType);
resMediaItem.setToken(mediaToken);
resMediaItem.setUrl(mediaUrl);
resMediaItem.setOffsetInMilliseconds(offsetInMilliseconds);
resMedia.setAction(ResMedia.MEDIA_ACTION_PLAY);
resMedia.setItem(resMediaItem);
return this;
}
/**
* 暂停Media
*
* @return
*/
public ResponseBuilder mediaPause() {
if (resMedia == null) {
resMedia = new ResMedia();
}
resMedia.setAction(ResMedia.MEDIA_ACTION_PAUSE);
return this;
}
/**
* 继续播放Meida
*
* @return
*/
public ResponseBuilder mediaResume() {
if (resMedia == null) {
resMedia = new ResMedia();
}
resMedia.setAction(ResMedia.MEDIA_ACTION_RESUME);
return this;
}
/**
* 停止播放TTS
*
* @return
*/
public ResponseBuilder mediaStop() {
if (resMedia == null) {
resMedia = new ResMedia();
}
resMedia.setAction(ResMedia.MEDIA_ACTION_STOP);
return this;
}
/**
* 关闭Voice的EventRequest
*
* @return
*/
public ResponseBuilder mediaEventDisable() {
if (resMedia == null) {
resMedia = new ResMedia();
}
resMedia.setDisableEvent(true);
return this;
}
/**
* 打开拾音
*
* @return
*/
public ResponseBuilder pickupOpen() {
return pickupOpen(null);
}
/**
* 打开识音,并且设置重复播报的TTS
*
* @param retryTts
* @return
*/
public ResponseBuilder pickupOpen(String retryTts) {
if (pickup == null) {
pickup = new ResPickup();
}
pickup.setEnable(true);
pickup.setDurationInMilliseconds(6000l);
if (StringUtils.isNotBlank(retryTts)) {
pickup.setRetryTts(retryTts);
}
return this;
}
/**
* 执行完毕以后退出应用
*
* @return
*/
public ResponseBuilder afterFinish() {
shouldEndSession = true;
return this;
}
/**
* 立即退出应用
*
* @return
*/
public ResponseBuilder finishNow() {
actionType = ResAction.ACTION_TYPE_EXIT;
shouldEndSession = true;
return this;
}
public ResponseBuilder sendChatCard(String content) {
card = new ResChatCard(content);
return this;
}
public ResResponse create() throws ProtocolException {
response.getSession().setAttributes(attributes);
List<ResDirective> directives = new ArrayList<>();
response.getResponse().getAction().setDirectives(directives);
response.getResponse().getAction().setShouldEndSession(shouldEndSession);
if (!ActionUtils.checkActionType(actionType)) {
throw new ProtocolException("actionType is error");
}
response.getResponse().getAction().setType(actionType);
if (!ActionUtils.checkVoice(resVoice)) {
throw new ProtocolException("resVoice is error");
}
if (resVoice != null) {
response.getResponse().getAction().getDirectives().add(resVoice);
}
if (!ActionUtils.checkMedia(resMedia)) {
throw new ProtocolException("resMedia is error");
}
if (resMedia != null) {
response.getResponse().getAction().getDirectives().add(resMedia);
}
if (!ActionUtils.checkConfirm(resConfirm)) {
throw new ProtocolException("resConfirm is error");
}
if (resConfirm != null) {
response.getResponse().getAction().getDirectives().add(resConfirm);
}
if (!ActionUtils.checkPickup(pickup)) {
throw new ProtocolException("resPickup is error");
}
if (pickup != null) {
response.getResponse().getAction().getDirectives().add(pickup);
}
if (card != null) {
response.getResponse().setCard(card);
}
return response;
}
private ResResponse buildEmptyActionResponse(String resVersion, HashMap<String, Object> attributes,
String actionVersion, String actionType, boolean shouldEndSession) {
ResResponse resResponse = new ResResponse();
resResponse.setVersion(resVersion);
ResSession resSession = new ResSession();
if (attributes != null && !attributes.isEmpty()) {
resSession.setAttributes(attributes);
}
resResponse.setSession(resSession);
ResResponseContent resResponseContent = new ResResponseContent();
ResAction resAction;
try {
resAction = ActionUtils.getEmptyAction(actionVersion, actionType, shouldEndSession);
resResponseContent.setAction(resAction);
} catch (ProtocolException e) {
e.printStackTrace();
}
resResponse.setResponse(resResponseContent);
return resResponse;
}
}
package ai.qiwu.rokid.ruoqi.common.utils;
import java.util.List;
import ai.qiwu.rokid.ruoqi.common.exception.ProtocolException;
import ai.qiwu.rokid.ruoqi.model.response.ResResponse;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.media.mediaitem.ResMediaItem;
import org.apache.commons.lang.StringUtils;
import com.google.gson.GsonBuilder;
/**
* @类描述 用于快速构造CloudApp的Response的工具类
* @对应结构以及命名 Response对应ResResponse:协议内容; response对应ResResponseContent:响应;
* action对应ResAction:事件; voice:文本; media:媒体; confirm:主动询问;
* confirmIntent:主动询问意图(比如询问歌手); confirmSlot:主动询问意图内容(比如歌手);
* optionWords:主动询问辅助信息; 场景化:scen;非场景化:cut
*/
public class ResponseUtils {
/**
* @方法 构造一个退出应用的协议内容
* @描述 客户端接收到该协议内容以后会立即退出应用
* @使用场景 当我们的应用需要退出的时候返回这个协议内容
* @注意 此协议内容的版本以及事件版本号都已经被固定为RES_VERSION_V2和ACTION_VERSION_V2,如协议版本变更,请自行修正一下;另外应用退出以后,nlp那边的session也会被清理
* @return
* @throws ProtocolException
*/
public static ResResponse buildExitNowResponse() throws ProtocolException {
return ResponseBuilder.build().finishNow().create();
}
/**
* @方法 构造一个空的协议内容,Voice以及Media继续保持原有执行状态
* @描述 客户端接收到该协议内容以后不会对当前的操作有任何的影响
* @使用场景 当我们的应用接受到不需要处理,需要忽略的Event请求是,我们可以返回该响应
* @注意 此协议内容的版本以及事件版本号都已经被固定为RES_VERSION_V2和ACTION_VERSION_V2,如协议版本变更,请自行修正一下,另外此协议内容会的shouldEndSession=false的
* @return
* @throws ProtocolException
*/
public static ResResponse buildIngoreEventResponse() throws ProtocolException {
return ResponseBuilder.build().create();
}
/**
* @方法 播报一句TTS,Media继续保持原有执行状态,并且有EventRequest
* @param voiceId
* tts的ID,可以为空
* @param voiceContent
* tts 内容
* @return
* @throws ProtocolException
*/
public static ResResponse buildVoicePlayResponse(String voiceId, String voiceContent) throws ProtocolException {
if (StringUtils.isBlank(voiceContent)) {
throw new ProtocolException("voiceContent Can not be null");
}
return ResponseBuilder.build().voicePlay(voiceId, voiceContent).create();
}
/**
* @方法 暂停播放Voice
*
* @return
* @throws ProtocolException
*/
public static ResResponse buildVoicePauseResponse() throws ProtocolException {
return ResponseBuilder.build().voicePause().create();
}
/**
* @方法 继续播放Voice
*
* @return
* @throws ProtocolException
*/
public static ResResponse buildVoiceResumeResponse() throws ProtocolException {
return ResponseBuilder.build().voiceResume().create();
}
/**
* @方法 停止播放Voice
*
* @return
* @throws ProtocolException
*/
public static ResResponse buildVoiceStopResponse() throws ProtocolException {
return ResponseBuilder.build().voiceStop().create();
}
/**
* @方法 播放Media事件,TTS继续保持原有执行状态,
*
* @param mediaToken
* @param mediaType
* @param mediaUrl
* @param mediaOffset
* @return
*/
public static ResResponse buildMediaPlayResponse(String mediaId, String mediaToken, String mediaType,
String mediaUrl, long mediaOffset) throws ProtocolException {
if (StringUtils.isBlank(mediaUrl)) {
throw new ProtocolException("mediaUrl Can not be null");
}
if (mediaOffset < 0) {
throw new ProtocolException("mediaOffset Can not be < 0");
}
if (!ResMediaItem.MEDIA_TYPE_AUDIO.equals(mediaType) && ResMediaItem.MEDIA_TYPE_VIDEO.equals(mediaType)) {
throw new ProtocolException("mediaType is error");
}
return ResponseBuilder.build().mediaPlay(mediaId, mediaToken, mediaType, mediaUrl, mediaOffset).create();
}
/**
* @方法 暂停播放Media
*
* @return
* @throws ProtocolException
*/
public static ResResponse buildMediaPauseResponse() throws ProtocolException {
return ResponseBuilder.build().mediaPause().create();
}
/**
* @方法 继续播放Media
*
* @return
* @throws ProtocolException
*/
public static ResResponse buildMediaResumeResponse() throws ProtocolException {
return ResponseBuilder.build().mediaResume().create();
}
/**
* @方法 停止播放Media
*
* @return
* @throws ProtocolException
*/
public static ResResponse buildMediaStopResponse() throws ProtocolException {
return ResponseBuilder.build().mediaStop().create();
}
/**
* @方法 暂停播放Media和Voice
*
* @return
* @throws ProtocolException
*/
public static ResResponse buildPauseResponse() throws ProtocolException {
return ResponseBuilder.build().voicePause().mediaPause().create();
}
/**
* @方法 继续播放Voice和Meida
*
* @return
* @throws ProtocolException
*/
public static ResResponse buildResumeResponse() throws ProtocolException {
return ResponseBuilder.build().voiceResume().mediaResume().create();
}
/**
* @方法 停止播放Voice和Media
*
* @return
* @throws ProtocolException
*/
public static ResResponse buildStopResponse() throws ProtocolException {
return ResponseBuilder.build().voiceStop().mediaStop().create();
}
/**
* 构造一个Confirm,并且把Media停止
*
* @param voiceContent
* @param confirmIntent
* 需要在平台上面定义过得intent,不能随便写
* @param confirmSlot
* 需要在平台上面定义过得slot,不能随便写
* @param confirmOptionWords
* @return
*/
public static ResResponse buildConfirmOpenResponse(String voiceContent, String confirmIntent, String confirmSlot,
List<String> confirmOptionWords) throws ProtocolException {
if (StringUtils.isBlank(voiceContent)) {
throw new ProtocolException("voiceContent Can not be null");
}
if (StringUtils.isBlank(confirmIntent)) {
throw new ProtocolException("confirmIntent Can not be null");
}
if (StringUtils.isBlank(confirmSlot)) {
throw new ProtocolException("confirmSlot Can not be null");
}
return ResponseBuilder.build().voicePlay(null, voiceContent).mediaStop()
.confirmOpen(confirmIntent, confirmSlot, confirmOptionWords).create();
}
/**
* 将ResResponse变成Json字符串
*
* @param response
* @return
*/
public static String responseToString(ResResponse response) {
if (response != null) {
return new GsonBuilder().disableHtmlEscaping().create().toJson(response);
} else {
return null;
}
}
}
package ai.qiwu.rokid.ruoqi.controller;
import ai.qiwu.rokid.ruoqi.model.request.ReqRequest;
import ai.qiwu.rokid.ruoqi.model.response.ResResponse;
import ai.qiwu.rokid.ruoqi.service.RokidRequestParse;
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.RestController;
/**
* @author 苗权威
* @dateTime 19-7-3 下午4:25
*/
@RestController
public class RokidController {
private static final Logger logger = LoggerFactory.getLogger(RokidController.class);
@Autowired
private RokidRequestParse requestParse;
@RequestMapping("/rokid")
public ResResponse chat(@RequestBody ReqRequest request) {
logger.info("请求消息:"+request.toString());
return requestParse.getResponse(request);
}
}
package ai.qiwu.rokid.ruoqi.model.request;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.request.context.ReqContext;
import ai.qiwu.rokid.ruoqi.model.request.request.ReqRequestValue;
import ai.qiwu.rokid.ruoqi.model.request.session.ReqSession;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
/**
*
*
*/
/**
* @类描述 CloudApp协议,Request对象
* @说明 Request主要包含四块内容 1、version:CloudApp协议版本; 2、session:当前的会话信息;
* 3、context:设备、用户、以及其他状态信息; 4、request:业务请求内容
* @param <>
* Slots对象
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqRequest implements Serializable {
/**
*
*/
private static final long serialVersionUID = -490292141289020844L;
/**
*
*/
private String version;// 协议版本号,当前版本2.0.0
private ReqSession session;// 会话的信息
private ReqContext context;// 当前的设备信息,用户信息和应用状态
private ReqRequestValue request;
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public ReqSession getSession() {
return session;
}
public void setSession(ReqSession session) {
this.session = session;
}
public ReqContext getContext() {
return context;
}
public void setContext(ReqContext context) {
this.context = context;
}
public ReqRequestValue getRequest() {
return request;
}
public void setRequest(ReqRequestValue request) {
this.request = request;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.context;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.request.context.application.ReqApplication;
import ai.qiwu.rokid.ruoqi.model.request.context.device.ReqDevice;
import ai.qiwu.rokid.ruoqi.model.request.context.user.ReqUser;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqContext implements Serializable {
/**
*
*/
private static final long serialVersionUID = 5297187036481770538L;
private ReqApplication application; //ApplicationInfo对象,目前只有应用ID
private ReqDevice device;//此次请求发生时当前设备信息的描述
private ReqUser user;//展示了与当前设备绑定的用户信息,通常是设备对应手机应用的账号
public ReqApplication getApplication() {
return application;
}
public void setApplication(ReqApplication application) {
this.application = application;
}
public ReqDevice getDevice() {
return device;
}
public void setDevice(ReqDevice device) {
this.device = device;
}
public ReqUser getUser() {
return user;
}
public void setUser(ReqUser user) {
this.user = user;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.context.application;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.request.context.application.media.ReqApplicationMedia;
import ai.qiwu.rokid.ruoqi.model.request.context.application.voice.ReqApplicationVoice;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqApplication implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6035458330596077339L;
private String applicationId;// 当前的应用ID
private ReqApplicationMedia media;
private ReqApplicationVoice voice;
public String getApplicationId() {
return applicationId;
}
public ReqApplicationMedia getMedia() {
return media;
}
public ReqApplicationVoice getVoice() {
return voice;
}
public void setMedia(ReqApplicationMedia media) {
this.media = media;
}
public void setVoice(ReqApplicationVoice voice) {
this.voice = voice;
}
public void setApplicationId(String applicationId) {
this.applicationId = applicationId;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.context.application.media;
import java.io.Serializable;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqApplicationMedia implements Serializable {
public static final String STATE_PLAYING = "PLAYING";// 当前在播放状态
public static final String STATE_PAUSED = "PAUSED";// 当前播放器在暂停状态
public static final String STATE_IDLE = "IDLE";// 当前播放器状态在闲置状态
public static final String STATE_UNKNOW = "UNKNOW";// 未知状态
/**
*
*/
private static final long serialVersionUID = -6035458330596077339L;
private String state;// "PLAYING / PAUSED / IDLE",
private String itemId;
private String token;
private Long progress;// 毫秒
private Long duration;// 毫秒
public String getState() {
return state;
}
public String getItemId() {
return itemId;
}
public String getToken() {
return token;
}
public Long getProgress() {
return progress;
}
public void setProgress(Long progress) {
this.progress = progress;
}
public Long getDuration() {
return duration;
}
public void setDuration(Long duration) {
this.duration = duration;
}
public void setState(String state) {
this.state = state;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public void setToken(String token) {
this.token = token;
}
}
package ai.qiwu.rokid.ruoqi.model.request.context.application.voice;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqApplicationVoice implements Serializable {
public static final String STATE_PLAYING = "PLAYING";// 当前在播放状态
public static final String STATE_PAUSED = "PAUSED";// 当前播放器在暂停状态
public static final String STATE_IDLE = "IDLE";// 当前播放器状态在闲置状态
public static final String STATE_UNKNOW = "UNKNOW";// 未知状态
/**
*
*/
private static final long serialVersionUID = -6035458330596077339L;
private String state;// "PLAYING / PAUSED / IDLE",
private String itemId;
public String getState() {
return state;
}
public String getItemId() {
return itemId;
}
public void setState(String state) {
this.state = state;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.context.device;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.request.context.device.basic.ReqBasic;
import ai.qiwu.rokid.ruoqi.model.request.context.device.location.ReqLocation;
import ai.qiwu.rokid.ruoqi.model.request.context.device.media.ReqMedia;
import ai.qiwu.rokid.ruoqi.model.request.context.device.screen.ReqScreen;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqDevice implements Serializable {
/**
*
*/
private static final long serialVersionUID = -3966116657482862685L;
private ReqBasic basic;// 展示了当前设备的基础信息,主要包含设备制造信息、时间信息、国家文字信息。
private ReqScreen screen;// 展示了当前设备的屏幕信息,主要包含屏幕的分辨率信息。
private ReqMedia media;// 向CloudApp表明当前设备上CloudAppClient中的MediaPlayer的状态信息。
private ReqMedia voice;// 向CloudApp表明当前设备上CloudAppClient中的Voice的状态信息。
private ReqLocation location;// 位置信息,现在只有一个经纬度
public ReqBasic getBasic() {
return basic;
}
public void setBasic(ReqBasic basic) {
this.basic = basic;
}
public ReqScreen getScreen() {
return screen;
}
public void setScreen(ReqScreen screen) {
this.screen = screen;
}
public ReqMedia getMedia() {
return media;
}
public void setMedia(ReqMedia media) {
this.media = media;
}
public ReqMedia getVoice() {
return voice;
}
public void setVoice(ReqMedia voice) {
this.voice = voice;
}
public ReqLocation getLocation() {
return location;
}
public void setLocation(ReqLocation location) {
this.location = location;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.context.device.basic;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqBasic implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
private String vendor;// 注册生产商ID
private String deviceType;// 该生产商设定的设备型号
private String deviceId;// 该型号下的设备ID
private String locale;// 国家及语言,标准locale格式
private Long timestamp;// 设备当前时间,unix timestamp
private String masterId;// 设备主人的Id;
private String voicetrigger;// 设备当前激活词
public String getVendor() {
return vendor;
}
public void setVendor(String vendor) {
this.vendor = vendor;
}
public String getDeviceType() {
return deviceType;
}
public void setDeviceType(String deviceType) {
this.deviceType = deviceType;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getLocale() {
return locale;
}
public void setLocale(String locale) {
this.locale = locale;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public String getMasterId() {
return masterId;
}
public void setMasterId(String masterId) {
this.masterId = masterId;
}
public String getVoicetrigger() {
return voicetrigger;
}
public void setVoicetrigger(String voicetrigger) {
this.voicetrigger = voicetrigger;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.context.device.location;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqLocation implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7136610825306612078L;
private String longitude;// 经度
private String latitude;// 纬度
private String country;// 国家
private String state;// 州/省份
private String city;// 城市
private String area;// 区县
private String district;// 地区,行政
private String street;// 街道
private String timeZone;//时区
public String getLongitude() {
return longitude;
}
public void setLongitude(String longitude) {
this.longitude = longitude;
}
public String getLatitude() {
return latitude;
}
public void setLatitude(String latitude) {
this.latitude = latitude;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getDistrict() {
return district;
}
public void setDistrict(String district) {
this.district = district;
}
public String getStreet() {
return street;
}
public void setStreet(String street) {
this.street = street;
}
public String getTimeZone() {
return timeZone;
}
public void setTimeZone(String timeZone) {
this.timeZone = timeZone;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.context.device.media;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 25/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqMedia implements Serializable {
public static final String STATE_PLAYING = "PLAYING";// 当前在播放状态
public static final String STATE_PAUSED = "PAUSED";// 当前播放器在暂停状态
public static final String STATE_IDLE = "IDLE";//当前播放器状态在闲置状态
public static final String STATE_UNKNOW = "UNKNOW";// 未知状态
/**
*
*/
private static final long serialVersionUID = -6588484011026696932L;
private String state;// PLAYING PAUSED IDLE
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public boolean isPlaying() {
return STATE_PLAYING.equals(state);
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.context.device.screen;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 25/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqScreen implements Serializable {
/**
*
*/
private static final long serialVersionUID = 3108410377906776393L;
private String x;//X 方向上的像素大小
private String y;//Y 方向上的像素大小
public String getX() {
return x;
}
public void setX(String x) {
this.x = x;
}
public String getY() {
return y;
}
public void setY(String y) {
this.y = y;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.context.user;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqUser implements Serializable {
/**
*
*/
private static final long serialVersionUID = 675958584565674347L;
private String userId;//用户ID
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.request;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.request.request.content.ReqRequestContent;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqRequestValue implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6876155972421972250L;
public static final String REQTYPE_INTENT = "INTENT";
public static final String REQTYPE_EVENT = "EVENT";
private String reqType;// 表明请求的类型: INTENT 和 EVENT 分别对应 IntentRequest 和
// EventRequest。
private String reqId;// 每次请求都会对应一个唯一ID用以区分每一次的请求。请求ID将会与返回ID一一对应。
private ReqRequestContent content;// IntentRequest 或 EventRequest的对象
public String getReqType() {
return reqType;
}
public void setReqType(String reqType) {
this.reqType = reqType;
}
public String getReqId() {
return reqId;
}
public void setReqId(String reqId) {
this.reqId = reqId;
}
public ReqRequestContent getContent() {
return content;
}
public void setContent(ReqRequestContent content) {
this.content = content;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.content;
import java.io.Serializable;
import java.util.HashMap;
import ai.qiwu.rokid.ruoqi.model.request.request.content.extra.ReqEventExtra;
import ai.qiwu.rokid.ruoqi.model.request.request.content.slot.Slot;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqRequestContent implements Serializable {
/**
*
*/
private static final long serialVersionUID = -8296524576831663917L;
/**
* @see ai.qiwu.rokid.ruoqi.model.request.request.content.enums
*/
private String intent;// IntentRequest,CloudApp 对应的 nlp intent
private HashMap<String, Slot> slots;
private String sentence;// asr 语音内容
/**
* @see ai.qiwu.rokid.ruoqi.model.request.request.content.enums
*/
private String event; // EventRequest,事件类型
private ReqEventExtra extra;// EventRequest
public String getIntent() {
return intent;
}
public void setIntent(String intent) {
this.intent = intent;
}
public HashMap<String, Slot> getSlots() {
return slots;
}
public void setSlots(HashMap<String, Slot> slots) {
this.slots = slots;
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public ReqEventExtra getExtra() {
return extra;
}
public void setExtra(ReqEventExtra extra) {
this.extra = extra;
}
public String getSentence() {
return sentence;
}
public void setSentence(String sentence) {
this.sentence = sentence;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.content.enums;
import org.apache.commons.lang.StringUtils;
public enum RokidEventCommonEnums {
// EVENT
SKILL_EXIT_EVENT("Skill.EXIT", "skillSuspendEvent", "EventRequest,event=Skill.EXIT"), // 当应用挂起的时候 TODO 需要修改名字
SKILL_SUSPEND_EVENT("Skill.SUSPEND", "skillSuspendEvent", "EventRequest,event=Skill.SUSPEND"), // 当应用挂起的时候的事件
SESSION_ENDED_EVENT("Session.ENDED", "sessionEndedEvent", "EventRequest,event=Session.ENDED");// 当Domain被切换到的时候的事件,可以用于关闭资源
private String event;
private String methodName;
private String cnHit; // 中文提示,仅作阅读代码的提示。
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public String getCnHit() {
return cnHit;
}
public void setCnHit(String cnHit) {
this.cnHit = cnHit;
}
RokidEventCommonEnums(String event, String methodName, String cnHit) {
this.event = event;
this.methodName = methodName;
this.cnHit = cnHit;
}
public static RokidEventCommonEnums convert(String event) {
for (RokidEventCommonEnums v : RokidEventCommonEnums.values()) {
if (StringUtils.equals(v.event, event)) {
return v;
}
}
return null;
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.content.enums;
import org.apache.commons.lang.StringUtils;
public enum RokidEventMediaEnums {
// EVENT
MEDIA_STARTED_EVENT("Media.STARTED", "mediaStartedEvent", "EventRequest,event=Media.STARTED"), // 当MediaPlayer开始播放时发生。
MEDIA_FAILED_EVENT("Media.FAILED", "mediaFailedEvent", "EventRequest,event=Media.FAILED"), // 当MediaPlayer播放失败时发生。
MEDIA_PAUSED_EVENT("Media.PAUSED", "mediaPausedEvent", "EventRequest,event=Media.PAUSED"), // 当MediaPlayer中途停止时发生。
MEDIA_FINISHED_EVENT("Media.FINISHED", "mediaFinishedEvent", "EventRequest,event=Media.FINISHED");// 当播放内容结束时发生。
private String event;
private String methodName;
private String cnHit; // 中文提示,仅作阅读代码的提示。
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public String getCnHit() {
return cnHit;
}
public void setCnHit(String cnHit) {
this.cnHit = cnHit;
}
RokidEventMediaEnums(String event, String methodName, String cnHit) {
this.event = event;
this.methodName = methodName;
this.cnHit = cnHit;
}
public static RokidEventMediaEnums convert(String event) {
for (RokidEventMediaEnums v : RokidEventMediaEnums.values()) {
if (StringUtils.equals(v.event, event)) {
return v;
}
}
return null;
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.content.enums;
import org.apache.commons.lang.StringUtils;
public enum RokidEventVoiceEnums {
// EVENT
VOICE_STARTED_EVENT("Voice.STARTED", "voiceStartedEvent", "EventRequest,event=Voice.STARTED"), // 当Voice开始播放时发生。
VOICE_FAILED_EVENT("Voice.FAILED", "voiceFailedEvent", "EventRequest,event=Voice.FAILED"), // 当Voice播放失败时发生。
VOICE_FINISHED_EVENT("Voice.FINISHED", "voiceFinishedEvent", "EventRequest,event=Voice.FINISHED"); // 当Voice播放内容结束时发生。
private String event;
private String methodName;
private String cnHit; // 中文提示,仅作阅读代码的提示。
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public String getCnHit() {
return cnHit;
}
public void setCnHit(String cnHit) {
this.cnHit = cnHit;
}
RokidEventVoiceEnums(String event, String methodName, String cnHit) {
this.event = event;
this.methodName = methodName;
this.cnHit = cnHit;
}
public static RokidEventVoiceEnums convert(String event) {
for (RokidEventVoiceEnums v : RokidEventVoiceEnums.values()) {
if (StringUtils.equals(v.event, event)) {
return v;
}
}
return null;
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.content.enums;
import org.apache.commons.lang.StringUtils;
/**
* 系统级的Intent事件
*
* @author Bassam
*
*/
public enum RokidIntentCommonEnums {
WELECOME_INTENT("ROKID.INTENT.WELCOME", "appStartIntent", "打开应用事件"), // 通过激活词打开应用时会发送这个Intent
UNKONWN_INTENT("ROKID.INTENT.UNKNOWN", "unkonwnIntent", "未知意图的Intent事件"), // 未知意图的Intent事件,当Skill开启PickUp以后,用户三次处理都出错,会命中该Intent
EXIT_INTENT("ROKID.INTENT.EXIT", "appStopIntent", "退出应用事件");// Skill退出请求
private String intent;
private String methodName;
private String cnHit; // 中文提示,仅作阅读代码的提示。
public String getIntent() {
return intent;
}
public void setIntent(String intent) {
this.intent = intent;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public String getCnHit() {
return cnHit;
}
public void setCnHit(String cnHit) {
this.cnHit = cnHit;
}
RokidIntentCommonEnums(String intent, String methodName, String cnHit) {
this.intent = intent;
this.methodName = methodName;
this.cnHit = cnHit;
}
public static RokidIntentCommonEnums convert(String intent) {
for (RokidIntentCommonEnums v : RokidIntentCommonEnums.values()) {
if (StringUtils.equals(v.intent, intent)) {
return v;
}
}
return null;
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.content.enums;
import org.apache.commons.lang.StringUtils;
/**
* 系统级的Intent事件
*
* @author Bassam
*
*/
public enum RokidIntentMediaEnums {
RESUME_INTENT("ROKID.INTENT.AUDIO_RESUME", "resumeIntent", "继续播放事件"),
PAUSE_INTENT("ROKID.INTENT.AUDIO_PAUSE", "pauseIntent", "暂停播放事件"),
STOP_INTENT("ROKID.INTENT.AUDIO_CANCEL", "stopIntent", "取消播放事件"),
LOOP_INTENT("ROKID.INTENT.AUDIO_LOOPON", "loopIntent", "循环播放事件"),
LOOPOFF_INTENT("ROKID.INTENT.AUDIO_LOOPOFF", "loopOffIntent", "取消循环播放事件"),
NEXT_INTENT("ROKID.INTENT.AUDIO_NEXT", "nextIntent", "下一首播放事件"),
PREVIOUS_INTENT("ROKID.INTENT.AUDIO_PREVIOUS", "previousIntent", "上一首播放事件"),
REPEAT_INTENT("ROKID.INTENT.AUDIO_REPEAT", "repeatIntent", "重复播放事件"),
STARTOVER_INTENT("ROKID.INTENT.AUDIO_STARTOVER", "startOverIntent", "重新播放事件"),
SHUFFLE_INTENT("ROKID.INTENT.AUDIO_SHUFFLEON", "shuffleIntent", "随机播放事件"),
SHUFFLEOFF_INTENT("ROKID.INTENT.AUDIO_SHUFFLEOFF", "shuffleOffIntent", "关闭随机播放事件");
private String intent;
private String methodName;
private String cnHit; // 中文提示,仅作阅读代码的提示。
public String getIntent() {
return intent;
}
public void setIntent(String intent) {
this.intent = intent;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
public String getCnHit() {
return cnHit;
}
public void setCnHit(String cnHit) {
this.cnHit = cnHit;
}
RokidIntentMediaEnums(String intent, String methodName, String cnHit) {
this.intent = intent;
this.methodName = methodName;
this.cnHit = cnHit;
}
public static RokidIntentMediaEnums convert(String intent) {
for (RokidIntentMediaEnums v : RokidIntentMediaEnums.values()) {
if (StringUtils.equals(v.intent, intent)) {
return v;
}
}
return null;
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.content.extra;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.request.request.content.extra.media.ReqExtraMedia;
import ai.qiwu.rokid.ruoqi.model.request.request.content.extra.voice.ReqExtraVoice;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqEventExtra implements Serializable {
/**
*
*/
private static final long serialVersionUID = -6312382694862019116L;
private ReqExtraMedia media;
private ReqExtraVoice voice;
public ReqExtraMedia getMedia() {
return media;
}
public void setMedia(ReqExtraMedia media) {
this.media = media;
}
public ReqExtraVoice getVoice() {
return voice;
}
public void setVoice(ReqExtraVoice voice) {
this.voice = voice;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.content.extra.media;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqExtraMedia implements Serializable {
/**
*
*/
private static final long serialVersionUID = -4201471138232339064L;
private String itemId;
private String token;
private String progress;
private String duration;
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getProgress() {
return progress;
}
public void setProgress(String progress) {
this.progress = progress;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.content.extra.voice;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqExtraVoice implements Serializable {
/**
*
*/
private static final long serialVersionUID = 4975096988067404659L;
private String itemId;
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.content.slot;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class Slot implements Serializable {
/**
*
*/
private static final long serialVersionUID = 8124321322315914064L;
private String type;
private String value;
public String getType() {
return type;
}
public String getValue() {
return value;
}
public void setType(String type) {
this.type = type;
}
public void setValue(String value) {
this.value = value;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.request.request.enums;
import org.apache.commons.lang.StringUtils;
/**
* 请求类型
*
* @author Bassam
*
*/
public enum RokidRequestTypeEnums {
EVENT_REQUEST("EVENT", "事件类型"), // 通过激活词打开应用时会发送这个Intent
INTENT_REQUEST("INTENT", "语音请求类型");
private String type;
private String cnHit; // 中文提示,仅作阅读代码的提示。
public String getCnHit() {
return cnHit;
}
public void setCnHit(String cnHit) {
this.cnHit = cnHit;
}
RokidRequestTypeEnums(String type, String cnHit) {
this.type = type;
this.cnHit = cnHit;
}
public static RokidRequestTypeEnums convert(String type) {
for (RokidRequestTypeEnums v : RokidRequestTypeEnums.values()) {
if (StringUtils.equals(v.type, type)) {
return v;
}
}
return null;
}
}
package ai.qiwu.rokid.ruoqi.model.request.session;
import java.io.Serializable;
import java.util.HashMap;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ReqSession implements Serializable {
/**
*
*/
private static final long serialVersionUID = -845013936250311340L;
private String sessionId;//每次会话的唯一ID,由系统填充
private boolean newSession;//是否是新会话
private HashMap<String, Object> attributes;//为CloudApp提供attributes字段留保存上下文信息的字段
public String getSessionId() {
return sessionId;
}
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
public boolean isNewSession() {
return newSession;
}
public void setNewSession(boolean newSession) {
this.newSession = newSession;
}
public HashMap<String, Object> getAttributes() {
return attributes;
}
public void setAttributes(HashMap<String, Object> attributes) {
this.attributes = attributes;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.response.response.ResResponseContent;
import ai.qiwu.rokid.ruoqi.model.response.session.ResSession;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResResponse implements Serializable {
public static final String RES_VERSION_V2 = "2.0.0";// 协议版本
/**
*
*/
private static final long serialVersionUID = -4299224159622592090L;
private String version;// 表明了Response协议的版本,必须由 CloudApp 填充。当前协议版本是 2.0.0.
private ResSession session;// 表示当前应用的session,与Request中的信息一致,CloudApp 可以在
// attributes 里填充自己需要的上下文信息用于后面的请求。
private ResResponseContent response;// 返回给 CloudAppClient 的Response内容。包括了
// card 和 action 两个部分。card
// 会在之后的协议更新中作详细说明。
public ResResponse() {
ResSession resSession = new ResSession();
this.session = resSession;
ResResponseContent resResponseContent = new ResResponseContent();
this.response = resResponseContent;
}
public ResResponse(String resVersion) {
this();
this.version = resVersion;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public ResSession getSession() {
return session;
}
public void setSession(ResSession session) {
this.session = session;
}
public ResResponseContent getResponse() {
return response;
}
public void setResponse(ResResponseContent response) {
this.response = response;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.response.response.action.ResAction;
import ai.qiwu.rokid.ruoqi.model.response.response.card.ResCard;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResResponseContent implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1480333446516655906L;
private ResCard card;
private ResAction action;//voice 和 media。voice 表示了语音交互的返回。media 是对媒体播放的返回。
public ResCard getCard() {
return card;
}
public void setCard(ResCard card) {
this.card = card;
}
public ResAction getAction() {
return action;
}
public void setAction(ResAction action) {
this.action = action;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.action;
import java.io.Serializable;
import java.util.List;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.ResDirective;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResAction implements Serializable {
/**
*
*/
private static final long serialVersionUID = 8270863105569783649L;
public static final String ACTION_TYPE_NORMAL = "NORMAL";
public static final String ACTION_TYPE_EXIT = "EXIT";
public static final String ACTION_VERSION_V2 = "2.0.0";// 协议版本
private String version;// "version": "2.0.0",
private String type;// 当前action的类型:NORMAL 或 EXIT。 当 type 是 NORMAL 时,voice 和
// media 会同时执行;当 type 是 EXIT
// 时,action会立即退出,并且在这种情况下,voice 和 media 将会被会被忽略
private String form;// 当前action的展现形式:scene、cut、service。scene的action会在被打断后压栈,cut的action会在被打断后直接结束,service会在后台执行,但没有任何界面。该字段在技能创建时被确定,无法由cloud
// app更改。
private boolean shouldEndSession;// 表明当此次返回的action执行完后 CloudAppClient
// 是否要退出,同时,当 shouldEndSession 为 true
// 时,CloudAppClient 将会忽略
// EventRequests,即在action执行过程中不会产生
// EventRequest。
private List<ResDirective> directives;// 行为操作
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getForm() {
return form;
}
public void setForm(String form) {
this.form = form;
}
public boolean isShouldEndSession() {
return shouldEndSession;
}
public void setShouldEndSession(boolean shouldEndSession) {
this.shouldEndSession = shouldEndSession;
}
public List<ResDirective> getDirectives() {
return directives;
}
public void setDirectives(List<ResDirective> directives) {
this.directives = directives;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.action.directive;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public abstract class ResDirective implements Serializable{
/**
*
*/
private static final long serialVersionUID = -4528558462654915554L;
private String type;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.action.directive.confirm;
import java.io.Serializable;
import java.util.List;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.ResDirective;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 25/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResConfirm extends ResDirective implements Serializable {
public ResConfirm() {
setType("confirm");
}
/**
*
*/
private static final long serialVersionUID = 8416039262704445675L;
private String confirmIntent;
private String confirmSlot;
private List<String> optionWords;
public String getConfirmIntent() {
return confirmIntent;
}
public void setConfirmIntent(String confirmIntent) {
this.confirmIntent = confirmIntent;
}
public String getConfirmSlot() {
return confirmSlot;
}
public void setConfirmSlot(String confirmSlot) {
this.confirmSlot = confirmSlot;
}
public List<String> getOptionWords() {
return optionWords;
}
public void setOptionWords(List<String> optionWords) {
this.optionWords = optionWords;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.action.directive.display;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.ResDirective;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 25/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResDisplay extends ResDirective implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2540353337364483125L;
private String action;
private boolean needEventCallback;
private long duration;
public ResDisplay() {
setType("display");
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public boolean isNeedEventCallback() {
return needEventCallback;
}
public void setNeedEventCallback(boolean needEventCallback) {
this.needEventCallback = needEventCallback;
}
public long getDuration() {
return duration;
}
public void setDuration(long duration) {
this.duration = duration;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.action.directive.media;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.ResDirective;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.media.mediaitem.ResMediaItem;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 25/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResMedia extends ResDirective implements Serializable {
public static final String MEDIA_ACTION_PLAY = "PLAY";// 从头开始播放操作,最好带上MediaItem,否则一旦设备那边没有Item,则会出错
public static final String MEDIA_ACTION_PAUSE = "PAUSE";// 暂停播放操作,暂停当前的Media播放
public static final String MEDIA_ACTION_RESUME = "RESUME";// 继续播放操作,继续当前的播放,需要注意的是客户端那边必须要有MediaItem,否则会出错(可以校验一下当前的Media状态是否是PAUSE的状态)
public static final String MEDIA_ACTION_STOP = "STOP";// 停止播放操作,停止当前的Media播放
/**
*
*/
private static final long serialVersionUID = -8814555042830620352L;
private boolean disableEvent;
private String action;
private ResMediaItem item;
public ResMedia() {
setType("media");
}
public boolean isDisableEvent() {
return disableEvent;
}
public void setDisableEvent(boolean disableEvent) {
this.disableEvent = disableEvent;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public ResMediaItem getItem() {
return item;
}
public void setItem(ResMediaItem item) {
this.item = item;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.action.directive.media.mediaitem;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 25/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResMediaItem implements Serializable {
public static String MEDIA_TYPE_AUDIO = "AUDIO";
public static String MEDIA_TYPE_VIDEO = "VIDEO";
/**
*
*/
private static final long serialVersionUID = -5505517316901645087L;
private String itemId;
private String token;
private String type;
private String url;
private Long offsetInMilliseconds;
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public Long getOffsetInMilliseconds() {
return offsetInMilliseconds;
}
public void setOffsetInMilliseconds(Long offsetInMilliseconds) {
this.offsetInMilliseconds = offsetInMilliseconds;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.action.directive.pickup;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.ResDirective;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResPickup extends ResDirective implements Serializable {
/**
*
*/
private static final long serialVersionUID = -1498955831240619651L;
private boolean enable;
private Long durationInMilliseconds;
private String retryTts;// 重试一次的TTS
public ResPickup() {
setType("pickup");
}
public boolean isEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
public Long getDurationInMilliseconds() {
return durationInMilliseconds;
}
public void setDurationInMilliseconds(Long durationInMilliseconds) {
this.durationInMilliseconds = durationInMilliseconds;
}
public String getRetryTts() {
return retryTts;
}
public void setRetryTts(String retryTts) {
this.retryTts = retryTts;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.action.directive.voice;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.ResDirective;
import ai.qiwu.rokid.ruoqi.model.response.response.action.directive.voice.item.ResVoiceItem;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 25/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResVoice extends ResDirective implements Serializable {
public static final String VOICE_ACTION_PLAY = "PLAY";// 从头开始播放操作,最好带上VoiceItem,否则一旦设备那边没有Item,则会出错
public static final String VOICE_ACTION_PAUSE = "PAUSE";// 暂停播放操作,暂停当前的Voice播放
public static final String VOICE_ACTION_RESUME = "RESUME";// 继续播放操作,继续当前的播放,需要注意的是客户端那边必须要有VoiceItem,否则会出错(可以校验一下当前的Voice状态是否是PAUSE的状态)
public static final String VOICE_ACTION_STOP = "STOP";// 停止播放操作,停止当前的VOICE播放
/**
*
*/
private static final long serialVersionUID = -5413825634268582630L;
private boolean disableEvent;
private String action;// 播放控制操作 "PLAY/PAUSE/RESUME/STOP"
private ResVoiceItem item;// tts 内容
public ResVoice() {
setType("voice");
}
public boolean isDisableEvent() {
return disableEvent;
}
public void setDisableEvent(boolean disableEvent) {
this.disableEvent = disableEvent;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public ResVoiceItem getItem() {
return item;
}
public void setItem(ResVoiceItem item) {
this.item = item;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.action.directive.voice.item;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 25/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResVoiceItem implements Serializable {
/**
*
*/
private static final long serialVersionUID = -2690547231606519182L;
private String itemId;
private String tts;
public String getItemId() {
return itemId;
}
public void setItemId(String itemId) {
this.itemId = itemId;
}
public String getTts() {
return tts;
}
public void setTts(String tts) {
this.tts = tts;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.card;
import java.io.Serializable;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 25/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResCard implements Serializable {
/**
*
*/
private static final long serialVersionUID = -7191961608130764058L;
private String version;
private String type;
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.model.response.response.card.chat;
import java.io.Serializable;
import ai.qiwu.rokid.ruoqi.model.response.response.card.ResCard;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResChatCard extends ResCard implements Serializable {
private static final String CARD_TYPE = "chat";
/**
*
*/
private static final long serialVersionUID = -5802546637629946742L;
public ResChatCard() {
setType(CARD_TYPE);
}
public ResChatCard(String tts) {
setType(CARD_TYPE);
setContent(getTTSContent(tts));
}
private String content;
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
private String getTTSContent(String tts) {
return tts.replaceAll("<[^>]*>", "").replaceAll("\\[[^]]*\\]", "");
}
}
package ai.qiwu.rokid.ruoqi.model.response.session;
import java.io.Serializable;
import java.util.HashMap;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
/**
* Created by Bassam on 15/03/2017.
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class ResSession implements Serializable {
/**
*
*/
private static final long serialVersionUID = -716289067923877883L;
private HashMap<String, Object> attributes;
public HashMap<String, Object> getAttributes() {
return attributes;
}
public void setAttributes(HashMap<String, Object> attributes) {
this.attributes = attributes;
}
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
package ai.qiwu.rokid.ruoqi.service;
import ai.qiwu.rokid.ruoqi.common.Constants;
import ai.qiwu.rokid.ruoqi.common.exception.RokidException;
import ai.qiwu.rokid.ruoqi.common.utils.ProtocolUtils;
import ai.qiwu.rokid.ruoqi.model.request.ReqRequest;
import ai.qiwu.rokid.ruoqi.model.response.ResResponse;
import ai.qiwu.rokid.ruoqi.model.response.response.action.ResAction;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.HashMap;
/**
* @author 苗权威
* @dateTime 19-7-2 下午7:27
*/
@Service("requestParse")
public class RokidRequestParse {
private static final Logger logger = LoggerFactory.getLogger(RokidRequestParse.class);
public ResResponse getResponse(ReqRequest request) {
String userWord = request.getRequest().getContent().getSentence();
String userId = request.getContext().getUser().getUserId();
try {
return requestTerminate(userWord, userId);
} catch (RokidException e) {
logger.info("出错:"+e.toString());
return ProtocolUtils.igonre();
}
}
private ResResponse requestTerminate(String word, String userId) throws RokidException {
String audioUrl = "";
String textContent = "请说推荐作品";
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(Constants.QI_WU_INTERFACE);
HashMap<String, String> params = new HashMap<>();
params.put("user_id", String.valueOf(userId));
params.put("text", word);
params.put("access",Constants.SERVICE_NAME);
String paramsJsonFormat = JSON.toJSONString(params);
StringEntity body = new StringEntity(paramsJsonFormat, "UTF-8");
post.setHeader("Content-Type", "application/json;charset=utf-8");
post.setEntity(body);
httpResponse = httpClient.execute(post);
HttpEntity responseBody = httpResponse.getEntity();
if (responseBody != null) {
String responseContent = EntityUtils.toString(responseBody);
logger.info("齐悟接口返回: "+ responseContent);
JSONObject responseJsonFormat = JSONObject.parseObject(responseContent);
audioUrl = (String) responseJsonFormat.get("audio");
textContent = (String) responseJsonFormat.get("text");
}
} catch (IOException e) {
logger.error("请求齐悟接口出错:"+e.toString());
return null;
} finally {
try {
if (httpClient != null) httpClient.close();
if (httpResponse != null) httpResponse.close();
} catch (IOException e) {
logger.error("关闭与齐悟接口时出错:"+e.toString());
}
}
return addUrlAndText(audioUrl, textContent);
}
private ResResponse addUrlAndText(String url, String text) throws RokidException {
return buildResponse(text);
}
private ResResponse buildResponse(String text) throws RokidException {
return ProtocolUtils.pickUp(text);
}
}
......@@ -11,6 +11,7 @@
<groupId>ai.qiwu.tmall</groupId>
<artifactId>spirit</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>spirit</name>
<description>Tmall spirit project</description>
......@@ -22,6 +23,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
......@@ -29,13 +36,78 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.tmall.spirit</groupId>
<artifactId>tmall-sdk</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/aliGenie-intent-sematic.jar</systemPath>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.8</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>18.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<!--添加servlet-api的依赖,用来打war包 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>Spirit</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
<compilerArguments>
<extdirs>${project.basedir}/src/main/resources/lib</extdirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<webResources>
<resource>
<directory>${project.basedir}/src/main/resources/lib</directory>
<targetPath>WEB-INF/lib</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
......
......@@ -2,12 +2,18 @@ package ai.qiwu.tmall.spirit;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class SpiritApplication {
public class SpiritApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SpiritApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(SpiritApplication.class);
}
}
package ai.qiwu.tmall.spirit.controller;
import ai.qiwu.tmall.spirit.service.SpiritService;
import com.alibaba.da.coin.ide.spi.standard.ResultModel;
import com.alibaba.da.coin.ide.spi.standard.TaskQuery;
import com.alibaba.da.coin.ide.spi.standard.TaskResult;
import com.alibaba.da.coin.ide.spi.trans.MetaFormat;
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;
/**
* 天猫自定义技能里Webhook中URL,假如填写的是http://test.com/spirit,
* 他会访问这里,并将请求参数映射到taskQuery上.关于证书的访问,
* 以上面URL为例天猫会访问http://test.com/aligenie/xxx.file,
* 这里我们将xxx.file放到了resources/aligenie下
* @author 苗权威
* @dateTime 2019/6/18
*/
@RestController
public class SpiritController {
/**
* slf4j打印日志信息
*/
private static final Logger logger = LoggerFactory.getLogger(SpiritController.class);
/**
* 解析请求信息的实现类
*/
@Autowired
private SpiritService spiritService;
/**
* 利用天猫精灵打开发包解析请求并从构造响应数据返回
* @param taskQuery 请求的参数信息
* @return 返回响应的JSON数据
*/
@RequestMapping(value = "/spirit")
public @ResponseBody ResultModel<TaskResult> getResponse(@RequestBody String taskQuery) {
logger.info("TaskQuery:{}",taskQuery);
TaskQuery query = MetaFormat.parseToQuery(taskQuery);
// build response
ResultModel<TaskResult> resultModel = new ResultModel<>();
TaskResult taskResult = spiritService.getResponse(query);
logger.info("taskResult:"+taskResult);
resultModel.setReturnCode("0");
resultModel.setReturnValue(taskResult);
return resultModel;
}
}
package ai.qiwu.tmall.spirit.service;
import com.alibaba.da.coin.ide.spi.meta.AskedInfoMsg;
import com.alibaba.da.coin.ide.spi.meta.ExecuteCode;
import com.alibaba.da.coin.ide.spi.meta.ResultType;
import com.alibaba.da.coin.ide.spi.standard.TaskQuery;
import com.alibaba.da.coin.ide.spi.standard.TaskResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
/**
* 解析请求参数,构造向终端接口发送打数据打JSON,之后得到响应数据,提取构造返回给天猫的响应数据
* @author 苗权威
* @dateTime 2019/6/18
*/
@Service
public class SpiritService {
/**
* org.slf4j.Logger打印日志信息
*/
private static final Logger logger = LoggerFactory.getLogger(SpiritService.class);
/**
* 获取返回给天猫的数据
* @param request 请求参数
* @return 返回数据封装在开发包中的TaskResult
*/
public TaskResult getResponse(TaskQuery request) {
return getNeededParam(request);
}
/**
* 解析获取需要的参数信息:用户的话,用户的id,意图id
* @param request 请求参数
* @return 返回数据封装在开发包中的TaskResult
*/
private TaskResult getNeededParam(TaskQuery request) {
Long userId = request.getBotId();
String userWord = request.getUtterance();
logger.info("The customer say:"+userWord);
Long intentId = request.getIntentId();
return postToQiWuInterface(userId, userWord, intentId);
}
/**
* 向接口公司的接口发送数据:user_id 包括用户id, text TTS文本内容,access 来源标识
* 获取返回:audio 音频链接,text TTS文本内容
* @param userId 用户id
* @param userWord TTS文本内容
* @param intentId 意图id
* @return 返回数据封装在开发包中的TaskResult
*/
private TaskResult postToQiWuInterface(Long userId, String userWord, Long intentId) {
String audioUrl = "";
String textContent = "请说推荐作品";
CloseableHttpClient httpClient = null;
CloseableHttpResponse response = null;
try {
httpClient = HttpClientBuilder.create().build();
HttpPost post = new HttpPost("http://aliyun-hz1.chewrobot.com:8070/api/chat");
HashMap<String, String> params = new HashMap<>();
params.put("user_id", String.valueOf(userId));
params.put("text", userWord);
params.put("access","TIANMAO");
String paramsJsonFormat = JSON.toJSONString(params);
StringEntity body = new StringEntity(paramsJsonFormat, "UTF-8");
post.setHeader("Content-Type", "application/json;charset=utf-8");
post.setEntity(body);
response = httpClient.execute(post);
HttpEntity responseBody = response.getEntity();
if (responseBody != null) {
String responseContent = EntityUtils.toString(responseBody);
logger.info("齐悟接口返回: "+ responseContent);
JSONObject responseJsonFormat = JSONObject.parseObject(responseContent);
audioUrl = (String) responseJsonFormat.get("audio");
textContent = (String) responseJsonFormat.get("text");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (httpClient != null) httpClient.close();
if (response != null) response.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return buildTaskResult(audioUrl, textContent, intentId);
}
/**
* 封装返回数据在TaskResult中
* @param audio 音频链接
* @param text TTS文本内容
* @param intentId 意图id
* @return 返回数据封装在开发包中的TaskResult
*/
private TaskResult buildTaskResult(String audio, String text, Long intentId) {
TaskResult result = new TaskResult();
result.setReply(text);
result.setResultType(ResultType.ASK_INF);
result.setExecuteCode(ExecuteCode.SUCCESS);
AskedInfoMsg askedInfoMsg = new AskedInfoMsg("any", intentId);
ArrayList<AskedInfoMsg> listInfo = new ArrayList<>();
listInfo.add(askedInfoMsg);
result.setAskedInfos(listInfo);
// List<Action> actions = new ArrayList<>();
// Action action = new Action("audioPlayGenieSource");
// //action.addProperty("audioGenieId", "21441");
// action.addProperty("audioGenieId", audio);
// actions.add(action);
// result.setActions(actions);
return result;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--控制台日志输出配置-->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!--对输出日志进行格式化-->
<encoder>
<!-- %d日期,%p日志级别,%file文件名,%line所在行数,%m输出的信息,%n换行 -->
<pattern>%d %p (%file:%line\)- %m%n</pattern>
<!--字符编码-->
<charset>UTF-8</charset><!--此处设置字符集-->
</encoder>
</appender>
<!--指定日志输出等级-->
<root level="info">
<appender-ref ref="STDOUT" />
</root>
<!--上述配置表名将 >=info级别的日志都输出到控制台-->
<!--日志文件配置-->
<appender name="spiritLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--被写入的文件名,可以是相对目录,也可以是绝对目录,如果上级目录不存在会自动创建,没有默认值。-->
<File>/usr/mqw/logs/spirit/</File>
<!--滚动记录文件:根据时间来制定滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/usr/mqw/logs/spirit/base.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="qi.qiwu.tmall" level="DEBUG">
<appender-ref ref="spiritLog" />
</logger>
</configuration>
\ No newline at end of file
Jfc4Z4Ur15JwUBuvUQD5wg7Nu8+l+HscqYlfofbyJdYGH+f3XrduI0FLgVW7gXyV
\ No newline at end of file
......@@ -29,6 +29,24 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.8</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
......
package ai.qiwu.mi.xiaoai.commons;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.util.Objects;
/**
* @author 苗权威
* @dateTime 19-7-6 上午11:16
*/
public class Utils {
public static HttpServletRequest getHttpServletRequest() {
return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder
.getRequestAttributes())).getRequest();
}
public static String useIPAsItsID() {
HttpServletRequest request = getHttpServletRequest();
String ip = request.getHeader("x-forwarded-for");
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getHeader("WL-Proxy-Client-IP");
}
if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
ip = request.getRemoteAddr();
}
return ip;
}
}
package ai.qiwu.mi.xiaoai.commons;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:56
*/
public interface XiaoAiConstants {
String QI_WU_TERMINATE = "http://aliyun-hz1.chewrobot.com:8070/api/chat";
String DEVICE_NAME = "XIAOAI";
String CONTENT_TYPE = "application/json;charset=utf-8";
String PLAYBACK_NEARLY_FINISHED = "mediaplayer.playbacknearlyfinished";
interface ERROR_MSG {
String SORRY_REPEAT = "不好意思,请再说一边吧";
String TERMINATE_IO_EXCEPTION = "请求终端接口时发生IO错误";
String HTTP_CONNECTION_CLOSE_EXCEPTION = "关闭与终端接口链接时出错";
}
interface TTS {
String WELCOME_WORD = "欢迎来到互动天地,请说推荐作品";
String END_BYE = "我们的作品库在不断扩充,下次会有更大的惊喜哦";
String END_WORD = "退出";
String USER_IDLE = "小悟在等你的回复哦";
}
}
package ai.qiwu.mi.xiaoai.controller;
import ai.qiwu.mi.xiaoai.model.request.XiaoAiRequest;
import ai.qiwu.mi.xiaoai.model.response.XiaoAiResponse;
import ai.qiwu.mi.xiaoai.service.XiaoAiService;
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;
/**
* @author 苗权威
* @dateTime 19-7-6 上午11:36
*/
@RestController
public class XiaoAiController {
@Autowired
private XiaoAiService xiaoAiService;
@RequestMapping("/xiaoai")
public @ResponseBody XiaoAiResponse xiaoai(@RequestBody XiaoAiRequest request) {
return xiaoAiService.getResponse(request);
}
}
package ai.qiwu.mi.xiaoai.model.request;
import ai.qiwu.mi.xiaoai.model.request.context.Context;
import ai.qiwu.mi.xiaoai.model.request.innerRequest.Request;
import ai.qiwu.mi.xiaoai.model.request.session.Session;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:10
*/
@Getter
@Setter
@ToString
public class XiaoAiRequest {
private String version;
private String query;
private Session session;
private Context context;
private Request request;
}
package ai.qiwu.mi.xiaoai.model.request.context;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:21
*/
@Getter
@Setter
@ToString
public class ClientAppInfo {
private String pkg_name;
private String version_name;
}
package ai.qiwu.mi.xiaoai.model.request.context;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:20
*/
@Getter
@Setter
@ToString
public class Context {
private String device_id;
private String passport;
private List<ClientAppInfo> app_info;
}
package ai.qiwu.mi.xiaoai.model.request.innerRequest;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:24
*/
@Getter
@Setter
@ToString
public class EventProperty {
private String asr_text;
private String msg_file_id;
}
package ai.qiwu.mi.xiaoai.model.request.innerRequest;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:23
*/
@Getter
@Setter
@ToString
public class Request {
private int type;
private String request_id;
private Long timestamp;
private Boolean no_response;
private String event_type;
private EventProperty event_property;
private String Locale;
private SlotInfo slot_info;
}
package ai.qiwu.mi.xiaoai.model.request.innerRequest;
import ai.qiwu.mi.xiaoai.model.request.innerRequest.slot.Slot;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:26
*/
@Getter
@Setter
@ToString
public class SlotInfo {
private String intent_name;
private boolean is_confirmed;
private List<Slot> slots;
}
package ai.qiwu.mi.xiaoai.model.request.innerRequest.slot;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:27
*/
@Getter
@Setter
@ToString
public class Slot {
private String name;
private String value;
private boolean is_inquire_failed;
}
package ai.qiwu.mi.xiaoai.model.request.session;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:16
*/
@Getter
@Setter
@ToString
public class Application {
private String app_id;
}
package ai.qiwu.mi.xiaoai.model.request.session;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Map;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:15
*/
@Getter
@Setter
@ToString
public class Session {
private String session_id;
private Application application;
private Map<String, String> attributes;
private User user;
}
package ai.qiwu.mi.xiaoai.model.request.session;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:16
*/
@Getter
@Setter
@ToString
public class User {
private String user_id;
private String access_token;
private Boolean is_user_login;
private String gender;
}
package ai.qiwu.mi.xiaoai.model.response;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.Response;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Map;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:30
*/
@Getter
@Setter
@ToString
public class XiaoAiResponse {
private String version;
private Map<String, String> session_attributes;
private Boolean is_session_end;
private Response response;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.actionProperty.ActionProperty;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.directive.Directive;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.registerEvent.RegisterEvent;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.toDisplay.ToDisplay;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.toSpeak.ToSpeak;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:31
*/
@Getter
@Setter
@ToString
public class Response {
private ToSpeak to_speak;
private ToDisplay to_display;
private List<Directive> directives;
private Boolean open_mic;
private Boolean not_understand;
private String action;
private ActionProperty action_property;
private List<RegisterEvent> register_events;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse.actionProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:47
*/
@Getter
@Setter
@ToString
public class ActionProperty {
private List<Long> file_id_list;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse.directive.AudioItem;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:41
*/
@Getter
@Setter
@ToString
public class AudioItem {
private AudioStream stream;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse.directive.AudioItem;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:42
*/
@Getter
@Setter
@ToString
public class AudioStream {
private String token;
private String url;
private Long offset_in_milliseconds;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse.directive;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.directive.AudioItem.AudioItem;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.directive.ttsItem.TTSItem;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:41
*/
@Getter
@Setter
@ToString
public class Directive {
private String type;
private AudioItem audio_item;
private TTSItem tts_item;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse.directive.ttsItem;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:44
*/
@Getter
@Setter
@ToString
public class TTSItem {
private String type;
private String text;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse.registerEvent;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:49
*/
@Getter
@Setter
@ToString
public class RegisterEvent {
private String event_name;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse.toDisplay;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.toDisplay.UITemplate.UITemplate;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:34
*/
@Getter
@Setter
@ToString
public class ToDisplay {
private int type;
private String url;
private String text;
private UITemplate ui_template;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse.toDisplay.UITemplate.Item;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:36
*/
@Getter
@Setter
@ToString
public class Item {
private String image_style;
private List<Object> images;
private String intent;
private String title;
private Object body;
private String background_image;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse.toDisplay.UITemplate;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.toDisplay.UITemplate.Item.Item;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:35
*/
@Getter
@Setter
@ToString
public class UITemplate {
private int type;
private List<Item> items;
private String logo;
private Item item;
}
package ai.qiwu.mi.xiaoai.model.response.innerResponse.toSpeak;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:33
*/
@Getter
@Setter
@ToString
public class ToSpeak {
private int type;
private String text;
}
package ai.qiwu.mi.xiaoai.service;
import ai.qiwu.mi.xiaoai.commons.Utils;
import ai.qiwu.mi.xiaoai.commons.XiaoAiConstants;
import ai.qiwu.mi.xiaoai.commons.XiaoAiConstants.TTS;
import ai.qiwu.mi.xiaoai.commons.XiaoAiConstants.ERROR_MSG;
import ai.qiwu.mi.xiaoai.model.request.XiaoAiRequest;
import ai.qiwu.mi.xiaoai.model.response.XiaoAiResponse;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.Response;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.directive.AudioItem.AudioItem;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.directive.AudioItem.AudioStream;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.directive.Directive;
import ai.qiwu.mi.xiaoai.model.response.innerResponse.toSpeak.ToSpeak;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-7-5 下午8:52
*/
@Service
public class XiaoAiService {
private static final Logger logger = LoggerFactory.getLogger(XiaoAiService.class);
public XiaoAiResponse getResponse(XiaoAiRequest request) {
String userId = getUserId(request);
int type = request.getRequest().getType();
switch (type) {
case 0 : return dealWithLaunchRequest(request);
case 1 : return dealWithIntentRequest(request, userId);
case 2 : return dealWithEndRequest(userId);
default: return buildTextResponse(ERROR_MSG.SORRY_REPEAT);
}
}
private XiaoAiResponse postToQiWuInterface(String userId, String userWord) {
String audioUrl = null;
String textContent = null;
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(XiaoAiConstants.QI_WU_TERMINATE);
HashMap<String, String> params = new HashMap<>();
params.put("user_id", userId);
params.put("text", userWord);
params.put("access",XiaoAiConstants.DEVICE_NAME);
String paramsJsonFormat = JSON.toJSONString(params);
StringEntity body = new StringEntity(paramsJsonFormat, StandardCharsets.UTF_8);
post.setHeader("Content-Type", XiaoAiConstants.CONTENT_TYPE);
post.setEntity(body);
httpResponse = httpClient.execute(post);
HttpEntity responseBody = httpResponse.getEntity();
if (responseBody != null) {
String responseContent = EntityUtils.toString(responseBody);
logger.info("齐悟接口返回: "+ responseContent);
JSONObject responseJsonFormat = JSONObject.parseObject(responseContent);
audioUrl = (String) responseJsonFormat.get("audio");
textContent = (String) responseJsonFormat.get("text");
}
} catch (IOException e) {
logger.info(ERROR_MSG.TERMINATE_IO_EXCEPTION);
return buildTextResponse(ERROR_MSG.SORRY_REPEAT);
} finally {
try {
if (httpClient != null) httpClient.close();
if (httpResponse != null) httpResponse.close();
} catch (IOException e) {
logger.info(ERROR_MSG.HTTP_CONNECTION_CLOSE_EXCEPTION);
}
}
return buildAudioResponse(audioUrl);
}
private XiaoAiResponse buildResponse() {
XiaoAiResponse response = new XiaoAiResponse();
response.setVersion("1.0");
response.setIs_session_end(false);
return response;
}
private XiaoAiResponse buildAudioResponse(String audioUrl) {
XiaoAiResponse response = buildResponse();
Response responseInfo = new Response();
Directive directive = new Directive();
directive.setType("audio");
AudioItem audioItem = new AudioItem();
AudioStream audioStream = new AudioStream();
audioStream.setUrl(audioUrl);
audioItem.setStream(audioStream);
directive.setAudio_item(audioItem);
List<Directive> directives = new ArrayList<>();
directives.add(directive);
responseInfo.setDirectives(directives);
response.setResponse(responseInfo);
return response;
}
private XiaoAiResponse buildTextResponse(String text) {
XiaoAiResponse response = buildResponse();
Response responseInfo = new Response();
ToSpeak toSpeak = new ToSpeak();
toSpeak.setType(0);
toSpeak.setText(text);
responseInfo.setTo_speak(toSpeak);
response.setResponse(responseInfo);
return response;
}
private XiaoAiResponse buildOpenMicResponse() {
XiaoAiResponse response = buildResponse();
Response responseInfo = new Response();
responseInfo.setOpen_mic(true);
response.setResponse(responseInfo);
return response;
}
private XiaoAiResponse dealWithLaunchRequest(XiaoAiRequest request) {
return buildTextResponse(TTS.WELCOME_WORD);
}
private XiaoAiResponse dealWithIntentRequest(XiaoAiRequest request, String userId) {
Boolean idle = request.getRequest().getNo_response();
if (idle == null || idle) {
return buildTextResponse(TTS.USER_IDLE);
}
//String eventType = request.getRequest().getEvent_type();
// 这里是否向小度一样需要在语音播放结束后主动开麦?
// if (eventType != null && eventType.equals(XiaoAiConstants.PLAYBACK_NEARLY_FINISHED)) {
// return buildOpenMicResponse();
// }
String userWord = request.getQuery();
if (userWord == null) {
return buildTextResponse(ERROR_MSG.SORRY_REPEAT);
}
return postToQiWuInterface(userId, userWord);
}
private XiaoAiResponse dealWithEndRequest(String userId) {
postToQiWuInterface(userId, TTS.END_WORD);
return buildTextResponse(TTS.END_BYE);
}
private String getUserId(XiaoAiRequest request) {
String userId = request.getSession().getUser().getUser_id();
if (userId == null) {
userId = request.getContext().getDevice_id();
}
if (userId == null) {
userId = Utils.useIPAsItsID();
}
return userId;
}
}
......@@ -11,6 +11,7 @@
<groupId>ai.qiwu.baidu</groupId>
<artifactId>xiaodu</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>xiaodu</name>
<description>Demo project for Spring Boot</description>
......@@ -22,6 +23,20 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--添加servlet-api的依赖,用来打war包 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
......@@ -50,6 +65,7 @@
</dependencies>
<build>
<finalName>xiaodu</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
......
......@@ -2,12 +2,18 @@ package ai.qiwu.baidu.xiaodu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class XiaoduApplication {
public class XiaoduApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(XiaoduApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(XiaoduApplication.class);
}
}
......@@ -10,7 +10,7 @@ public interface Constants {
String SERVICE_NAME = "BAIDU";
interface WelcomeWord {
String WELCOME = "在这里你就是主角,开始你的星辰大海吧";
String WELCOME = "在这里你就是主角,开始你的星辰大海吧,请说推荐作品";
String BEGIN_NO_RESPONSE = "咋还没开始就停住了,我们这里可有很多好玩的作品哦";
}
......
package ai.qiwu.baidu.xiaodu.common;
import lombok.Getter;
import lombok.Setter;
import java.util.concurrent.locks.ReentrantLock;
/**
* @author 苗权威
* @dateTime 19-7-1 下午8:39
*/
@Getter
@Setter
public class Holder {
private volatile String timestamp;
private volatile String lastAudioUrl;
private final ReentrantLock FAIR_LOCK = new ReentrantLock();
private volatile int first;
}
......@@ -9,11 +9,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.IOException;
/**
* @author 苗权威
* @dateTime 19-6-29 下午5:32
* @dateTime 19-6-29 下午5:32cat
*/
@RestController
public class XiaoDuController {
......@@ -25,6 +23,7 @@ public class XiaoDuController {
try {
ResponseEncapsulation response = new ResponseEncapsulation(Utils.getHttpServletRequest());
response.enableVerify();
//response.disableVerify();
return response.run();
} catch (Exception e) {
logger.info("出现错误 "+e.toString());
......
package ai.qiwu.baidu.xiaodu.service;
import ai.qiwu.baidu.xiaodu.common.Constants;
import ai.qiwu.baidu.xiaodu.common.Constants.ErrorMsg;
import ai.qiwu.baidu.xiaodu.common.Constants.EndMsg;
import ai.qiwu.baidu.xiaodu.common.Constants.WelcomeWord;
import ai.qiwu.baidu.xiaodu.common.Holder;
import ai.qiwu.baidu.xiaodu.common.Utils;
import ai.qiwu.baidu.xiaodu.pojo.AudioUrlAndText;
import com.alibaba.fastjson.JSON;
import com.baidu.dueros.bot.AudioPlayer;
import com.baidu.dueros.data.request.IntentRequest;
import com.baidu.dueros.data.request.LaunchRequest;
import com.baidu.dueros.data.request.Query;
import com.baidu.dueros.data.request.SessionEndedRequest;
import com.baidu.dueros.data.request.audioplayer.event.PlaybackFinishedEvent;
import com.baidu.dueros.data.request.audioplayer.event.PlaybackNearlyFinishedEvent;
import com.baidu.dueros.data.request.audioplayer.event.PlaybackStoppedEvent;
import com.baidu.dueros.data.response.OutputSpeech;
import com.baidu.dueros.data.response.Reprompt;
import com.baidu.dueros.data.response.directive.audioplayer.AudioPlayerDirective;
......@@ -21,52 +27,147 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
/**
* @author 苗权威
* @dateTime 19-6-28 下午8:22
*/
@Service("service")
public class ResponseEncapsulation extends AudioPlayer {
private static final Logger logger = LoggerFactory.getLogger(ResponseEncapsulation.class);
private static final ConcurrentHashMap<String, Holder> USER_TIMESTAMP = new ConcurrentHashMap<>();
private String userId;
private static final Logger logger = LoggerFactory.getLogger(ResponseEncapsulation.class);
public ResponseEncapsulation(HttpServletRequest request) throws IOException {
super(request);
String privateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANMWIYduiQZt0B7s\n" +
"IZ6PW15gpcO7Yn+9ZbaMSHwzJqNeDAZzh6HXF7r0ZpQcw3XEWKPAPWyuJ5eqZf46\n" +
"W/NyJQkcddWrA/5OvcZw1uAmzTt8sWz1zokt2e6v6SucvvHoPxLGjfTKWh6Qr+2x\n" +
"K/5wmdOOpikL/ruH2ZviYjto2cBPAgMBAAECgYBuQCLnD8618uk/HWo53PqGAsjR\n" +
"wK+jtJLJk9/QLw9BSL/TJshyuVuFpF1ngtZ8Tj9V1/S9LQE08CUxcd3Q+49njgEq\n" +
"R60FKDjwCe8G9El5jIYIU0RTnd84I8B0RKWBO8ShZ29qWEVXOExPZc1fMlq4UgBr\n" +
"Xkfsh/E1cTfphYyS8QJBAOuX1c11XOSeDVo5KyxM26K2Kiekjm1cLIXJR54hetRN\n" +
"diCHqd5WyolKJzxFuUMEsq+sAfgd7KsrorO5hwY42lUCQQDlXt9TiIWGMt3oVEIf\n" +
"ulJQmURhkQ+Z9EC2wHnFrE3UhkCNyX3TOwTzV8bzC+Vr2hAobbhXTCr8tLGm0Yxk\n" +
"f1wTAkEAqbQtplosF+Jh6+PSXY7fh02BAB1hGxWSXKyokhe7ysIhnT0b97S9IDfy\n" +
"G1B+KvBvZmuY34luub4s7RlvUeQSIQJANaq7Cip5Q2sHbOK6Df5kYCNcUo/EXLs/\n" +
"oQLr+wpTs5Qt6n7oh9HZWK6DCD8SUOfWu/7gENzrefE1V9jTxnfeLQJBANKf4QfA\n" +
"CvwfHTyEgphcWrWDzB7bEqUDWiEjfO8sf+lwj9I0yU6fO/+aUtwU9xwkij1PscUF\n" +
"9AWUhbas+LG9mds=";
//privateKey为私钥内容,0代表你的Bot在DBP平台debug环境,1或者其他整数代表online环境,
// botMonitor对象已经在bot-sdk里初始化,可以直接调用
//this.botMonitor.setEnvironmentInfo(privateKey, 0);
//this.botMonitor.setMonitorEnabled(true);
}
@Override
public Response onInent(IntentRequest intentRequest) {
protected Response onInent(IntentRequest intentRequest) {
String userId = getCustomerId();
String timestamp = this.getRequest().getRequest().getTimestamp();
Query query = intentRequest.getQuery();
String userWord = null;
if (query != null) {
userWord = query.getOriginal();
}
if (query != null) userWord = query.getOriginal();
if (userWord == null){
logger.info("小度没有传来任何话语");
return buildErrorResponse(ErrorMsg.SORRY_UNCATCH);
}
if (userId == null) {
userId = Utils.useIPAsItsID();
Holder holder = USER_TIMESTAMP.get(userId);
ReentrantLock lock = null;
try {
lock = holder.getFAIR_LOCK();
lock.lock();
if (holder.getFirst() == 0) {
holder.setFirst(1);
Thread.sleep(60);
}
if (lock.hasQueuedThreads()) {
logger.info("由于请求间隔过短,因此认为本次请求为过于的重复请求,"+ "上次请求的时间:"+holder.getTimestamp() +
"这次请求的时间:"+ timestamp+"本次请求内容为:original:"
+intentRequest.getQuery().getOriginal()+"; asrRawResult:"+getAsrRawResult(this.getStrRequest()));
this.waitAnswer();
return new Response();
}
} catch (InterruptedException e) {
logger.info("睡眠中断");
holder.setFirst(0);
return buildErrorResponse(ErrorMsg.SORRY_UNCATCH);
} catch (NullPointerException e) {
logger.info("锁未初始化");
USER_TIMESTAMP.put(userId, new Holder());
return buildErrorResponse(ErrorMsg.SORRY_UNCATCH);
} finally {
if (lock != null) lock.unlock();
}
holder.setTimestamp(timestamp);
holder.setFirst(0);
logger.info("请求消息:"+this.getStrRequest());
AudioUrlAndText data = RequestTerminal.requestTerminate(userWord, userId);
if (data == null) {
return buildErrorResponse(ErrorMsg.SORRY_UNCATCH);
}
addDirective(buildPlayDirectice(data.getAudioUrl()));
// shouldEndSession字段和expectSpeech字段同时为false,技能还在会话中,
// 但是不需要用户进行回复,设备端会关闭麦克风,此时可以返回AudioPlayer.Play指令,
// 目的是为了防止设备读取自己正在播放的内容
endDialog();
setExpectSpeech(false);
String audioUrl = data.getAudioUrl();
addDirective(buildPlayDirective(audioUrl, AudioPlayerDirective.PlayBehaviorType.REPLACE_ALL));
return new Response();
}
// @Override
// public Response onInent(IntentRequest intentRequest) {
// String userId = getCustomerId();
// String timestamp = this.getRequest().getRequest().getTimestamp();
// Holder preHolder = USER_TIMESTAMP.get(userId);
// if (preHolder == null) {
// preHolder = new Holder();
// USER_TIMESTAMP.put(userId, preHolder);
// }else if (Long.parseLong(preHolder.getTimestamp())+9 >= Long.parseLong(timestamp)) {
// logger.info("由于请求间隔过短,因此认为本次请求为过于的重复请求,"+ "上次请求的时间:"+preHolder.getTimestamp() +
// "这次请求的时间:"+ timestamp+"本次请求内容为:original:"
// +intentRequest.getQuery().getOriginal()+"; asrRawResult:"+getAsrRawResult(this.getStrRequest()));
//// String lastAudioUrl = preHolder.getLastAudioUrl();
//// if (lastAudioUrl == null || lastAudioUrl.isEmpty()) {
//// lastAudioUrl = "http://aliyun-hz1.chewrobot.com:9663/api/tts/get_audio?dirs=%5B5903691804%2Cxiaoai%5D&filename=86a667384722234e0060e3eae31dd223.mp3";
//// }
//// addDirective(buildPlayDirective(lastAudioUrl, AudioPlayerDirective.PlayBehaviorType.ENQUEUE));
// this.waitAnswer();
// return new Response();
// }
// preHolder.setTimestamp(timestamp);
// logger.info("请求消息:"+this.getStrRequest());
// Query query = intentRequest.getQuery();
// String userWord = null;
// if (query != null) userWord = query.getOriginal();
//
//// String userWord = getAsrRawResult(this.getStrRequest());
//// if (userWord.isEmpty() && query != null) {
//// userWord = query.getOriginal();
//// }
//
// if (userWord == null){
// logger.info("小度没有传来任何话语");
// return buildErrorResponse(ErrorMsg.SORRY_UNCATCH);
// }
//
// AudioUrlAndText data = RequestTerminal.requestTerminate(userWord, userId);
// if (data == null) {
// return buildErrorResponse(ErrorMsg.SORRY_UNCATCH);
// }
// String audioUrl = data.getAudioUrl();
// //preHolder.setLastAudioUrl(audioUrl);
// addDirective(buildPlayDirective(audioUrl, AudioPlayerDirective.PlayBehaviorType.REPLACE_ALL));
// // shouldEndSession字段和expectSpeech字段同时为false,技能还在会话中,
// // 但是不需要用户进行回复,设备端会关闭麦克风,此时可以返回AudioPlayer.Play指令,
// // 目的是为了防止设备读取自己正在播放的内容,二者默认都是false
// return new Response();
// }
@Override
public Response onLaunch(LaunchRequest launchRequest) {
userId = getDeviceId();
logger.info("请求消息:"+this.getStrRequest());
USER_TIMESTAMP.put(getCustomerId(), new Holder());
OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, WelcomeWord.WELCOME);
Reprompt reprompt = new Reprompt(new OutputSpeech(OutputSpeech.SpeechType.PlainText, WelcomeWord.BEGIN_NO_RESPONSE));
return new Response(outputSpeech, null, reprompt);
......@@ -74,6 +175,11 @@ public class ResponseEncapsulation extends AudioPlayer {
@Override
public Response onSessionEnded(SessionEndedRequest sessionEndedRequest) {
logger.info("触发结束事件,"+this.getStrRequest());
Holder holder = USER_TIMESTAMP.remove(getCustomerId());
if (holder != null) {
logger.info("删除用户:"+getCustomerId()+" 的缓存成功");
}
switch (sessionEndedRequest.getReason()) {
case ERROR: dealWithError(sessionEndedRequest); break;
case USER_INITIATED: logger.info(EndMsg.USER_SAY_CANCEL); break;
......@@ -81,6 +187,7 @@ public class ResponseEncapsulation extends AudioPlayer {
}
// 向终端发送“退出”
OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, EndMsg.BYE_BYE);
RequestTerminal.requestTerminate("退出", getCustomerId());
return new Response(outputSpeech);
}
......@@ -98,7 +205,86 @@ public class ResponseEncapsulation extends AudioPlayer {
return new Response(outputSpeech);
}
private Play buildPlayDirectice(String audioUrl) {
return new Play(AudioPlayerDirective.PlayBehaviorType.REPLACE_ALL, audioUrl, 0);
private Play buildPlayDirective(String audioUrl, AudioPlayerDirective.PlayBehaviorType type) {
return new Play(type, audioUrl, 0);
}
/**
* 不想对每个事件都进行处理,通过重写onDefaultEvent方法来统一处理。
* 任何事件都不允许开麦
* @return
*/
// @Override
// protected Response onDefaultEvent() {
// this.waitAnswer();
// this.setExpectSpeech(false);
// return new Response();
// }
/**
* 音频播放结束,开麦
*
* expectSpeech
* 在会话进行过程中,技能是否需要用户进行对话响应。该字段可选,并且仅在shouldEndSession为false时有效。
* true:表示技能需要用户进行对话响应,设备端上打开麦克风聆听用户的语音。
* false:表示技能不需要用户进行对话响应,设备端上关闭麦克风。
*
* shouldEndSession字段和expectSpeech字段同时为false,技能还在会话中,但是不需要用户进行回复,
* 设备端会关闭麦克风,此时可以返回AudioPlayer.Play指令。
* @param playbackFinishedEvent
* @return
*/
@Override
protected Response onPlaybackFinishedEvent(PlaybackFinishedEvent playbackFinishedEvent) {
logger.info("音频播放完毕,开麦");
this.waitAnswer();
this.setExpectSpeech(true);
return new Response();
}
@Override
protected Response onPlaybackStoppedEvent(PlaybackStoppedEvent playbackStoppedEvent) {
logger.info("音频播放停止");
this.waitAnswer();
return new Response();
}
// 不能提前开麦,这回让正在播放的音频停止
// @Override
// protected Response onPlaybackNearlyFinishedEvent(PlaybackNearlyFinishedEvent playbackNearlyFinishedEvent) {
// logger.info("音频即将播出完毕,提前开麦");
// this.waitAnswer();
// this.setExpectSpeech(true);
// return new Response();
// }
@Override
protected Response onDefaultEvent() {
logger.info("未拦截的事件类型:"+getEventType(this.getStrRequest()));
this.waitAnswer();
return new Response();
}
private String getCustomerId() {
String userId;
try {
userId = getUserId();
} catch (NullPointerException e) {
userId = Utils.useIPAsItsID();
}
return userId;
}
private String getEventType(String requestStr) {
int typeIndex = requestStr.lastIndexOf("type");
int comma = requestStr.indexOf(',', typeIndex);
return requestStr.substring(typeIndex, comma);
}
private String getAsrRawResult(String requestStr) {
int asrIndex = requestStr.lastIndexOf("asrRawResult");
int asrWordBegin = requestStr.indexOf(':', asrIndex)+2;
int asrWordEnd = requestStr.indexOf('"',asrWordBegin);
return requestStr.substring(asrWordBegin, asrWordEnd);
}
}
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = /usr/mqw/logs/xiaodu.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = DEBUG
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--控制台日志输出配置-->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!--对输出日志进行格式化-->
<encoder>
<!-- %d日期,%p日志级别,%file文件名,%line所在行数,%m输出的信息,%n换行 -->
<pattern>%d %p (%file:%line\)- %m%n</pattern>
<!--字符编码-->
<charset>UTF-8</charset><!--此处设置字符集-->
</encoder>
</appender>
<!--指定日志输出等级-->
<root level="info">
<appender-ref ref="STDOUT" />
</root>
<!--上述配置表名将 >=info级别的日志都输出到控制台-->
<!--日志文件配置-->
<appender name="xiaoduLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--被写入的文件名,可以是相对目录,也可以是绝对目录,如果上级目录不存在会自动创建,没有默认值。-->
<File>/usr/mqw/logs/xiaodu/</File>
<!--滚动记录文件:根据时间来制定滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/usr/mqw/logs/xiaodu/base.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="qi.qiwu.baidu" level="DEBUG">
<appender-ref ref="xiaoduLog" />
</logger>
</configuration>
\ No newline at end of file
......@@ -11,6 +11,7 @@
<groupId>ai.qiwu.xiaoya</groupId>
<artifactId>xiaoya</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>xiaoya</name>
<description>Demo project for Spring Boot</description>
......@@ -22,6 +23,19 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--添加servlet-api的依赖,用来打war包 -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
......@@ -29,9 +43,26 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.8</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.58</version>
</dependency>
</dependencies>
<build>
<finalName>xiaoya</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
......
......@@ -2,12 +2,18 @@ package ai.qiwu.xiaoya.xiaoya;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class XiaoyaApplication {
public class XiaoyaApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(XiaoyaApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(XiaoyaApplication.class);
}
}
package ai.qiwu.xiaoya.xiaoya.common;
/**
* @author 苗权威
* @dateTime 19-6-25 下午1:35
*/
public interface Constants {
String QI_WU_INTERFACE = "http://aliyun-hz1.chewrobot.com:8070/api/chat";
String SERVICE_NAME = "XIAOYA";
}
package ai.qiwu.xiaoya.xiaoya.controller;
import ai.qiwu.xiaoya.xiaoya.model.RequestModel.RequestParams;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.Response;
import ai.qiwu.xiaoya.xiaoya.service.ParseService;
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;
/**
* @author 苗权威
* @dateTime 19-6-25 上午11:03
*/
@RestController
public class XiaoYaController {
private static Logger logger = LoggerFactory.getLogger(XiaoYaController.class);
@Autowired
private ParseService service;
@RequestMapping("/xiaoya")
public @ResponseBody Response chat(@RequestBody RequestParams params) {
logger.info(params.toString());
return service.getResponse(params);
}
@RequestMapping("/hello")
public @ResponseBody String hello(@RequestBody RequestParams params) {
return "热部署测试成功7777777777777";
}
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel;
import ai.qiwu.xiaoya.xiaoya.model.RequestModel.contextSystem.SysUser;
import ai.qiwu.xiaoya.xiaoya.model.RequestModel.contextSystem.SystemApplication;
import ai.qiwu.xiaoya.xiaoya.model.RequestModel.contextSystem.SystemDevice;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午12:21
*/
@Getter
@Setter
@ToString
public class ContextSystem {
private SystemDevice device;
private SystemApplication application;
private SysUser user;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午12:21
*/
@Getter
@Setter
@ToString
public class RequestContext {
private ContextSystem system;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel;
import ai.qiwu.xiaoya.xiaoya.model.RequestModel.request.RequestPart;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午1:23
*/
@Getter
@Setter
@ToString
public class RequestParams {
private String version;
private RequestSession session;
private RequestContext context;
private RequestPart request;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel;
import ai.qiwu.xiaoya.xiaoya.model.RequestModel.request.RequestPart;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.Map;
/**
* @author 苗权威
* @dateTime 19-6-25 下午12:19
*/
@Getter
@Setter
@ToString
public class RequestSession {
private String sid;
private Map<String, String> attributes;
private RequestContext context;
private RequestPart request;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel.contextSystem;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午1:07
*/
@Getter
@Setter
@ToString
public class AppClient {
private String osClient;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel.contextSystem;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午1:08
*/
@Getter
@Setter
@ToString
public class AppSkill {
private String skillId;
private String version;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel.contextSystem;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午1:10
*/
@Getter
@Setter
@ToString
public class SysUser {
private String uid;
private String osAccessToken;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel.contextSystem;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午1:07
*/
@Getter
@Setter
@ToString
public class SystemApplication {
private AppClient client;
private AppSkill skill;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel.contextSystem;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午12:23
*/
@Getter
@Setter
@ToString
public class SystemDevice {
private String deviceType;
private String deviceId;
private String sn;
private String productId;
private String version;
private String lat;
private String lng;
private String ip;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel.request;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午1:16
*/
@Getter
@Setter
@ToString
public class RequestAsr {
private String text;
private String version;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel.request;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 下午1:17
*/
@Getter
@Setter
@ToString
public class RequestNlu {
private String domain;
private String intent;
private Object slots;
private String env;
}
package ai.qiwu.xiaoya.xiaoya.model.RequestModel.request;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-6-25 下午1:14
*/
@Getter
@Setter
@ToString
public class RequestPart {
private String type;
private RequestAsr asr;
private List<RequestNlu> nlu;
}
package ai.qiwu.xiaoya.xiaoya.model.ResponseModel;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.ResponsePart;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
/**
* @author 苗权威
* @dateTime 19-6-25 上午11:06
*/
@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
@Getter
@Setter
@ToString
public class Response {
private String version;
private Session session;
private ResponsePart response;
}
package ai.qiwu.xiaoya.xiaoya.model.ResponseModel;
import lombok.Getter;
import lombok.Setter;
import java.util.Map;
/**
* @author 苗权威
* @dateTime 19-6-25 上午11:08
*/
@Getter
@Setter
public class Session {
private String sid;
private Map<String, String> attributes;
}
package ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 上午11:14
*/
@Getter
@Setter
public class OutputSpeech {
private String type; // plaintext
private String text; // tts
private String ssml;
}
package ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.directive.Directive;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-6-25 上午11:14
*/
@Getter
@Setter
public class ResponsePart {
private OutputSpeech outputSpeech;
private List<Directive> directives;
private boolean shouldEndSession;
}
package ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.directive;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 上午11:24
*/
@Getter
@Setter
public class Art {
private String small;
private String middle;
private String large;
}
package ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.directive;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 上午11:19
*/
@Getter
@Setter
public class AudioItem {
private Stream stream;
private MetaData metaData;
}
package ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.directive;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 上午11:18
*/
@Getter
@Setter
public class Directive {
private String type; //AudioPlay.Play
private AudioItem audioItem;
}
package ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.directive;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 上午11:23
*/
@Getter
@Setter
public class MetaData {
private String id;
private String title;
private String albumId;
private String albumTitle;
private String artist;
private Art art;
}
package ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.directive;
import lombok.Getter;
import lombok.Setter;
/**
* @author 苗权威
* @dateTime 19-6-25 上午11:22
*/
@Getter
@Setter
public class Stream {
private String url; //audio url
private int offsetInMilliseconds;
}
package ai.qiwu.xiaoya.xiaoya.service;
import ai.qiwu.xiaoya.xiaoya.common.Constants;
import ai.qiwu.xiaoya.xiaoya.model.RequestModel.RequestParams;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.Response;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.Session;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.OutputSpeech;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.ResponsePart;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.directive.AudioItem;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.directive.Directive;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.directive.MetaData;
import ai.qiwu.xiaoya.xiaoya.model.ResponseModel.responsePart.directive.Stream;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @author 苗权威
* @dateTime 19-6-25 下午1:25
*/
@Service("service")
public class ParseService {
private static Logger logger = LoggerFactory.getLogger(ParseService.class);
public Response getResponse(RequestParams params) {
Response curResponse = buildResponse();
String userId = params.getContext().getSystem().getDevice().getIp();
addSidToResponse(params, curResponse);
String userWord = params.getRequest().getAsr().getText();
requestQiWuInterface(userId, userWord, curResponse);
return curResponse;
}
private void requestQiWuInterface(String userId, String userWord, Response response) {
String audioUrl = "";
String textContent = "请说推荐作品";
CloseableHttpClient httpClient = null;
CloseableHttpResponse httpResponse = null;
try {
httpClient = HttpClientBuilder.create().build();
HttpPost post = new HttpPost(Constants.QI_WU_INTERFACE);
HashMap<String, String> params = new HashMap<>();
params.put("user_id", String.valueOf(userId));
params.put("text", userWord);
params.put("access",Constants.SERVICE_NAME);
String paramsJsonFormat = JSON.toJSONString(params);
StringEntity body = new StringEntity(paramsJsonFormat, "UTF-8");
post.setHeader("Content-Type", "application/json;charset=utf-8");
post.setEntity(body);
httpResponse = httpClient.execute(post);
HttpEntity responseBody = httpResponse.getEntity();
if (responseBody != null) {
String responseContent = EntityUtils.toString(responseBody);
logger.info("齐悟接口返回: "+ responseContent);
JSONObject responseJsonFormat = JSONObject.parseObject(responseContent);
audioUrl = (String) responseJsonFormat.get("audio");
textContent = (String) responseJsonFormat.get("text");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (httpClient != null) httpClient.close();
if (httpResponse != null) httpResponse.close();
} catch (IOException e) {
e.printStackTrace();
}
}
addUrlAndTextToResponse(audioUrl, textContent, response);
}
private void addUrlAndTextToResponse(String audioUrl, String text, Response response) {
response.getResponse().getOutputSpeech().setText(text);
response.getResponse().getDirectives().get(0).getAudioItem().getStream().setUrl(audioUrl);
}
private void addSidToResponse(RequestParams params, Response response) {
response.getSession().setSid(params.getSession().getSid());
}
private Response buildResponse() {
Response response = new Response();
response.setVersion("1.0.0");
Session session = new Session();
response.setSession(session);
ResponsePart responsePart = new ResponsePart();
OutputSpeech outputSpeech = new OutputSpeech();
outputSpeech.setType("plaintext");
responsePart.setOutputSpeech(outputSpeech);
Directive directive = new Directive();
directive.setType("AudioPlay.Play");
AudioItem audioItem = new AudioItem();
Stream stream = new Stream();
stream.setOffsetInMilliseconds(0);
MetaData metaData = new MetaData();
metaData.setId("27299018");
metaData.setTitle("Any");
audioItem.setStream(stream);
audioItem.setMetaData(metaData);
directive.setAudioItem(audioItem);
List<Directive> directives = new ArrayList<>();
directives.add(directive);
responsePart.setDirectives(directives);
responsePart.setShouldEndSession(false);
response.setResponse(responsePart);
return response;
}
}
log4j.appender.D = org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File = /usr/mqw/logs/xiaoyas.log
log4j.appender.D.Append = true
log4j.appender.D.Threshold = DEBUG
log4j.appender.D.layout = org.apache.log4j.PatternLayout
log4j.appender.D.layout.ConversionPattern = %-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--控制台日志输出配置-->
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!--对输出日志进行格式化-->
<encoder>
<!-- %d日期,%p日志级别,%file文件名,%line所在行数,%m输出的信息,%n换行 -->
<pattern>%d %p (%file:%line\)- %m%n</pattern>
<!--字符编码-->
<charset>UTF-8</charset><!--此处设置字符集-->
</encoder>
</appender>
<!--指定日志输出等级-->
<root level="info">
<appender-ref ref="STDOUT" />
</root>
<!--上述配置表名将 >=info级别的日志都输出到控制台-->
<!--日志文件配置-->
<appender name="xiaoyaLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!--被写入的文件名,可以是相对目录,也可以是绝对目录,如果上级目录不存在会自动创建,没有默认值。-->
<File>/usr/mqw/logs/xiaoya/</File>
<!--滚动记录文件:根据时间来制定滚动策略-->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/usr/mqw/logs/xiaoya/base.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<logger name="qi.qiwu.xiaoya" level="DEBUG">
<appender-ref ref="xiaoyaLog" />
</logger>
</configuration>
\ 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