Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
qwgame
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵国君
qwgame
Commits
7d840a91
Commit
7d840a91
authored
Nov 24, 2018
by
hxw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
routine
parent
f8d00711
Show whitespace changes
Inline
Side-by-side
Showing
89 changed files
with
851 additions
and
7594 deletions
+851
-7594
ChatbotBackendApplication.java
src/ChatbotBackendApplication.java
+0
-0
C3p0Utils.java
src/db/C3p0Utils.java
+1
-1
DB.java
src/db/DB.java
+1
-1
DBCPUtils.java
src/db/DBCPUtils.java
+2
-2
DBUtils.java
src/db/DBUtils.java
+1
-1
SqlHelper.java
src/db/SqlHelper.java
+143
-24
ChatCache.java
src/entity/ChatCache.java
+14
-3
Condition.java
src/entity/Condition.java
+1
-2
JConfig.java
src/entity/JConfig.java
+6
-4
QuestionKeyWord.java
src/entity/QuestionKeyWord.java
+1
-1
Solution.java
src/entity/Solution.java
+1
-1
UserInfo.java
src/entity/UserInfo.java
+1
-1
CharacterConstructor.java
src/gameDesign/CharacterConstructor.java
+28
-19
ElementConstructor.java
src/gameDesign/ElementConstructor.java
+61
-14
Floyd.java
src/gameDesign/Floyd.java
+1
-1
GlobalVariableConstructor.java
src/gameDesign/GlobalVariableConstructor.java
+17
-7
ItemConstructor.java
src/gameDesign/ItemConstructor.java
+24
-20
MapConstructor.java
src/gameDesign/MapConstructor.java
+60
-22
PlotConstructor.java
src/gameDesign/PlotConstructor.java
+87
-40
MANIFEST.MF
src/main/java/META-INF/MANIFEST.MF
+0
-3
DBUtil.java
.../java/com/qiwu/chatbotbackend/GameEnvironment/DBUtil.java
+0
-40
GameEnv.java
...java/com/qiwu/chatbotbackend/GameEnvironment/GameEnv.java
+0
-498
ObjectFileUtil.java
...m/qiwu/chatbotbackend/GameEnvironment/ObjectFileUtil.java
+0
-46
Util.java
...in/java/com/qiwu/chatbotbackend/GameEnvironment/Util.java
+0
-54
Attr.java
...va/com/qiwu/chatbotbackend/GameEnvironment/bean/Attr.java
+0
-26
GoodsInstance.java
...wu/chatbotbackend/GameEnvironment/bean/GoodsInstance.java
+0
-35
NpcInstance.java
...qiwu/chatbotbackend/GameEnvironment/bean/NpcInstance.java
+0
-35
Place.java
...a/com/qiwu/chatbotbackend/GameEnvironment/bean/Place.java
+0
-61
SuperClass.java
.../qiwu/chatbotbackend/GameEnvironment/bean/SuperClass.java
+0
-53
C3p0Utils.java
src/main/java/com/qiwu/chatbotbackend/db/C3p0Utils.java
+0
-57
DB.java
src/main/java/com/qiwu/chatbotbackend/db/DB.java
+0
-24
DBCPUtils.java
src/main/java/com/qiwu/chatbotbackend/db/DBCPUtils.java
+0
-61
DBUtils.java
src/main/java/com/qiwu/chatbotbackend/db/DBUtils.java
+0
-4
SqlHelper.java
src/main/java/com/qiwu/chatbotbackend/db/SqlHelper.java
+0
-511
ChatCache.java
src/main/java/com/qiwu/chatbotbackend/entity/ChatCache.java
+0
-47
Condition.java
src/main/java/com/qiwu/chatbotbackend/entity/Condition.java
+0
-51
JConfig.java
src/main/java/com/qiwu/chatbotbackend/entity/JConfig.java
+0
-296
QuestionKeyWord.java
.../java/com/qiwu/chatbotbackend/entity/QuestionKeyWord.java
+0
-35
Solution.java
src/main/java/com/qiwu/chatbotbackend/entity/Solution.java
+0
-45
UserInfo.java
src/main/java/com/qiwu/chatbotbackend/entity/UserInfo.java
+0
-34
CharacterConstructor.java
.../qiwu/chatbotbackend/gameDesign/CharacterConstructor.java
+0
-96
ElementConstructor.java
...om/qiwu/chatbotbackend/gameDesign/ElementConstructor.java
+0
-132
Floyd.java
src/main/java/com/qiwu/chatbotbackend/gameDesign/Floyd.java
+0
-106
GlobalVariableConstructor.java
.../chatbotbackend/gameDesign/GlobalVariableConstructor.java
+0
-46
ItemConstructor.java
...a/com/qiwu/chatbotbackend/gameDesign/ItemConstructor.java
+0
-99
MapConstructor.java
...va/com/qiwu/chatbotbackend/gameDesign/MapConstructor.java
+0
-310
PlotConstructor.java
...a/com/qiwu/chatbotbackend/gameDesign/PlotConstructor.java
+0
-805
ChatCacheController.java
...m/qiwu/chatbotbackend/processing/ChatCacheController.java
+0
-233
ConditionTableController.java
...u/chatbotbackend/processing/ConditionTableController.java
+0
-228
LogWriter.java
...in/java/com/qiwu/chatbotbackend/processing/LogWriter.java
+0
-60
MyFunc.java
src/main/java/com/qiwu/chatbotbackend/processing/MyFunc.java
+0
-147
QuestionMatcher.java
...a/com/qiwu/chatbotbackend/processing/QuestionMatcher.java
+0
-1251
UserInfoController.java
...om/qiwu/chatbotbackend/processing/UserInfoController.java
+0
-294
WorldController.java
...a/com/qiwu/chatbotbackend/processing/WorldController.java
+0
-127
GameDesignServlet.java
...va/com/qiwu/chatbotbackend/servlet/GameDesignServlet.java
+0
-263
GetAnswerServlet.java
...ava/com/qiwu/chatbotbackend/servlet/GetAnswerServlet.java
+0
-137
GetConfigServlet.java
...ava/com/qiwu/chatbotbackend/servlet/GetConfigServlet.java
+0
-44
ReloadChatCacheServlet.java
...m/qiwu/chatbotbackend/servlet/ReloadChatCacheServlet.java
+0
-19
ReloadConfigServlet.java
.../com/qiwu/chatbotbackend/servlet/ReloadConfigServlet.java
+0
-80
SaveChatCacheServlet.java
...com/qiwu/chatbotbackend/servlet/SaveChatCacheServlet.java
+0
-40
UpdateServlet.java
...n/java/com/qiwu/chatbotbackend/servlet/UpdateServlet.java
+0
-130
UpdateSingleConfigServlet.java
...iwu/chatbotbackend/servlet/UpdateSingleConfigServlet.java
+0
-98
application.properties
src/main/resources/application.properties
+0
-4
c3p0-config.xml
src/main/resources/dev/c3p0-config.xml
+0
-34
log4j.properties
src/main/resources/dev/log4j.properties
+0
-23
c3p0-config.xml
src/main/resources/pro/c3p0-config.xml
+0
-34
log4j.properties
src/main/resources/pro/log4j.properties
+0
-23
jquery-3.3.1.min.js
src/main/resources/static/js/jquery-3.3.1.min.js
+0
-2
update.html
src/main/resources/static/update.html
+0
-97
index.jsp
src/main/resources/templates/index.jsp
+0
-16
update.html
src/main/resources/templates/update.html
+0
-97
update3.html
src/main/resources/templates/update3.html
+0
-85
ChatCacheController.java
src/processing/ChatCacheController.java
+81
-50
ConditionTableController.java
src/processing/ConditionTableController.java
+3
-3
LogWriter.java
src/processing/LogWriter.java
+17
-6
MyFunc.java
src/processing/MyFunc.java
+2
-2
QuestionMatcher.java
src/processing/QuestionMatcher.java
+43
-26
UserInfoController.java
src/processing/UserInfoController.java
+12
-6
WorldController.java
src/processing/WorldController.java
+17
-11
GameDesignServlet.java
src/servlet/GameDesignServlet.java
+157
-33
GetAnswerServlet.java
src/servlet/GetAnswerServlet.java
+49
-12
GetConfigServlet.java
src/servlet/GetConfigServlet.java
+2
-2
ReloadChatCacheServlet.java
src/servlet/ReloadChatCacheServlet.java
+1
-1
ReloadConfigServlet.java
src/servlet/ReloadConfigServlet.java
+3
-3
SaveChatCacheServlet.java
src/servlet/SaveChatCacheServlet.java
+5
-5
UpdateServlet.java
src/servlet/UpdateServlet.java
+5
-5
UpdateSingleConfigServlet.java
src/servlet/UpdateSingleConfigServlet.java
+4
-4
ChatbotBackendApplicationTests.java
...m/qiwu/chatbotbackend/ChatbotBackendApplicationTests.java
+0
-16
WorldTests.java
src/test/java/com/qiwu/chatbotbackend/WorldTests.java
+0
-69
No files found.
src/
main/java/com/qiwu/chatbotbackend/
ChatbotBackendApplication.java
→
src/ChatbotBackendApplication.java
View file @
7d840a91
File moved
src/db/C3p0Utils.java
View file @
7d840a91
package
db
;
package
com
.
qiwu
.
chatbotbackend
.
db
;
import
com.mchange.v2.c3p0.ComboPooledDataSource
;
import
com.mchange.v2.c3p0.ComboPooledDataSource
;
...
...
src/db/DB.java
View file @
7d840a91
package
db
;
package
com
.
qiwu
.
chatbotbackend
.
db
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.DriverManager
;
...
...
src/db/DBCPUtils.java
View file @
7d840a91
package
db
;
package
com
.
qiwu
.
chatbotbackend
.
db
;
import
org.apache.
commons.dbcp
.BasicDataSourceFactory
;
import
org.apache.
tomcat.dbcp.dbcp2
.BasicDataSourceFactory
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
java.io.File
;
import
java.io.File
;
...
...
src/db/DBUtils.java
View file @
7d840a91
package
db
;
package
com
.
qiwu
.
chatbotbackend
.
db
;
public
class
DBUtils
{
public
class
DBUtils
{
}
}
src/db/SqlHelper.java
View file @
7d840a91
package
db
;
package
com
.
qiwu
.
chatbotbackend
.
db
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
entity.JConfig
;
import
com.qiwu.chatbotbackend.
entity.JConfig
;
import
entity.QuestionKeyWord
;
import
com.qiwu.chatbotbackend.
entity.QuestionKeyWord
;
import
gameDesign.ElementConstructor
;
import
com.qiwu.chatbotbackend.
gameDesign.ElementConstructor
;
import
processing.MyFunc
;
import
com.qiwu.chatbotbackend.
processing.MyFunc
;
import
java.sql.*
;
import
java.sql.*
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Iterator
;
import
java.util.List
;
public
class
SqlHelper
{
public
class
SqlHelper
{
private
Connection
conn
=
null
;
private
Connection
conn
=
null
;
...
@@ -153,7 +151,7 @@ public class SqlHelper {
...
@@ -153,7 +151,7 @@ public class SqlHelper {
return
b
;
return
b
;
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
"删除旧数据失败"
);
System
.
out
.
println
(
"删除旧数据
config
失败"
);
e
.
printStackTrace
();
e
.
printStackTrace
();
return
false
;
return
false
;
}
}
...
@@ -173,7 +171,28 @@ public class SqlHelper {
...
@@ -173,7 +171,28 @@ public class SqlHelper {
return
b
;
return
b
;
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
"删除旧数据失败"
);
System
.
out
.
println
(
"删除旧数据variable失败"
);
e
.
printStackTrace
();
return
false
;
}
}
public
boolean
deleteCategoryByBotId
(
int
botId
)
{
String
sql
=
"delete from config_categories where botId= ?"
;
boolean
b
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
b
=
ps
.
execute
();
ps
.
close
();
return
b
;
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
"删除旧数据category失败"
);
e
.
printStackTrace
();
e
.
printStackTrace
();
return
false
;
return
false
;
}
}
...
@@ -236,7 +255,7 @@ public class SqlHelper {
...
@@ -236,7 +255,7 @@ public class SqlHelper {
}
}
public
boolean
batchInsertConfigByBotId
(
int
botId
,
ElementConstructor
constructor
,
List
<
Integer
>
idList
)
{
public
boolean
batchInsertConfigByBotId
(
int
botId
,
List
<
JSONObject
>
jsonList
,
List
<
Integer
>
idList
,
int
categoryId
)
{
int
count
[];
int
count
[];
boolean
insertFlag
=
true
;
boolean
insertFlag
=
true
;
String
sql
=
"insert into chatbot_config (botId, categoryId, configData, configName) VALUES (?, ?, ?, ?)"
;
String
sql
=
"insert into chatbot_config (botId, categoryId, configData, configName) VALUES (?, ?, ?, ?)"
;
...
@@ -246,11 +265,11 @@ public class SqlHelper {
...
@@ -246,11 +265,11 @@ public class SqlHelper {
conn
.
setAutoCommit
(
false
);
// 需要用到事务,不能让他自动提交,需要手动提交
conn
.
setAutoCommit
(
false
);
// 需要用到事务,不能让他自动提交,需要手动提交
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
for
(
J
Config
jConfig
:
constructor
.
getjConfigList
()
)
{
for
(
J
SONObject
json
:
jsonList
)
{
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
ps
.
setString
(
2
,
String
.
valueOf
(
0
));
ps
.
setString
(
2
,
String
.
valueOf
(
categoryId
));
ps
.
setString
(
3
,
j
Config
.
toJson
(
constructor
.
getConditionDescription
())
.
toJSONString
());
ps
.
setString
(
3
,
j
son
.
toJSONString
());
ps
.
setString
(
4
,
""
);
ps
.
setString
(
4
,
(
String
)
json
.
get
(
"configName"
)
);
ps
.
addBatch
();
ps
.
addBatch
();
}
}
...
@@ -289,6 +308,72 @@ public class SqlHelper {
...
@@ -289,6 +308,72 @@ public class SqlHelper {
}
}
public
boolean
batchInsertCategoryByBotId
(
int
botId
,
Map
<
String
,
Integer
>
categoryMap
)
{
int
count
[],
iterNum
=
0
,
id
;
boolean
insertFlag
=
true
;
String
sql
=
""
,
varName
,
varValue
,
description
;
ArrayList
<
String
>
nameList
=
new
ArrayList
<
String
>();
try
{
conn
.
setAutoCommit
(
false
);
sql
=
"insert into config_categories (botId, categoryParentId, categoryName, categoryStatus) VALUES (?, -1, ?, 'avaliable')"
;
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
Iterator
<
String
>
iit
=
categoryMap
.
keySet
().
iterator
();
while
(
iit
.
hasNext
())
{
varName
=
iit
.
next
();
nameList
.
add
(
varName
);
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
ps
.
setString
(
2
,
varName
);
ps
.
addBatch
();
}
count
=
ps
.
executeBatch
();
conn
.
commit
();
for
(
int
i
:
count
)
{
if
(
i
==
0
)
{
conn
.
rollback
();
System
.
out
.
println
(
"======出现异常,回滚========="
);
insertFlag
=
false
;
}
}
ResultSet
rs
=
ps
.
getGeneratedKeys
();
while
(
rs
.
next
()){
id
=
rs
.
getInt
(
1
);
categoryMap
.
put
(
nameList
.
get
(
iterNum
),
id
);
iterNum
++;
}
ps
.
close
();
rs
.
close
();
}
catch
(
SQLException
e
)
{
try
{
conn
.
rollback
();
}
catch
(
SQLException
e1
)
{
e1
.
printStackTrace
();
}
System
.
out
.
println
(
"------出现异常,回滚----------"
);
e
.
printStackTrace
();
}
return
insertFlag
;
}
public
JSONObject
queryGameElementsByBotId
(
int
id
)
{
public
JSONObject
queryGameElementsByBotId
(
int
id
)
{
String
sql
=
"select * from generate_json_tb where project_id = ?"
;
String
sql
=
"select * from generate_json_tb where project_id = ?"
;
String
userName
=
""
;
String
userName
=
""
;
...
@@ -347,6 +432,7 @@ public class SqlHelper {
...
@@ -347,6 +432,7 @@ public class SqlHelper {
b
=
ps
.
execute
();
b
=
ps
.
execute
();
ps
.
close
();
ps
.
close
();
conn
.
commit
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -356,27 +442,29 @@ public class SqlHelper {
...
@@ -356,27 +442,29 @@ public class SqlHelper {
}
}
public
boolean
insertConfigByBotId
(
int
botId
,
ElementConstructor
constructor
,
JConfig
jConfig
,
List
<
Integer
>
idList
)
{
public
boolean
insertConfigByBotId
(
int
botId
,
JSONObject
json
,
List
<
Integer
>
idList
,
int
categoryId
)
{
String
sql
=
"insert into chatbot_config (botId, categoryId, configData, configName) VALUES (?, ?, ?, ?)"
;
String
sql
=
"insert into chatbot_config (botId, categoryId, configData, configName) VALUES (?, ?, ?, ?)"
;
String
userName
=
""
;
String
result
=
"empty"
;
ResultSet
rs
=
null
;
int
id
=
0
;
int
id
=
0
;
boolean
b
=
true
;
boolean
b
=
true
;
int
bNum
=
0
;
try
{
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
ps
.
setString
(
2
,
String
.
valueOf
(
0
));
ps
.
setString
(
2
,
String
.
valueOf
(
categoryId
));
ps
.
setString
(
3
,
j
Config
.
toJson
(
constructor
.
getConditionDescription
())
.
toJSONString
());
ps
.
setString
(
3
,
j
son
.
toJSONString
());
ps
.
setString
(
4
,
""
);
ps
.
setString
(
4
,
(
String
)
json
.
get
(
"configName"
)
);
ps
.
executeUpdate
();
System
.
out
.
println
(
ps
.
toString
());
rs
=
ps
.
getGeneratedKeys
();
bNum
=
ps
.
executeUpdate
();
ResultSet
rs
=
ps
.
getGeneratedKeys
();
if
(
rs
.
next
()){
if
(
rs
.
next
()){
id
=
rs
.
getInt
(
1
);
id
=
rs
.
getInt
(
1
);
idList
.
add
(
id
);
idList
.
add
(
id
);
}
}
ps
.
close
();
ps
.
close
();
rs
.
close
();
conn
.
commit
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -386,6 +474,37 @@ public class SqlHelper {
...
@@ -386,6 +474,37 @@ public class SqlHelper {
}
}
// public boolean insertCategoryByBotId(int botId, String categoryName) {
// String sql = "insert into chatbot_config (botId, categoryId, configData, configName) VALUES (?, ?, ?, ?)";
// int id = 0;
// boolean b = true;
// int bNum = 0;
// try {
// PreparedStatement ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
// ps.setString(1, String.valueOf(botId));
// ps.setString(2, "0");
// ps.setString(4, jConfig.getConfigName());
//
// System.out.println(ps.toString());
//
// bNum = ps.executeUpdate();
// ResultSet rs = ps.getGeneratedKeys();
// if(rs.next()){
// id = rs.getInt(1);
// idList.add(id);
// }
// ps.close();
// rs.close();
// conn.commit();
//
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// return b;
//
// }
...
...
src/entity/ChatCache.java
View file @
7d840a91
package
entity
;
package
com
.
qiwu
.
chatbotbackend
.
entity
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Map
;
import
GameEnvironment.GameEnv
;
import
java.util.concurrent.ExecutionException
;
import
com.qiwu.chatbotbackend.GameEnvironment.GameEnv
;
public
class
ChatCache
{
public
class
ChatCache
{
private
Map
<
String
,
String
>
infoPoint
=
null
;
private
Map
<
String
,
String
>
infoPoint
=
null
;
private
GameEnv
gameEnv
=
null
;
private
GameEnv
gameEnv
=
null
;
...
@@ -27,8 +29,17 @@ public class ChatCache {
...
@@ -27,8 +29,17 @@ public class ChatCache {
this
.
gameEnv
=
gameEnv
;
this
.
gameEnv
=
gameEnv
;
}
}
public
ChatCache
(
GameEnv
gameEnv
,
Map
<
String
,
String
>
infoPoint
){
this
.
gameEnv
=
gameEnv
;
this
.
infoPoint
=
infoPoint
;
}
public
ChatCache
(
UserInfo
userInfo
)
throws
Exception
{
public
ChatCache
(
UserInfo
userInfo
)
throws
Exception
{
try
{
gameEnv
=
new
GameEnv
(
userInfo
.
botAccount
);
gameEnv
=
new
GameEnv
(
userInfo
.
botAccount
);
}
catch
(
Exception
e
){
System
.
out
.
println
(
"游戏平台初始化失败"
);
}
String
k
;
String
k
;
infoPoint
=
new
HashMap
<
String
,
String
>();
infoPoint
=
new
HashMap
<
String
,
String
>();
...
...
src/entity/Condition.java
View file @
7d840a91
package
entity
;
package
com
.
qiwu
.
chatbotbackend
.
entity
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
...
...
src/entity/JConfig.java
View file @
7d840a91
package
entity
;
package
com
.
qiwu
.
chatbotbackend
.
entity
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
...
@@ -38,6 +38,10 @@ public class JConfig {
...
@@ -38,6 +38,10 @@ public class JConfig {
this
.
configName
=
configName
;
this
.
configName
=
configName
;
}
}
public
String
getConfigName
()
{
return
configName
;
}
private
String
configName
=
""
;
private
String
configName
=
""
;
public
String
getCurPremise
()
{
public
String
getCurPremise
()
{
...
@@ -56,7 +60,7 @@ public class JConfig {
...
@@ -56,7 +60,7 @@ public class JConfig {
put
(
"return"
,
"return"
);
put
(
"return"
,
"return"
);
put
(
"return-1"
,
"back"
);
put
(
"return-1"
,
"back"
);
put
(
"return-0"
,
"stay"
);
put
(
"return-0"
,
"stay"
);
put
(
"activ
at
e"
,
"activate"
);
put
(
"active"
,
"activate"
);
}
}
};
};
...
@@ -125,7 +129,6 @@ public class JConfig {
...
@@ -125,7 +129,6 @@ public class JConfig {
varName
=
iit
.
next
();
varName
=
iit
.
next
();
varValue
=
knowledge
.
get
(
varName
);
varValue
=
knowledge
.
get
(
varName
);
sb
.
append
(
"-<-"
+
varName
+
":"
+
varValue
);
sb
.
append
(
"-<-"
+
varName
+
":"
+
varValue
);
}
}
if
(!
extraKL
.
equals
(
""
))
{
if
(!
extraKL
.
equals
(
""
))
{
sb
.
append
(
"-<-"
+
extraKL
);
sb
.
append
(
"-<-"
+
extraKL
);
...
@@ -275,7 +278,6 @@ public class JConfig {
...
@@ -275,7 +278,6 @@ public class JConfig {
data
.
put
(
"nextStepList"
,
nextStepList
);
data
.
put
(
"nextStepList"
,
nextStepList
);
return
data
;
return
data
;
}
}
public
String
toString
()
{
public
String
toString
()
{
...
...
src/entity/QuestionKeyWord.java
View file @
7d840a91
package
entity
;
package
com
.
qiwu
.
chatbotbackend
.
entity
;
/**
/**
...
...
src/entity/Solution.java
View file @
7d840a91
package
entity
;
package
com
.
qiwu
.
chatbotbackend
.
entity
;
/**
/**
...
...
src/entity/UserInfo.java
View file @
7d840a91
package
entity
;
package
com
.
qiwu
.
chatbotbackend
.
entity
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
...
src/gameDesign/CharacterConstructor.java
View file @
7d840a91
package
gameDesign
;
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
db.SqlHelper
;
import
com.qiwu.chatbotbackend.
db.SqlHelper
;
import
entity.JConfig
;
import
com.qiwu.chatbotbackend.
entity.JConfig
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Map
;
public
class
CharacterConstructor
extends
ElementConstructor
{
public
class
CharacterConstructor
extends
ElementConstructor
{
public
CharacterConstructor
(
SqlHelper
helper
,
int
botId
)
{
public
CharacterConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
super
();
super
();
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
botId
=
botId
;
this
.
exceptRelation
=
exceptRelation
;
}
}
public
void
construct
(
JSONObject
jsonObject
,
UserInfo
userinfo
)
{
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
String
category
,
name
,
className
,
description
,
attrName
,
attrValue
;
String
category
,
name
,
className
,
description
,
attrName
,
attrValue
;
JSONArray
allNPC
=
jsonObject
.
getJSONArray
(
"npc"
);
try
{
JSONArray
allNPC
=
gameElements
.
getJSONArray
(
"npc"
);
Map
<
String
,
String
>
attribute
=
null
;
Map
<
String
,
String
>
attribute
=
null
;
Iterator
<
String
>
attrIter
=
null
;
Iterator
<
String
>
attrIter
=
null
;
HashSet
<
String
>
classSet
=
new
HashSet
<
String
>();
HashSet
<
String
>
classSet
=
new
HashSet
<
String
>();
//与npc属性相关的所有condition
//与npc属性相关的所有condition
ArrayList
<
String
>
relateConditions
=
new
ArrayList
<
String
>()
{
ArrayList
<
String
>
relateConditions
=
new
ArrayList
<
String
>()
{
{
{
add
(
"wenzainali"
);
add
(
"wenzainali"
);
add
(
"shishenme"
);
add
(
"shishenme"
);
}
}
};
};
//与npc类相关的所有condition
//与npc类相关的所有condition
ArrayList
<
String
>
classRelateConditions
=
new
ArrayList
<
String
>()
{
ArrayList
<
String
>
classRelateConditions
=
new
ArrayList
<
String
>()
{
{
{
add
(
"know_exist_what"
);
add
(
"know_exist_what"
);
}
}
};
};
//在condition的三元组中添加与NPC相关的关键词
String
conditionValue
=
"哪里:人称"
,
repValue
;
String
conditionValue
=
"哪里:人称"
,
repValue
;
StringBuffer
keywords
=
new
StringBuffer
();
StringBuffer
keywords
=
new
StringBuffer
();
StringBuffer
classKeywords
=
new
StringBuffer
();
StringBuffer
classKeywords
=
new
StringBuffer
();
...
@@ -47,15 +50,15 @@ public class CharacterConstructor extends ElementConstructor {
...
@@ -47,15 +50,15 @@ public class CharacterConstructor extends ElementConstructor {
for
(
JSONObject
character
:
allNPC
.
toJavaList
(
JSONObject
.
class
))
{
for
(
JSONObject
character
:
allNPC
.
toJavaList
(
JSONObject
.
class
))
{
name
=
(
String
)
character
.
get
(
"name"
);
name
=
(
String
)
character
.
get
(
"name"
);
className
=
(
String
)
character
.
get
(
"class"
);
className
=
(
String
)
character
.
get
(
"class"
);
if
(!
classSet
.
contains
(
className
))
{
if
(!
classSet
.
contains
(
className
))
{
classSet
.
add
(
className
);
classSet
.
add
(
className
);
classKeywords
.
append
(
"+周围:"
+
className
+
"+附近
"
+
className
);
classKeywords
.
append
(
"+周围:"
+
className
+
"+附近:
"
+
className
);
}
}
attribute
=
JSONObject
.
toJavaObject
(
character
.
getJSONObject
(
"attr"
),
Map
.
class
);
attribute
=
gameElements
.
toJavaObject
(
character
.
getJSONObject
(
"attr"
),
Map
.
class
);
attrIter
=
attribute
.
keySet
().
iterator
();
attrIter
=
attribute
.
keySet
().
iterator
();
repValue
=
conditionValue
.
replace
(
"人称"
,
name
);
repValue
=
conditionValue
.
replace
(
"人称"
,
name
);
keywords
.
append
(
"+"
+
repValue
);
keywords
.
append
(
"+"
+
repValue
);
...
@@ -64,11 +67,12 @@ public class CharacterConstructor extends ElementConstructor {
...
@@ -64,11 +67,12 @@ public class CharacterConstructor extends ElementConstructor {
attrValue
=
attribute
.
get
(
attrName
);
attrValue
=
attribute
.
get
(
attrName
);
}
}
System
.
out
.
println
(
name
);
System
.
out
.
println
(
name
);
}
}
//根据根据NPC名字和属性查询属性值
//根据根据NPC名字和属性查询属性值
for
(
String
conditionName
:
relateConditions
)
{
for
(
String
conditionName
:
relateConditions
)
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
keywords
,
" "
,
conditionName
+
"::match-Include="
+
keywords
,
" "
,
"match,return-0"
,
"{NPC_query-2}"
,
"yaobuyao"
,
"NPC_query:queryAttrByNPCName:"
+
conditionName
"match,return-0"
,
"{NPC_query-2}"
,
"yaobuyao"
,
"NPC_query:queryAttrByNPCName:"
+
conditionName
...
@@ -76,12 +80,17 @@ public class CharacterConstructor extends ElementConstructor {
...
@@ -76,12 +80,17 @@ public class CharacterConstructor extends ElementConstructor {
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
//根据根据NPC类别和地点属性查询所有NPC实例
//根据根据NPC类别和地点属性查询所有NPC实例
for
(
String
conditionName
:
relateConditions
)
{
for
(
String
conditionName
:
relateConditions
)
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
classKeywords
,
" "
,
conditionName
+
"::match-Include="
+
classKeywords
,
" "
,
"match,return-0"
,
"{NPC_query-2}"
,
"yaobuyao"
,
"NPC_query:queryAroundNpcByClassName:"
+
conditionName
"match,return-0"
,
"{NPC_query-2}"
,
"yaobuyao"
,
"NPC_query:queryAroundNpcByClassName:"
+
conditionName
);
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
}
catch
(
Exception
e
){
operationStatus
=
0
;
message
=
"NPC接口处理出现异常"
;
return
;
}
}
}
}
}
src/gameDesign/ElementConstructor.java
View file @
7d840a91
package
gameDesign
;
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
db.SqlHelper
;
import
com.qiwu.chatbotbackend.
db.SqlHelper
;
import
entity.JConfig
;
import
com.qiwu.chatbotbackend.
entity.JConfig
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
public
class
ElementConstructor
{
public
class
ElementConstructor
{
int
botId
=
0
;
int
botId
=
0
;
int
operationStatus
=
1
;
SqlHelper
helper
=
null
;
SqlHelper
helper
=
null
;
HashSet
<
String
>
exceptRelation
=
null
;
JConfig
jConfig
=
null
;
String
CHITCHAT_URL
=
"http:192.168.1.178:1111/test"
;
String
userName
;
String
message
=
""
;
List
<
JSONObject
>
configDataList
=
new
ArrayList
<
JSONObject
>();
List
<
JSONObject
>
configDataList
=
new
ArrayList
<
JSONObject
>();
List
<
JConfig
>
jConfigList
=
new
ArrayList
<
JConfig
>();
List
<
JConfig
>
jConfigList
=
new
ArrayList
<
JConfig
>();
String
CHITCHAT_URL
=
"http:192.168.1.178:1111/test"
,
userName
;
StringBuffer
configText
=
new
StringBuffer
();
StringBuffer
configText
=
new
StringBuffer
();
JConfig
jConfig
=
null
;
Map
<
String
,
String
>
varInitialMap
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
varInitialMap
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
conditionDescription
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
conditionDescription
=
new
HashMap
<
String
,
String
>();
public
String
getMessage
()
{
return
message
;
}
public
int
getOperationStatus
()
{
return
operationStatus
;
}
public
Map
<
String
,
String
>
getVarInitialMap
()
{
public
Map
<
String
,
String
>
getVarInitialMap
()
{
return
varInitialMap
;
return
varInitialMap
;
}
}
public
void
construct
(
JSONObject
jsonObject
,
UserInfo
userinfo
)
{
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
}
}
public
List
<
JConfig
>
getjConfigList
()
{
public
List
<
JConfig
>
getjConfigList
()
{
return
jConfigList
;
return
jConfigList
;
...
@@ -64,16 +76,51 @@ public class ElementConstructor {
...
@@ -64,16 +76,51 @@ public class ElementConstructor {
}
}
for
(
String
varName
:
varInitialMap
.
keySet
())
{
for
(
String
varName
:
varInitialMap
.
keySet
())
{
varValue
=
varInitialMap
.
get
(
varName
);
varValue
=
varInitialMap
.
get
(
varName
);
configText
.
append
(
"-varInitial-|"
+
varName
+
"|"
+
varValue
+
"\n"
);
configText
.
append
(
"-varInitial-|"
+
varName
+
"|"
+
varValue
.
replace
(
"\n"
,
""
)
+
"\n"
);
}
}
}
public
void
parseKeyword
(
JSONObject
config
,
Map
<
String
,
HashSet
<
String
>>
relationKeywords
,
HashSet
<
String
>
exceptRelation
){
String
conditionName
,
pair
[];
for
(
Map
premise:
JSONArray
.
parseArray
(
config
.
getJSONArray
(
"currentPremiseList"
).
toJSONString
(),
Map
.
class
)){
conditionName
=
(
String
)
premise
.
get
(
"actionName"
);
if
(!
exceptRelation
.
contains
(
conditionName
))
{
if
(!
relationKeywords
.
containsKey
(
conditionName
+
"_head"
))
{
relationKeywords
.
put
(
conditionName
+
"_head"
,
new
HashSet
<
String
>());
relationKeywords
.
put
(
conditionName
+
"_tail"
,
new
HashSet
<
String
>());
}
for
(
String
keyword
:
((
String
)
premise
.
get
(
"keywords"
)).
split
(
"\\+"
))
{
if
(
keyword
.
equals
(
""
)){
continue
;
}
else
if
(
keyword
.
contains
(
":"
)){
pair
=
keyword
.
split
(
":"
);
relationKeywords
.
get
(
conditionName
+
"_head"
).
add
(
pair
[
0
]);
relationKeywords
.
get
(
conditionName
+
"_tail"
).
add
(
pair
[
1
]);
}
else
{
relationKeywords
.
get
(
conditionName
+
"_tail"
).
add
(
keyword
);
}
}
}
}
}
}
/**
/**
* 根据插入的数据做后处理
* 根据插入的数据做后处理
* @param idList
* @param idList
*/
*/
public
void
postProcessing
(
List
<
Integer
>
idList
){}
public
void
postProcessing
(
List
<
Integer
>
idList
,
int
categoryId
){}
/**
/**
* 构造参数配置文件的json版
* 构造参数配置文件的json版
...
...
src/gameDesign/Floyd.java
View file @
7d840a91
package
gameDesign
;
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
/**
/**
* 弗洛伊德算法,用于构造地图时求最短路径
* 弗洛伊德算法,用于构造地图时求最短路径
...
...
src/gameDesign/GlobalVariableConstructor.java
View file @
7d840a91
package
gameDesign
;
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
db.SqlHelper
;
import
com.qiwu.chatbotbackend.
db.SqlHelper
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Map
;
public
class
GlobalVariableConstructor
extends
ElementConstructor
{
public
class
GlobalVariableConstructor
extends
ElementConstructor
{
public
GlobalVariableConstructor
(
SqlHelper
helper
,
int
botId
)
{
public
GlobalVariableConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
super
();
super
();
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
botId
=
botId
;
this
.
exceptRelation
=
exceptRelation
;
}
}
public
void
construct
(
JSONObject
jsonObject
,
UserInfo
userinfo
)
{
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
try
{
String
category
,
name
,
description
,
attrName
,
attrValue
;
String
category
,
name
,
description
,
attrName
,
attrValue
;
JSONArray
globalVariable
=
jsonObject
.
getJSONArray
(
"globalVariable"
);
JSONArray
globalVariable
=
gameElements
.
getJSONArray
(
"globalVariable"
);
Map
<
String
,
String
>
attribute
=
null
;
Map
<
String
,
String
>
attribute
=
null
;
Iterator
<
String
>
attrIter
=
null
;
Iterator
<
String
>
attrIter
=
null
;
for
(
JSONObject
variableList
:
globalVariable
.
toJavaList
(
JSONObject
.
class
))
{
for
(
JSONObject
variableList
:
globalVariable
.
toJavaList
(
JSONObject
.
class
))
{
category
=
(
String
)
variableList
.
get
(
"category"
);
category
=
(
String
)
variableList
.
get
(
"category"
);
attribute
=
JSONObject
.
toJavaObject
(
variableList
.
getJSONObject
(
"variables"
),
Map
.
class
);
attribute
=
gameElements
.
toJavaObject
(
variableList
.
getJSONObject
(
"variables"
),
Map
.
class
);
attrIter
=
attribute
.
keySet
().
iterator
();
attrIter
=
attribute
.
keySet
().
iterator
();
while
(
attrIter
.
hasNext
())
{
while
(
attrIter
.
hasNext
())
{
attrName
=
attrIter
.
next
();
attrName
=
attrIter
.
next
();
...
@@ -32,5 +37,10 @@ public class GlobalVariableConstructor extends ElementConstructor {
...
@@ -32,5 +37,10 @@ public class GlobalVariableConstructor extends ElementConstructor {
varInitialMap
.
put
(
category
+
"_"
+
attrName
,
attrValue
);
varInitialMap
.
put
(
category
+
"_"
+
attrName
,
attrValue
);
}
}
}
}
}
catch
(
Exception
e
){
operationStatus
=
0
;
message
=
"全局变量处理出现异常"
;
return
;
}
}
}
}
}
src/gameDesign/ItemConstructor.java
View file @
7d840a91
package
gameDesign
;
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
db.SqlHelper
;
import
com.qiwu.chatbotbackend.
db.SqlHelper
;
import
entity.JConfig
;
import
com.qiwu.chatbotbackend.
entity.JConfig
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Map
;
public
class
ItemConstructor
extends
ElementConstructor
{
public
class
ItemConstructor
extends
ElementConstructor
{
public
ItemConstructor
(
SqlHelper
helper
,
int
botId
)
{
public
ItemConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
super
();
super
();
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
botId
=
botId
;
this
.
exceptRelation
=
exceptRelation
;
}
}
public
void
construct
(
JSONObject
jsonObject
,
UserInfo
userinfo
)
{
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
try
{
String
category
,
name
,
className
,
description
,
attrName
,
attrValue
;
String
category
,
name
,
className
,
description
,
attrName
,
attrValue
;
JSONArray
goods
=
jsonObject
.
getJSONArray
(
"goods"
);
JSONArray
goods
=
gameElements
.
getJSONArray
(
"goods"
);
Map
<
String
,
String
>
attribute
=
null
;
Map
<
String
,
String
>
attribute
=
null
;
Iterator
<
String
>
attrIter
=
null
;
Iterator
<
String
>
attrIter
=
null
;
HashSet
<
String
>
classSet
=
new
HashSet
<
String
>();
HashSet
<
String
>
classSet
=
new
HashSet
<
String
>();
//与物品属性查询相关的所有condition
//与物品属性查询相关的所有condition
ArrayList
<
String
>
attrRelateConditions
=
new
ArrayList
<
String
>()
{
ArrayList
<
String
>
attrRelateConditions
=
new
ArrayList
<
String
>()
{
{
{
add
(
"nums"
);
add
(
"nums"
);
add
(
"shishenme"
);
add
(
"shishenme"
);
}
}
};
};
//与物品类查询相关的所有condition
//与物品类查询相关的所有condition
ArrayList
<
String
>
classRelateConditions
=
new
ArrayList
<
String
>()
{
ArrayList
<
String
>
classRelateConditions
=
new
ArrayList
<
String
>()
{
{
{
add
(
"know_exist_what"
);
add
(
"know_exist_what"
);
}
}
...
@@ -47,20 +46,20 @@ public class ItemConstructor extends ElementConstructor {
...
@@ -47,20 +46,20 @@ public class ItemConstructor extends ElementConstructor {
for
(
JSONObject
good
:
goods
.
toJavaList
(
JSONObject
.
class
))
{
for
(
JSONObject
good
:
goods
.
toJavaList
(
JSONObject
.
class
))
{
name
=
(
String
)
good
.
get
(
"name"
);
name
=
(
String
)
good
.
get
(
"name"
);
className
=
(
String
)
good
.
get
(
"class"
);
className
=
(
String
)
good
.
get
(
"class"
);
if
(!
classSet
.
contains
(
className
))
{
if
(!
classSet
.
contains
(
className
))
{
classSet
.
add
(
className
);
classSet
.
add
(
className
);
//添加周围有什么士兵等关于类别的关键词
//添加周围有什么士兵等关于类别的关键词
classKeywords
.
append
(
"+周围:"
+
className
+
"+附近"
+
className
);
classKeywords
.
append
(
"+周围:"
+
className
+
"+附近
:
"
+
className
);
}
}
attribute
=
JSONObject
.
toJavaObject
(
good
.
getJSONObject
(
"attr"
),
Map
.
class
);
attribute
=
gameElements
.
toJavaObject
(
good
.
getJSONObject
(
"attr"
),
Map
.
class
);
attrIter
=
attribute
.
keySet
().
iterator
();
attrIter
=
attribute
.
keySet
().
iterator
();
while
(
attrIter
.
hasNext
())
{
while
(
attrIter
.
hasNext
())
{
attrName
=
attrIter
.
next
();
attrName
=
attrIter
.
next
();
attrValue
=
attribute
.
get
(
attrName
);
attrValue
=
attribute
.
get
(
attrName
);
keywords
.
append
(
"+"
+
name
+
":"
+
attrName
)
;
keywords
.
append
(
"+"
+
name
+
":"
+
attrName
)
;
}
}
...
@@ -68,7 +67,7 @@ public class ItemConstructor extends ElementConstructor {
...
@@ -68,7 +67,7 @@ public class ItemConstructor extends ElementConstructor {
}
}
//根据根据物品名字和属性查询属性值
//根据根据物品名字和属性查询属性值
for
(
String
conditionName
:
attrRelateConditions
)
{
for
(
String
conditionName
:
attrRelateConditions
)
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
keywords
,
" "
,
conditionName
+
"::match-Include="
+
keywords
,
" "
,
"match,return-0"
,
"match,return-0"
,
...
@@ -80,7 +79,7 @@ public class ItemConstructor extends ElementConstructor {
...
@@ -80,7 +79,7 @@ public class ItemConstructor extends ElementConstructor {
}
}
//根据类名和地点查询所有实例
//根据类名和地点查询所有实例
for
(
String
conditionName
:
attrRelateConditions
)
{
for
(
String
conditionName
:
attrRelateConditions
)
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
classKeywords
,
" "
,
conditionName
+
"::match-Include="
+
classKeywords
,
" "
,
"match,return-0"
,
"match,return-0"
,
...
@@ -90,6 +89,11 @@ public class ItemConstructor extends ElementConstructor {
...
@@ -90,6 +89,11 @@ public class ItemConstructor extends ElementConstructor {
);
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
}
catch
(
Exception
e
){
operationStatus
=
0
;
message
=
"物品处理出现异常"
;
return
;
}
}
}
}
}
src/gameDesign/MapConstructor.java
View file @
7d840a91
package
gameDesign
;
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
db.SqlHelper
;
import
com.qiwu.chatbotbackend.
db.SqlHelper
;
import
entity.JConfig
;
import
com.qiwu.chatbotbackend.
entity.JConfig
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
java.util.*
;
import
java.util.*
;
...
@@ -16,10 +16,11 @@ public class MapConstructor extends ElementConstructor {
...
@@ -16,10 +16,11 @@ public class MapConstructor extends ElementConstructor {
Map
<
String
,
String
>
question2keyword
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
question2keyword
=
new
HashMap
<
String
,
String
>();
JSONArray
locations
=
null
;
JSONArray
locations
=
null
;
public
MapConstructor
(
SqlHelper
helper
,
int
botId
)
{
public
MapConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
super
();
super
();
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
botId
=
botId
;
this
.
exceptRelation
=
exceptRelation
;
}
}
...
@@ -51,6 +52,7 @@ public class MapConstructor extends ElementConstructor {
...
@@ -51,6 +52,7 @@ public class MapConstructor extends ElementConstructor {
List
<
Integer
>
neighbours
=
JSONArray
.
parseArray
(
locations
.
getJSONObject
(
i
).
getJSONArray
(
"neighbours"
).
toJSONString
(),
Integer
.
class
);
List
<
Integer
>
neighbours
=
JSONArray
.
parseArray
(
locations
.
getJSONObject
(
i
).
getJSONArray
(
"neighbours"
).
toJSONString
(),
Integer
.
class
);
for
(
int
neighbourId
:
neighbours
)
{
for
(
int
neighbourId
:
neighbours
)
{
JSONObject
neighbourObject
=
id2j
.
get
(
neighbourId
);
JSONObject
neighbourObject
=
id2j
.
get
(
neighbourId
);
System
.
out
.
println
(
neighbourObject
);
index
=
(
Integer
)
neighbourObject
.
get
(
"index"
);
index
=
(
Integer
)
neighbourObject
.
get
(
"index"
);
matrix
[
i
][
index
]
=
1
;
matrix
[
i
][
index
]
=
1
;
matrix
[
index
][
i
]
=
1
;
matrix
[
index
][
i
]
=
1
;
...
@@ -58,13 +60,16 @@ public class MapConstructor extends ElementConstructor {
...
@@ -58,13 +60,16 @@ public class MapConstructor extends ElementConstructor {
}
}
}
}
public
void
construct
(
JSONObject
jsonObject
,
UserInfo
userinfo
)
{
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
try
{
conditionDescription
.
put
(
"site"
,
"当前地点"
);
conditionDescription
.
put
(
"site"
,
"当前地点"
);
varInitialMap
.
put
(
"site"
,
"海边"
);
varInitialMap
.
put
(
"site"
,
"海边"
);
JSONObject
map
=
jsonObject
.
getJSONObject
(
"map"
);
JSONObject
map
=
gameElements
.
getJSONObject
(
"map"
);
Map
<
String
,
String
>
question2keyword
=
JSONObject
.
toJavaObject
(
map
.
getJSONObject
(
"question"
),
Map
.
class
);
Map
<
String
,
String
>
question2keyword
=
JSONObject
.
toJavaObject
(
map
.
getJSONObject
(
"question"
),
Map
.
class
);
JSONArray
locations
=
map
.
getJSONArray
(
"locations"
);
JSONArray
locations
=
map
.
getJSONArray
(
"locations"
);
String
userName
=
(
String
)
jsonObject
.
get
(
"userName"
);
String
userName
=
(
String
)
gameElements
.
get
(
"userName"
);
this
.
locations
=
locations
;
this
.
locations
=
locations
;
this
.
question2keyword
=
question2keyword
;
this
.
question2keyword
=
question2keyword
;
//通过邻接表构造邻接矩阵
//通过邻接表构造邻接矩阵
...
@@ -74,21 +79,28 @@ public class MapConstructor extends ElementConstructor {
...
@@ -74,21 +79,28 @@ public class MapConstructor extends ElementConstructor {
Floyd
floyd
=
new
Floyd
();
Floyd
floyd
=
new
Floyd
();
floyd
.
findShortestPath
(
matrix
,
locationNum
);
floyd
.
findShortestPath
(
matrix
,
locationNum
);
floyd
.
printPath
(
matrix
,
locationNum
);
floyd
.
printPath
(
matrix
,
locationNum
);
generateWantToThere
(
floyd
.
pathMatirx
,
floyd
.
preTable
,
jsonObject
);
generateWantToThere
(
floyd
.
pathMatirx
,
floyd
.
preTable
,
gameElements
);
generateWhereCanIgo
(
floyd
.
pathMatirx
,
floyd
.
preTable
,
jsonObject
);
generateWhereCanIgo
(
floyd
.
pathMatirx
,
floyd
.
preTable
,
gameElements
);
generateWhereIam
(
jsonObject
,
userName
);
generateWhereIam
(
gameElements
,
userName
);
generateHowToThere
(
floyd
.
pathMatirx
,
floyd
.
preTable
,
jsonObject
);
generateHowToThere
(
floyd
.
pathMatirx
,
floyd
.
preTable
,
gameElements
);
generateSurroundingItem
();
generateSurroundingItem
();
generateSurroundingPeople
();
generateSurroundingPeople
();
generateSurroundThings
();
}
catch
(
Exception
e
){
operationStatus
=
0
;
message
=
"地图处理出现异常"
;
return
;
}
}
}
/**
/**
* 生成‘我在哪里’所需要的配置文件
* 生成‘我在哪里’所需要的配置文件
*/
*/
public
void
generateWhereIam
(
JSONObject
jsonObject
,
String
botName
)
{
public
void
generateWhereIam
(
JSONObject
gameElements
,
String
botName
)
{
String
conditionName
=
"rencheng"
;
String
conditionName
=
"rencheng"
;
String
conditionKeywords
=
"
botName:哪里+botName
:哪"
;
String
conditionKeywords
=
"
qiwu:哪里+qiwu:哪+现在:哪里+现在
:哪"
;
String
zainaliKeywords
=
conditionKeywords
.
replace
(
"botName"
,
botName
);
String
zainaliKeywords
=
conditionKeywords
.
replace
(
"botName"
,
botName
);
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
zainaliKeywords
,
" "
,
conditionName
+
"::match-Include="
+
zainaliKeywords
,
" "
,
...
@@ -105,7 +117,7 @@ public class MapConstructor extends ElementConstructor {
...
@@ -105,7 +117,7 @@ public class MapConstructor extends ElementConstructor {
/**
/**
* 生成‘怎么去哪里’所需要的配置文件
* 生成‘怎么去哪里’所需要的配置文件
*/
*/
public
void
generateHowToThere
(
int
[][]
pathMatirx
,
int
[][]
preTable
,
JSONObject
jsonObject
)
{
public
void
generateHowToThere
(
int
[][]
pathMatirx
,
int
[][]
preTable
,
JSONObject
gameElements
)
{
String
conditionName
=
"want_know_zenmezuo"
;
String
conditionName
=
"want_know_zenmezuo"
;
String
conditionKeywords
=
"去:地点"
;
String
conditionKeywords
=
"去:地点"
;
...
@@ -158,8 +170,8 @@ public class MapConstructor extends ElementConstructor {
...
@@ -158,8 +170,8 @@ public class MapConstructor extends ElementConstructor {
/**
/**
* 生成‘我能去哪里’所需要的配置文件
* 生成‘我能去哪里’所需要的配置文件
*/
*/
public
void
generateWhereCanIgo
(
int
[][]
pathMatirx
,
int
[][]
preTable
,
JSONObject
jsonObject
)
{
public
void
generateWhereCanIgo
(
int
[][]
pathMatirx
,
int
[][]
preTable
,
JSONObject
gameElements
)
{
String
conditionKeywords
=
"能去:哪+能去:哪里+能去:哪儿"
;
String
conditionKeywords
=
"
去:哪里+
能去:哪+能去:哪里+能去:哪儿"
;
String
conditionName
=
"choose_gowhere"
;
String
conditionName
=
"choose_gowhere"
;
String
placeA
,
placeB
,
pathNode
;
String
placeA
,
placeB
,
pathNode
;
...
@@ -186,15 +198,28 @@ public class MapConstructor extends ElementConstructor {
...
@@ -186,15 +198,28 @@ public class MapConstructor extends ElementConstructor {
/**
/**
* 生成‘我要去那里’所需要的配置文件
* 生成‘我要去那里’所需要的配置文件
*/
*/
public
void
generateWantToThere
(
int
[][]
pathMatirx
,
int
[][]
preTable
,
JSONObject
jsonObject
)
{
public
void
generateWantToThere
(
int
[][]
pathMatirx
,
int
[][]
preTable
,
JSONObject
gameElements
)
{
String
placeA
,
placeB
,
descriptionB
,
placeKeywords
,
text
,
pathNode
,
lastTaskCondition
,
lastTaskReply
;
String
placeA
,
placeB
,
descriptionB
,
placeKeywords
,
text
,
pathNode
,
lastTaskCondition
,
lastTaskReply
;
String
conditionName
=
"
quna
"
;
String
conditionName
=
"
yaobuyao
"
;
String
conditionKeywords
=
"地点"
;
String
conditionKeywords
=
"地点"
;
String
start
=
(
String
)
gameElements
.
get
(
"start"
);
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
for
(
int
j
=
0
;
j
<
locationNum
;
j
++)
{
placeA
=
(
String
)
locations
.
getJSONObject
(
i
).
get
(
"name"
);
placeA
=
(
String
)
locations
.
getJSONObject
(
i
).
get
(
"name"
);
/**
* 添加初始化变量
*/
if
(!
varInitialMap
.
containsKey
(
"任务线"
+
placeA
+
"最后一个condition"
))
{
varInitialMap
.
put
(
"任务线"
+
placeA
+
"最后一个condition"
,
"yaobuyao"
);
varInitialMap
.
put
(
"任务线"
+
placeA
+
"最后的回答"
,
"你来到了"
+
placeA
+
",现在什么都没有, 请继续之前的剧情,接着往下玩吧!"
);
conditionDescription
.
put
(
"任务线"
+
placeA
+
"最后一个condition"
,
"任务线"
+
placeA
+
"最后一个condition"
);
conditionDescription
.
put
(
"任务线"
+
placeA
+
"最后的回答"
,
"任务线"
+
placeA
+
"最后的回答"
);
}
for
(
int
j
=
0
;
j
<
locationNum
;
j
++)
{
placeB
=
(
String
)
locations
.
getJSONObject
(
j
).
get
(
"name"
);
placeB
=
(
String
)
locations
.
getJSONObject
(
j
).
get
(
"name"
);
descriptionB
=
(
String
)
locations
.
getJSONObject
(
j
).
get
(
"description"
);
descriptionB
=
(
String
)
locations
.
getJSONObject
(
j
).
get
(
"description"
);
placeKeywords
=
conditionKeywords
.
replace
(
"地点"
,
placeB
);
placeKeywords
=
conditionKeywords
.
replace
(
"地点"
,
placeB
);
...
@@ -229,6 +254,8 @@ public class MapConstructor extends ElementConstructor {
...
@@ -229,6 +254,8 @@ public class MapConstructor extends ElementConstructor {
//如果两点不是相邻点
//如果两点不是相邻点
}
else
if
(
pathMatirx
[
i
][
j
]
>
1
&&
pathMatirx
[
i
][
j
]
<
Integer
.
MAX_VALUE
)
{
}
else
if
(
pathMatirx
[
i
][
j
]
>
1
&&
pathMatirx
[
i
][
j
]
<
Integer
.
MAX_VALUE
)
{
int
k
=
preTable
[
i
][
j
];
int
k
=
preTable
[
i
][
j
];
pathNode
=
""
;
pathNode
=
""
;
while
(
k
!=
j
)
{
while
(
k
!=
j
)
{
...
@@ -252,7 +279,7 @@ public class MapConstructor extends ElementConstructor {
...
@@ -252,7 +279,7 @@ public class MapConstructor extends ElementConstructor {
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
"match,return-0"
,
"周围
有
{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundNpcBySite:"
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundNpcBySite:"
);
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
...
@@ -263,7 +290,18 @@ public class MapConstructor extends ElementConstructor {
...
@@ -263,7 +290,18 @@ public class MapConstructor extends ElementConstructor {
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
"match,return-0"
,
"周围有{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundGoodsBySite:"
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundGoodsBySite:"
);
jConfigList
.
add
(
jConfig
);
}
public
void
generateSurroundThings
(){
String
conditionName
=
"know_exist_what_mohu"
;
String
conditionKeywords
=
"有什么:周围+有什么:附近"
;
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundAllBySite:"
);
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
...
...
src/gameDesign/PlotConstructor.java
View file @
7d840a91
package
gameDesign
;
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
db.SqlHelper
;
import
com.qiwu.chatbotbackend.
db.SqlHelper
;
import
entity.JConfig
;
import
com.qiwu.chatbotbackend.
entity.JConfig
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.message.BasicNameValuePair
;
import
processing.MyFunc
;
import
com.qiwu.chatbotbackend.
processing.MyFunc
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.util.*
;
import
java.util.*
;
public
class
PlotConstructor
extends
ElementConstructor
{
public
class
PlotConstructor
extends
ElementConstructor
{
String
POST_URL
=
"http://localhost:1111/conditionProcess"
;
String
botName
=
""
;
JSONArray
plots
=
null
;
JSONArray
plots
=
null
;
HashMap
<
String
,
ArrayList
<
String
>>
adjList
=
new
HashMap
<
String
,
ArrayList
<
String
>>();
HashMap
<
String
,
ArrayList
<
String
>>
adjList
=
new
HashMap
<
String
,
ArrayList
<
String
>>();
HashMap
<
String
,
ArrayList
<
String
>>
revAdjList
=
new
HashMap
<
String
,
ArrayList
<
String
>>();
HashMap
<
String
,
ArrayList
<
String
>>
revAdjList
=
new
HashMap
<
String
,
ArrayList
<
String
>>();
HashMap
<
String
,
JSONObject
>
id2j
=
new
HashMap
<
String
,
JSONObject
>();
private
HashMap
<
String
,
JSONObject
>
id2j
=
new
HashMap
<
String
,
JSONObject
>();
HashMap
<
String
,
Boolean
>
visited
=
new
HashMap
<
String
,
Boolean
>();
HashMap
<
String
,
Boolean
>
visited
=
new
HashMap
<
String
,
Boolean
>();
public
HashMap
<
String
,
JSONObject
>
getId2j
()
{
return
id2j
;
}
public
PlotConstructor
(
SqlHelper
helper
,
int
botId
)
{
public
PlotConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
super
();
super
();
this
.
helper
=
helper
;
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
botId
=
botId
;
this
.
exceptRelation
=
exceptRelation
;
}
}
public
void
construct
(
JSONObject
jsonObject
,
UserInfo
userinfo
)
{
public
void
construct
(
JSONObject
jsonObject
,
UserInfo
userinfo
)
{
try
{
JSONArray
plots
=
jsonObject
.
getJSONArray
(
"plots"
);
JSONArray
plots
=
jsonObject
.
getJSONArray
(
"plots"
);
String
start
=
(
String
)
jsonObject
.
get
(
"start"
),
startCondition
;
String
start
=
(
String
)
jsonObject
.
get
(
"start"
),
startCondition
;
JSONObject
returnMessage
=
null
;
JSONObject
returnMessage
=
null
;
...
@@ -36,41 +43,31 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -36,41 +43,31 @@ public class PlotConstructor extends ElementConstructor {
this
.
plots
=
plots
;
this
.
plots
=
plots
;
constructAdjList
(
plots
);
constructAdjList
(
plots
);
if
(
id2j
.
containsKey
(
start
))
{
if
(
id2j
.
containsKey
(
start
))
{
JSONObject
data
=
new
JSONObject
();
startCondition
=
(
String
)
id2j
.
get
(
start
).
get
(
"conditionName"
);
data
.
put
(
"startCondition"
,
startCondition
);
data
.
put
(
"botName_yhm"
,
(
String
)
jsonObject
.
get
(
"botName"
));
data
.
put
(
"botName"
,
(
String
)
jsonObject
.
get
(
"botName"
));
data
.
put
(
"botId"
,
(
Integer
)
jsonObject
.
get
(
"botId"
));
data
.
put
(
"type"
,
"game_plot_init"
);
userinfo
.
extraInfo
.
put
(
"activeAction"
,
startCondition
);
try
{
returnMessage
=
MyFunc
.
postJSON
(
POST_URL
,
data
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
if
((
Integer
)
returnMessage
.
get
(
"status"
)
==
1
)
{
String
taskLineName
=
"任务线_"
+
id2j
.
get
(
start
).
get
(
"place"
)
+
"进度"
;
String
taskLineName
=
"任务线_"
+
id2j
.
get
(
start
).
get
(
"place"
)
+
"进度"
;
conditionDescription
.
put
(
taskLineName
,
taskLineName
);
conditionDescription
.
put
(
taskLineName
,
taskLineName
);
varInitialMap
.
put
(
taskLineName
,
start
);
varInitialMap
.
put
(
taskLineName
,
start
);
varInitialMap
.
put
(
"unknownText"
,
"你说啥?"
);
varInitialMap
.
put
(
"unknownText"
,
"你说啥?"
);
varInitialMap
.
put
(
"game_step"
,
(
String
)
id2j
.
get
(
start
).
get
(
"id"
));
conditionDescription
.
put
(
"unknownText"
,
"对于无法识别的问题做出的回答"
);
conditionDescription
.
put
(
"unknownText"
,
"对于无法识别的问题做出的回答"
);
conditionDescription
.
put
(
"game_step"
,
"QA问答游戏进度"
);
BFSGenerate4
(
id2j
.
get
(
start
),
userinfo
);
BFSGenerate4
(
id2j
.
get
(
start
),
userinfo
,
jsonObject
);
varInitialMap
.
put
(
start
,
"1"
);
varInitialMap
.
put
(
start
,
"1"
);
}
else
{
System
.
out
.
println
(
"剧情初始化失败"
);
}
}
else
{
}
else
{
System
.
out
.
println
(
"start剧情不存在"
);
System
.
out
.
println
(
"start剧情不存在"
);
operationStatus
=
0
;
message
=
"start剧情不存在"
;
return
;
}
}
catch
(
Exception
e
){
operationStatus
=
0
;
message
=
"地图接口处理出现异常"
;
return
;
}
}
}
}
...
@@ -590,7 +587,7 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -590,7 +587,7 @@ public class PlotConstructor extends ElementConstructor {
* @param root
* @param root
* @param userinfo
* @param userinfo
*/
*/
public
void
BFSGenerate4
(
JSONObject
root
,
UserInfo
userinfo
)
{
public
void
BFSGenerate4
(
JSONObject
root
,
UserInfo
userinfo
,
JSONObject
jsonObject
)
{
String
id
,
rootId
=
(
String
)
root
.
get
(
"id"
),
adjId
,
nextId
,
parentId
,
taskName
=
""
,
value
=
""
,
extraHP
=
""
,
extraUK
=
""
,
nextTaskName
,
keywordOptions
,
conditionName
,
String
id
,
rootId
=
(
String
)
root
.
get
(
"id"
),
adjId
,
nextId
,
parentId
,
taskName
=
""
,
value
=
""
,
extraHP
=
""
,
extraUK
=
""
,
nextTaskName
,
keywordOptions
,
conditionName
,
nextUnknownText
,
curUnknownText
,
nextCondition
,
location
,
nextLocation
,
taskLineName
,
nTaskLineName
,
lastTaskReply
,
lastTaskCondition
;
nextUnknownText
,
curUnknownText
,
nextCondition
,
location
,
nextLocation
,
taskLineName
,
nTaskLineName
,
lastTaskReply
,
lastTaskCondition
;
boolean
newBranch
,
manyParent
;
boolean
newBranch
,
manyParent
;
...
@@ -604,6 +601,12 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -604,6 +601,12 @@ public class PlotConstructor extends ElementConstructor {
root
.
put
(
"parentId"
,
"null"
);
root
.
put
(
"parentId"
,
"null"
);
String
startPlace
=
(
String
)
root
.
get
(
"place"
);
varInitialMap
.
put
(
"任务线"
+
startPlace
+
"最后一个condition"
,
(
String
)
root
.
get
(
"conditionName"
));
varInitialMap
.
put
(
"任务线"
+
startPlace
+
"最后的回答"
,
(
String
)
jsonObject
.
get
(
"plotStartText"
));
conditionDescription
.
put
(
"任务线"
+
startPlace
+
"最后一个condition"
,
"任务线"
+
startPlace
+
"最后一个condition"
);
conditionDescription
.
put
(
"任务线"
+
startPlace
+
"最后的回答"
,
"任务线"
+
startPlace
+
"最后的回答"
);
Queue
<
JSONObject
>
queue
=
new
LinkedList
<
JSONObject
>();
Queue
<
JSONObject
>
queue
=
new
LinkedList
<
JSONObject
>();
...
@@ -619,6 +622,7 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -619,6 +622,7 @@ public class PlotConstructor extends ElementConstructor {
taskLineName
=
"任务线_"
+
location
+
"进度"
;
taskLineName
=
"任务线_"
+
location
+
"进度"
;
conditionDescription
.
put
(
id
,
"剧情"
+
id
+
"状态"
);
conditionDescription
.
put
(
id
,
"剧情"
+
id
+
"状态"
);
varInitialMap
.
put
(
id
,
""
);
varInitialMap
.
put
(
id
,
""
);
nextUnknownText
=
""
;
//本任务线的最后一个condition和本任务线的最后一个回答
//本任务线的最后一个condition和本任务线的最后一个回答
...
@@ -648,7 +652,10 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -648,7 +652,10 @@ public class PlotConstructor extends ElementConstructor {
nextId
=
(
String
)
branchNode
.
get
(
"nextPlotId"
);
nextId
=
(
String
)
branchNode
.
get
(
"nextPlotId"
);
Map
<
String
,
String
>
updateKnowledge
=
JSONObject
.
toJavaObject
(
branchNode
.
getJSONObject
(
"updateKnowledge"
),
Map
.
class
);
Map
<
String
,
String
>
updateKnowledge
=
JSONObject
.
toJavaObject
(
branchNode
.
getJSONObject
(
"updateKnowledge"
),
Map
.
class
);
if
(
updateKnowledge
.
containsKey
(
"unkonwnText"
))
nextUnknownText
=
updateKnowledge
.
get
(
"unknownText"
);
nextUnknownText
=
updateKnowledge
.
get
(
"unknownText"
);
else
nextUnknownText
=
"unknown"
;
//如果存在下一剧情,就将下一步剧情的condition设为下一个激活的conditin,把地点更新为下一步剧情的地点,并更新任务线进度
//如果存在下一剧情,就将下一步剧情的condition设为下一个激活的conditin,把地点更新为下一步剧情的地点,并更新任务线进度
...
@@ -671,7 +678,7 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -671,7 +678,7 @@ public class PlotConstructor extends ElementConstructor {
extraHP
=
taskLineName
+
"::match-Include="
+
id
+
",site::match-Include="
+
location
+
","
+
id
+
"::number-BiggerOrEqual="
+
1
+
","
+
nextId
+
"::match-Include=null"
;
extraHP
=
taskLineName
+
"::match-Include="
+
id
+
",site::match-Include="
+
location
+
","
+
id
+
"::number-BiggerOrEqual="
+
1
+
","
+
nextId
+
"::match-Include=null"
;
extraUK
=
nTaskLineName
+
":"
+
nextId
+
"-<-site:"
+
nextLocation
+
"-<-"
+
lastTaskCondition
+
":var={nextStep-3}"
+
"-<-"
+
lastTaskReply
+
":var={reply-3}"
+
extraUK
=
nTaskLineName
+
":"
+
nextId
+
"-<-site:"
+
nextLocation
+
"-<-"
+
lastTaskCondition
+
":var={nextStep-3}"
+
"-<-"
+
lastTaskReply
+
":var={reply-3}"
+
"-<-"
+
id
+
":"
+
"+1-<-"
+
nextId
+
":"
+
"+1"
;
;
"-<-"
+
id
+
":"
+
"+1-<-"
+
nextId
+
":"
+
"+1"
+
"-<-game_step:"
+
botName
+
"_plot_"
+
nextId
;
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
String
.
class
),
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
String
.
class
),
...
@@ -712,6 +719,7 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -712,6 +719,7 @@ public class PlotConstructor extends ElementConstructor {
//对于unknown的特殊处理
//对于unknown的特殊处理
//对于unknown的特殊处理
if
(
curUnknownText
.
equals
(
""
))
{
if
(
curUnknownText
.
equals
(
""
))
{
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include=unknown"
,
conditionName
+
"::match-Include=unknown"
,
...
@@ -726,29 +734,68 @@ public class PlotConstructor extends ElementConstructor {
...
@@ -726,29 +734,68 @@ public class PlotConstructor extends ElementConstructor {
}
}
/**
* ----------------------------------------------------------------------------------------------------
* 待激活列表,用于qa问答
*/
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
" "
,
"
"
,
""
,
"
"
,
" "
,
""
" "
,
"
qa_status::match-Include=not_found"
,
"match,return-0"
,
"{unknownText-2}
"
,
" "
,
""
);
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown"
);
jConfig
.
setConfigName
(
"unknown
1
"
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
jConfig
=
new
JConfig
(
" "
,
""
,
""
,
" "
,
" "
,
""
" "
,
"qa_status::match-Include=not_found,unknownText::match-Include=null"
,
"match,return-0"
,
"不好意思,我没听懂你刚才说的话,请换个别的问题试试吧~哎呀,刚才开了小差,没理解你的意思,请换个问题吧~请根据上文信息,认真回答吧,谢谢~我们好像不在一个频道上,换个问题试试,希望我们能够接轨上吧"
,
" "
,
""
);
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"common_answer"
);
jConfig
.
setConfigName
(
"unknown2"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=ok,qa_score::number-Smaller=90,unknownText::match-Include=null"
,
"match,return-0"
,
"不好意思,我没听懂你刚才说的话,请换个别的问题试试吧~哎呀,刚才开了小差,没理解你的意思,请换个问题吧~请根据上文信息,认真回答吧,谢谢~我们好像不在一个频道上,换个问题试试,希望我们能够接轨上吧"
,
" "
,
""
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown3"
);
jConfig
.
setjStatus
(
1
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=ok,qa_score::number-Smaller=90"
,
"match,return-0"
,
"{unknownText-2}"
,
" "
,
""
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown4"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=ok,qa_score::number-BiggerOrEqual=90"
,
"match,return-0"
,
"{common_answer-2}"
,
" "
,
""
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"common_answer"
);
jConfigList
.
add
(
jConfig
);
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
}
}
@Override
@Override
public
void
postProcessing
(
List
<
Integer
>
idList
){
public
void
postProcessing
(
List
<
Integer
>
idList
,
int
categoryId
){
if
(
idList
.
size
()
!=
0
)
{
if
(
idList
.
size
()
!=
0
)
{
jConfig
=
new
JConfig
(
" "
,
""
,
"activate"
,
""
,
idList
.
get
(
idList
.
size
()
-
2
)
+
","
+
idList
.
get
(
idList
.
size
()
-
1
),
""
);
jConfig
=
new
JConfig
(
" "
,
" "
,
"activate,post::all(http://simqa.sz.chewrobot.com:28081/game)"
,
""
,
idList
.
get
(
idList
.
size
()
-
5
)
+
","
+
idList
.
get
(
idList
.
size
()
-
4
)
+
","
+
idList
.
get
(
idList
.
size
()
-
3
)
+
","
+
idList
.
get
(
idList
.
size
()
-
2
)
+
","
+
idList
.
get
(
idList
.
size
()
-
1
),
""
);
jConfig
.
setNextStepStatus
(
"active"
);
JSONObject
json
=
jConfig
.
toJson
(
this
.
getConditionDescription
());
helper
.
insertConfigByBotId
(
botId
,
json
,
idList
,
categoryId
);
jConfigList
.
add
(
jConfig
);
jConfigList
.
add
(
jConfig
);
}
}
}
}
...
...
src/main/java/META-INF/MANIFEST.MF
deleted
100644 → 0
View file @
f8d00711
Manifest-Version: 1.0
Main-Class: com.qiwu.chatbotbackend.ChatbotBackendApplication
src/main/java/com/qiwu/chatbotbackend/GameEnvironment/DBUtil.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
;
import
com.qiwu.chatbotbackend.db.C3p0Utils
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
public
class
DBUtil
{
public
static
String
queryEnvJsonByBotName
(
String
botName
)
throws
Exception
{
Connection
conn
=
C3p0Utils
.
getConnection
();
String
sql
=
"select * from generate_json_tb where bot_name = ?"
;
String
result
=
"{}"
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
String
.
valueOf
(
botName
));
ResultSet
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
())
result
=
rs
.
getString
(
"env_json_text"
);
ps
.
close
();
rs
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
conn
!=
null
)
{
try
{
conn
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
return
result
;
}
}
src/main/java/com/qiwu/chatbotbackend/GameEnvironment/GameEnv.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
com.alibaba.fastjson.JSON
;
import
com.qiwu.chatbotbackend.GameEnvironment.bean.Attr
;
import
com.qiwu.chatbotbackend.GameEnvironment.bean.GoodsInstance
;
import
com.qiwu.chatbotbackend.GameEnvironment.bean.SuperClass
;
import
com.qiwu.chatbotbackend.GameEnvironment.bean.NpcInstance
;
import
com.qiwu.chatbotbackend.GameEnvironment.bean.Place
;
public
class
GameEnv
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
public
Map
<
String
,
SuperClass
>
npcClassIndex
;
public
Map
<
String
,
NpcInstance
>
npcInstanceIndex
;
public
Map
<
String
,
SuperClass
>
goodsClassIndex
;
public
Map
<
String
,
GoodsInstance
>
goodsInstanceIndex
;
public
Map
<
String
,
Place
>
placeIndex
;
public
GameEnv
(
String
botName
)
throws
Exception
{
// 通过文件来初始化游戏环境
// String fullName = "E:\\projects\\env\\"+projectId+".json";
//
// String jsonString = Util.getJsonString(fullName);
String
jsonString
=
DBUtil
.
queryEnvJsonByBotName
(
botName
);
Map
<
String
,
Object
>
gameProjectMap
=
JSON
.
parseObject
(
jsonString
);
// System.out.println(gameProjectMap);
if
(!
gameProjectMap
.
isEmpty
())
{
// 地图
Map
<
String
,
Object
>
map
=
(
Map
<
String
,
Object
>)
gameProjectMap
.
get
(
"map"
);
this
.
placeIndex
=
new
HashMap
<
String
,
Place
>();
Map
<
String
,
Object
>
placeMapTmp
=
new
HashMap
();
if
(!
map
.
isEmpty
())
{
for
(
String
key:
map
.
keySet
())
{
Map
<
String
,
Object
>
one
=
(
Map
<
String
,
Object
>)
map
.
get
(
key
);
placeMapTmp
.
put
(
key
,
(
String
)
one
.
get
(
"name"
));
Place
place
=
new
Place
();
place
.
setIntro
((
String
)
one
.
get
(
"intro"
));
place
.
setName
((
String
)
one
.
get
(
"name"
));
placeIndex
.
put
((
String
)
one
.
get
(
"name"
),
place
);
}
for
(
String
tmp:
placeMapTmp
.
keySet
())
{
List
<
Place
>
ableGos
=
new
ArrayList
<
Place
>();
List
<
Long
>
ableGoLongs
=
(
List
<
Long
>)((
Map
<
String
,
Object
>)
map
.
get
(
tmp
)).
get
(
"canGo"
);
for
(
int
j
=
0
;
j
<
ableGoLongs
.
size
();
j
++)
{
String
idName
=
String
.
valueOf
(
ableGoLongs
.
get
(
j
));
ableGos
.
add
(
placeIndex
.
get
(
placeMapTmp
.
get
(
idName
)));
}
placeIndex
.
get
(
placeMapTmp
.
get
(
tmp
)).
setAbleGo
(
ableGos
);
}
}
// npc
// npc class
Map
<
String
,
Object
>
npcClasses
=
(
Map
<
String
,
Object
>)
gameProjectMap
.
get
(
"npc"
);
Map
<
String
,
Object
>
npcNames
=
new
HashMap
<
String
,
Object
>();
this
.
npcClassIndex
=
new
HashMap
<
String
,
SuperClass
>();
this
.
npcInstanceIndex
=
new
HashMap
<
String
,
NpcInstance
>();
if
(!
npcClasses
.
isEmpty
())
{
for
(
String
classKey:
npcClasses
.
keySet
())
{
Map
<
String
,
Object
>
one
=
(
Map
<
String
,
Object
>)
npcClasses
.
get
(
classKey
);
// class
Map
<
String
,
Object
>
oneClass
=
(
Map
<
String
,
Object
>)
one
.
get
(
"class"
);
SuperClass
npcClass
=
new
SuperClass
();
npcClass
.
setName
(
classKey
);
npcClass
.
setIntro
((
String
)
oneClass
.
get
(
"intro"
));
List
<
Attr
>
attrs
=
new
ArrayList
<
Attr
>();
for
(
String
attrKey:
oneClass
.
keySet
())
{
if
(!
attrKey
.
equals
(
"intro"
)
&&
!
attrKey
.
equals
(
"class"
)
&&
!
attrKey
.
equals
(
""
))
{
Attr
attr
=
new
Attr
();
attr
.
setName
(
attrKey
);
attr
.
setValue
((
String
)
oneClass
.
get
(
attrKey
));
attrs
.
add
(
attr
);
}
}
npcClass
.
setAttrs
(
attrs
);
// instance
Map
<
String
,
Object
>
instances
=
(
Map
<
String
,
Object
>)
one
.
get
(
"instance"
);
for
(
String
instanceKey:
instances
.
keySet
())
{
Map
<
String
,
Object
>
instance
=
new
HashMap
<
String
,
Object
>();
NpcInstance
npcInstance
=
new
NpcInstance
();
Map
<
String
,
Object
>
instanceAttrMap
=
(
Map
<
String
,
Object
>)
instances
.
get
(
instanceKey
);
npcNames
.
put
(
instanceKey
,
(
String
)
instanceAttrMap
.
get
(
"name"
));
npcInstance
.
setName
((
String
)
instanceAttrMap
.
get
(
"name"
));
npcInstance
.
setIntro
((
String
)
instanceAttrMap
.
get
(
"intro"
));
List
<
Attr
>
npcInstanceAttrs
=
new
ArrayList
<
Attr
>();
for
(
String
instanceAttrKey:
instanceAttrMap
.
keySet
())
{
if
(!
instanceAttrKey
.
equals
(
"name"
)&&!
instanceAttrKey
.
equals
(
"intro"
)&&!
instanceAttrKey
.
equals
(
"placeId"
)&&!
instanceAttrKey
.
equals
(
"placeName"
)&&!
instanceAttrKey
.
equals
(
"class"
))
{
Attr
attr
=
new
Attr
();
attr
.
setName
(
instanceAttrKey
);
attr
.
setValue
((
String
)
instanceAttrMap
.
get
(
instanceAttrKey
));
npcInstanceAttrs
.
add
(
attr
);
}
}
npcInstance
.
setAttrs
(
npcInstanceAttrs
);
Place
place
=
placeIndex
.
get
(((
Map
<
String
,
Object
>)
map
.
get
(
String
.
valueOf
(
instanceAttrMap
.
get
(
"placeId"
)))).
get
(
"name"
));
List
<
NpcInstance
>
npcInstances
=
place
.
getNpcInstances
();
if
(
npcInstances
==
null
)
{
npcInstances
=
new
ArrayList
<
NpcInstance
>();
}
npcInstances
.
add
(
npcInstance
);
place
.
setNpcInstances
(
npcInstances
);
List
<
NpcInstance
>
npcInstanceClass
=
npcClass
.
getNpcInstances
();
if
(
npcInstanceClass
==
null
)
{
npcInstanceClass
=
new
ArrayList
<
NpcInstance
>();
}
npcInstanceClass
.
add
(
npcInstance
);
npcClass
.
setNpcInstances
(
npcInstanceClass
);
npcInstance
.
setPlace
(
place
);
this
.
npcInstanceIndex
.
put
((
String
)
instanceAttrMap
.
get
(
"name"
),
npcInstance
);
}
this
.
npcClassIndex
.
put
(
classKey
,
npcClass
);
}
}
// goods
Map
<
String
,
Object
>
goodsClasses
=
(
Map
<
String
,
Object
>)
gameProjectMap
.
get
(
"goods"
);
this
.
goodsClassIndex
=
new
HashMap
<
String
,
SuperClass
>();
this
.
goodsInstanceIndex
=
new
HashMap
<
String
,
GoodsInstance
>();
if
(!
goodsClasses
.
isEmpty
())
{
for
(
String
classKey:
goodsClasses
.
keySet
())
{
Map
<
String
,
Object
>
one
=
(
Map
<
String
,
Object
>)
goodsClasses
.
get
(
classKey
);
// class
Map
<
String
,
Object
>
oneClass
=
(
Map
<
String
,
Object
>)
one
.
get
(
"class"
);
SuperClass
goodsClass
=
new
SuperClass
();
goodsClass
.
setName
(
classKey
);
goodsClass
.
setIntro
((
String
)
oneClass
.
get
(
"intro"
));
List
<
Attr
>
attrs
=
new
ArrayList
<
Attr
>();
for
(
String
attrKey:
oneClass
.
keySet
())
{
if
(!
attrKey
.
equals
(
"intro"
)&&!
attrKey
.
equals
(
"placeId"
)&&!
attrKey
.
equals
(
"npcName"
)&&!
attrKey
.
equals
(
"class"
)&&!
attrKey
.
equals
(
"placeName"
))
{
Attr
attr
=
new
Attr
();
attr
.
setName
(
attrKey
);
attr
.
setValue
((
String
)
oneClass
.
get
(
attrKey
));
attrs
.
add
(
attr
);
}
}
goodsClass
.
setAttrs
(
attrs
);
// instance
Map
<
String
,
Object
>
instances
=
(
Map
<
String
,
Object
>)
one
.
get
(
"instance"
);
for
(
String
instanceKey:
instances
.
keySet
())
{
Map
<
String
,
Object
>
instance
=
new
HashMap
<
String
,
Object
>();
GoodsInstance
goodsInstance
=
new
GoodsInstance
();
Map
<
String
,
Object
>
instanceAttrMap
=
(
Map
<
String
,
Object
>)
instances
.
get
(
instanceKey
);
goodsInstance
.
setName
((
String
)
instanceAttrMap
.
get
(
"name"
));
goodsInstance
.
setIntro
((
String
)
instanceAttrMap
.
get
(
"intro"
));
List
<
Attr
>
goodsInstanceAttrs
=
new
ArrayList
<
Attr
>();
for
(
String
instanceAttrKey:
instanceAttrMap
.
keySet
())
{
if
(
instanceAttrKey
!=
"placeId"
&&
instanceAttrKey
!=
"npcId"
&&
instanceAttrKey
!=
"name"
&&
instanceAttrKey
!=
"intro"
)
{
Attr
attr
=
new
Attr
();
attr
.
setName
(
instanceAttrKey
);
attr
.
setValue
((
String
)
instanceAttrMap
.
get
(
instanceAttrKey
));
goodsInstanceAttrs
.
add
(
attr
);
}
}
goodsInstance
.
setAttrs
(
goodsInstanceAttrs
);
Place
place
=
placeIndex
.
get
(((
Map
<
String
,
Object
>)
map
.
get
(
String
.
valueOf
(
instanceAttrMap
.
get
(
"placeId"
)))).
get
(
"name"
));
goodsInstance
.
setPlace
(
place
);
List
<
GoodsInstance
>
placeGoodsInstances
=
place
.
getGoodsInstances
();
if
(
placeGoodsInstances
==
null
)
{
placeGoodsInstances
=
new
ArrayList
<
GoodsInstance
>();
}
placeGoodsInstances
.
add
(
goodsInstance
);
place
.
setGoodsInstances
(
placeGoodsInstances
);
if
(
instanceAttrMap
.
get
(
"npcId"
)!=
null
){
NpcInstance
npc
=
this
.
npcInstanceIndex
.
get
(
npcNames
.
get
(
String
.
valueOf
(
instanceAttrMap
.
get
(
"npcId"
))));
goodsInstance
.
setNpc
(
npc
);
List
<
GoodsInstance
>
npcGoodsInstances
=
npc
.
getGoodsInstances
();
if
(
npcGoodsInstances
==
null
)
{
npcGoodsInstances
=
new
ArrayList
<
GoodsInstance
>();
}
npcGoodsInstances
.
add
(
goodsInstance
);
npc
.
setGoodsInstances
(
npcGoodsInstances
);
}
List
<
GoodsInstance
>
goodsInstancesClass
=
goodsClass
.
getGoodsInstances
();
if
(
goodsInstancesClass
==
null
)
{
goodsInstancesClass
=
new
ArrayList
<
GoodsInstance
>();
}
goodsInstancesClass
.
add
(
goodsInstance
);
goodsClass
.
setGoodsInstances
(
goodsInstancesClass
);
this
.
goodsInstanceIndex
.
put
((
String
)
instanceAttrMap
.
get
(
"name"
),
goodsInstance
);
}
this
.
goodsClassIndex
.
put
(
classKey
,
goodsClass
);
}
}
}
}
/********************************************地点******************************************/
// 周围有什么
public
List
<
String
>
queryAroundAllBySite
(
String
site
){
List
<
String
>
queryGoods
=
this
.
queryAroundGoodsBySite
(
site
);
List
<
String
>
queryNpc
=
this
.
queryAroundNpcBySite
(
site
);
queryGoods
.
addAll
(
queryNpc
);
return
queryGoods
;
}
// 周围有什么人
public
List
<
String
>
queryAroundNpcBySite
(
String
site
){
Place
place
=
this
.
placeIndex
.
get
(
site
);
List
<
String
>
queryNpc
=
new
ArrayList
<
String
>();
if
(
place
!=
null
)
{
List
<
NpcInstance
>
npcInstances
=
place
.
getNpcInstances
();
if
(
npcInstances
!=
null
)
{
for
(
int
i
=
0
;
i
<
npcInstances
.
size
();
i
++)
{
queryNpc
.
add
(
npcInstances
.
get
(
i
).
getName
());
}
}
}
return
queryNpc
;
}
// 周围有什么物品
public
List
<
String
>
queryAroundGoodsBySite
(
String
site
){
Place
place
=
this
.
placeIndex
.
get
(
site
);
List
<
String
>
queryGoods
=
new
ArrayList
<
String
>();
if
(
place
!=
null
)
{
List
<
GoodsInstance
>
goodsInstances
=
place
.
getGoodsInstances
();
if
(
goodsInstances
!=
null
)
{
for
(
int
i
=
0
;
i
<
goodsInstances
.
size
();
i
++)
{
queryGoods
.
add
(
goodsInstances
.
get
(
i
).
getName
());
}
}
}
return
queryGoods
;
}
// 我现在能去哪
public
List
<
String
>
queryCanGoBySite
(
String
site
){
List
<
String
>
ableGoString
=
new
ArrayList
<
String
>();
Place
place
=
this
.
placeIndex
.
get
(
site
);
List
<
Place
>
ableGos
=
place
.
getAbleGo
();
for
(
int
i
=
0
;
i
<
ableGos
.
size
();
i
++)
{
ableGoString
.
add
(
ableGos
.
get
(
i
).
getName
());
}
return
ableGoString
;
}
// 两点之间的路径
public
List
<
String
>
queryPathBySite
(
String
start
,
String
destination
){
return
null
;
}
/**************************************物品***************************/
// 通过类和地点查询所有物品名称
public
List
<
String
>
queryGoodsByClassAndSite
(
String
className
,
String
site
){
List
<
String
>
goodsNames
=
new
ArrayList
<
String
>();
List
<
GoodsInstance
>
placeGoodsInstances
=
null
;
List
<
GoodsInstance
>
goodsInstances
=
null
;
if
(
this
.
placeIndex
.
get
(
site
)!=
null
&&
this
.
goodsClassIndex
.
get
(
className
)!=
null
)
{
placeGoodsInstances
=
this
.
placeIndex
.
get
(
site
).
getGoodsInstances
();
goodsInstances
=
this
.
goodsClassIndex
.
get
(
className
).
getGoodsInstances
();
for
(
int
i
=
0
;
i
<
placeGoodsInstances
.
size
();
i
++)
{
for
(
int
j
=
0
;
j
<
goodsInstances
.
size
();
j
++)
{
if
(
placeGoodsInstances
.
get
(
i
)
==
goodsInstances
.
get
(
j
))
{
goodsNames
.
add
(
placeGoodsInstances
.
get
(
i
).
getName
());
}
}
}
}
return
goodsNames
;
}
// 查询指定物品
public
GoodsInstance
queryGoodsByGoodsName
(
String
name
){
GoodsInstance
goodsInstance
=
this
.
goodsInstanceIndex
.
get
(
name
);
return
goodsInstance
;
}
// 查询指定物品的简介
public
String
queryGoodsIntroByGoodsName
(
String
name
){
GoodsInstance
goodsInstance
=
this
.
queryGoodsByGoodsName
(
name
);
if
(
goodsInstance
!=
null
)
{
return
goodsInstance
.
getIntro
();
}
else
{
return
null
;
}
}
// 查询指定物品的属性值
public
String
queryGoodsAttrByGoodsName
(
String
name
,
String
attrName
){
GoodsInstance
goodsInstance
=
queryGoodsByGoodsName
(
name
);
if
(
goodsInstance
==
null
)
{
goodsInstance
=
queryGoodsByGoodsName
(
attrName
);
attrName
=
name
;
}
if
(
goodsInstance
!=
null
)
{
List
<
Attr
>
attrs
=
goodsInstance
.
getAttrs
();
if
(
attrName
.
equals
(
"location"
))
{
if
(
goodsInstance
.
getPlace
()!=
null
)
{
return
goodsInstance
.
getPlace
().
getName
();
}
}
if
(
attrName
.
equals
(
"owner"
))
{
if
(
goodsInstance
.
getNpc
()!=
null
)
{
return
goodsInstance
.
getNpc
().
getName
();
}
}
for
(
int
i
=
0
;
i
<
attrs
.
size
();
i
++)
{
if
(
attrs
.
get
(
i
).
getName
().
equals
(
attrName
))
{
return
attrs
.
get
(
i
).
getValue
();
}
}
return
null
;
}
else
{
return
null
;
}
}
// 查询指定物品的所有属性
public
List
<
String
>
queryGoodsAllAttrByGoodsName
(
String
name
){
List
<
String
>
attrnames
=
new
ArrayList
<
String
>();
GoodsInstance
goodsInstance
=
queryGoodsByGoodsName
(
name
);
if
(
goodsInstance
!=
null
)
{
List
<
Attr
>
attrs
=
goodsInstance
.
getAttrs
();
for
(
int
i
=
0
;
i
<
attrs
.
size
();
i
++)
{
attrnames
.
add
(
attrs
.
get
(
i
).
getName
());
}
return
attrnames
;
}
else
{
return
null
;
}
}
/**************************************npc*****************************************/
// 通过地点和类查询所有的npc名陈
public
List
<
String
>
queryNpcByClassAndSite
(
String
className
,
String
site
){
List
<
String
>
npcNames
=
new
ArrayList
<
String
>();
List
<
NpcInstance
>
placeNpcInstances
=
this
.
placeIndex
.
get
(
site
).
getNpcInstances
();
List
<
NpcInstance
>
npcInstances
=
this
.
goodsClassIndex
.
get
(
className
).
getNpcInstances
();
NpcInstance
npcInstance
=
new
NpcInstance
();
for
(
int
i
=
0
;
i
<
placeNpcInstances
.
size
();
i
++)
{
for
(
int
j
=
0
;
j
<
npcInstances
.
size
();
j
++)
{
if
(
placeNpcInstances
.
get
(
i
)
==
npcInstances
.
get
(
j
))
{
npcNames
.
add
(
placeNpcInstances
.
get
(
i
).
getName
());
}
}
}
return
npcNames
;
}
// 查询指定的npc
public
NpcInstance
queryNpcByNpcName
(
String
npcName
){
NpcInstance
npcInstance
=
this
.
npcInstanceIndex
.
get
(
npcName
);
return
npcInstance
;
}
// 查询指定NPC简介
public
String
queryNpcIntroByNpcName
(
String
name
){
NpcInstance
npcInstance
=
queryNpcByNpcName
(
name
);
if
(
npcInstance
!=
null
)
{
return
npcInstance
.
getIntro
();
}
else
{
return
null
;
}
}
// 查询指定npc的属性值
public
String
queryNpcAttrByNpcName
(
String
name
,
String
attrName
){
NpcInstance
npcInstance
=
queryNpcByNpcName
(
name
);
if
(
npcInstance
==
null
)
{
npcInstance
=
queryNpcByNpcName
(
attrName
);
attrName
=
name
;
}
if
(
attrName
.
equals
(
"location"
))
{
if
(
npcInstance
.
getPlace
()!=
null
)
{
return
npcInstance
.
getPlace
().
getName
();
}
}
if
(
npcInstance
!=
null
)
{
List
<
Attr
>
attrs
=
npcInstance
.
getAttrs
();
for
(
int
i
=
0
;
i
<
attrs
.
size
();
i
++)
{
if
(
attrs
.
get
(
i
).
getName
().
equals
(
attrName
))
{
return
attrs
.
get
(
i
).
getValue
();
}
}
return
null
;
}
else
{
return
null
;
}
}
// 查询指定npc的所有属性
public
List
<
String
>
queryNpcAttrsByNpcName
(
String
name
){
List
<
String
>
attrNames
=
new
ArrayList
<
String
>();
NpcInstance
npcInstance
=
queryNpcByNpcName
(
name
);
if
(
npcInstance
!=
null
)
{
List
<
Attr
>
attrs
=
npcInstance
.
getAttrs
();
for
(
int
i
=
0
;
i
<
attrs
.
size
();
i
++)
{
attrNames
.
add
(
attrs
.
get
(
i
).
getName
());
}
return
attrNames
;
}
else
{
return
null
;
}
}
// 增加
public
boolean
insert
(
String
name
){
String
[]
names
=
name
.
split
(
"_"
);
if
(
names
.
length
==
3
){
if
(
names
[
0
].
equals
(
"goods"
)){
SuperClass
goodsClass
=
this
.
goodsClassIndex
.
get
(
names
[
1
]);
List
<
Attr
>
goodsClassAttrs
=
goodsClass
.
getAttrs
();
GoodsInstance
goodsInstance
=
new
GoodsInstance
();
List
<
Attr
>
goodsInstanceAttr
=
new
ArrayList
<
Attr
>();
goodsInstance
.
setName
(
names
[
2
]);
goodsInstance
.
setIntro
(
goodsClass
.
getIntro
());
for
(
int
i
=
0
;
i
<
goodsClassAttrs
.
size
();
i
++){
Attr
attr
=
new
Attr
();
attr
.
setName
(
goodsClassAttrs
.
get
(
i
).
getName
());
attr
.
setValue
(
goodsClassAttrs
.
get
(
i
).
getValue
());
goodsInstanceAttr
.
add
(
attr
);
}
goodsInstance
.
setAttrs
(
goodsInstanceAttr
);
this
.
goodsInstanceIndex
.
put
(
names
[
2
],
goodsInstance
);
return
true
;
}
else
if
(
names
[
0
].
equals
(
"npc"
))
{
SuperClass
npcClass
=
this
.
npcClassIndex
.
get
(
names
[
1
]);
List
<
Attr
>
npcClassAttrs
=
npcClass
.
getAttrs
();
NpcInstance
npcInstance
=
new
NpcInstance
();
List
<
Attr
>
npcInstanceAttr
=
new
ArrayList
<
Attr
>();
npcInstance
.
setName
(
names
[
2
]);
npcInstance
.
setIntro
(
npcClass
.
getIntro
());
for
(
int
i
=
0
;
i
<
npcClassAttrs
.
size
();
i
++){
Attr
attr
=
new
Attr
();
attr
.
setName
(
npcClassAttrs
.
get
(
i
).
getName
());
attr
.
setValue
(
npcClassAttrs
.
get
(
i
).
getValue
());
npcInstanceAttr
.
add
(
attr
);
}
npcInstance
.
setAttrs
(
npcInstanceAttr
);
this
.
npcInstanceIndex
.
put
(
names
[
2
],
npcInstance
);
return
true
;
}
else
{
return
false
;
}
}
else
{
return
false
;
}
}
// 改变
public
boolean
update
(
String
name
,
String
value
)
{
String
[]
names
=
name
.
split
(
"_"
);
if
(
names
.
length
==
4
){
if
(
names
[
0
].
equals
(
"goods"
)){
List
<
GoodsInstance
>
goodsInstancesByClass
=
this
.
goodsClassIndex
.
get
(
names
[
1
]).
getGoodsInstances
();
boolean
goodsInstanceBoolean
=
false
;
GoodsInstance
goodsInstance
=
this
.
goodsInstanceIndex
.
get
(
names
[
2
]);
for
(
int
i
=
0
;
i
<
goodsInstancesByClass
.
size
();
i
++)
{
if
(
goodsInstance
==
goodsInstancesByClass
.
get
(
i
))
{
goodsInstanceBoolean
=
true
;
}
}
if
(
goodsInstanceBoolean
)
{
List
<
Attr
>
attrs
=
goodsInstance
.
getAttrs
();
for
(
int
j
=
0
;
j
<
attrs
.
size
();
j
++)
{
if
(
names
[
3
].
equals
(
attrs
.
get
(
j
).
getName
()))
{
attrs
.
get
(
j
).
setValue
(
value
);
return
true
;
}
}
return
true
;
}
else
{
return
false
;
}
}
else
if
(
names
[
0
].
equals
(
"npc"
))
{
List
<
NpcInstance
>
npcInstancesByClass
=
this
.
npcClassIndex
.
get
(
names
[
1
]).
getNpcInstances
();
boolean
npcInstanceBoolean
=
false
;
NpcInstance
npcInstance
=
this
.
npcInstanceIndex
.
get
(
names
[
2
]);
for
(
int
i
=
0
;
i
<
npcInstancesByClass
.
size
();
i
++)
{
if
(
npcInstance
==
npcInstancesByClass
.
get
(
i
))
{
npcInstanceBoolean
=
true
;
}
}
if
(
npcInstanceBoolean
)
{
List
<
Attr
>
attrs
=
npcInstance
.
getAttrs
();
for
(
int
j
=
0
;
j
<
attrs
.
size
();
j
++)
{
if
(
names
[
3
].
equals
(
attrs
.
get
(
j
).
getName
()))
{
attrs
.
get
(
j
).
setValue
(
value
);
return
true
;
}
}
return
true
;
}
else
{
return
false
;
}
}
}
return
false
;
}
// 增删改通用
public
boolean
CUD
(
String
name
,
String
operator
,
String
value
){
if
(
operator
.
equals
(
"insert"
))
{
return
this
.
insert
(
name
);
}
else
if
(
operator
.
equals
(
"update"
))
{
return
this
.
update
(
name
,
value
);
}
else
if
(
operator
.
equals
(
"delete"
))
{
return
false
;
}
else
{
return
false
;
}
}
}
src/main/java/com/qiwu/chatbotbackend/GameEnvironment/ObjectFileUtil.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.IOException
;
import
java.io.ObjectInputStream
;
import
java.io.ObjectOutputStream
;
public
class
ObjectFileUtil
{
// obj 任意可以序列化的对象 fileAllName 文件全名
public
static
boolean
writeObjectToFile
(
Object
obj
,
String
fileAllName
)
{
File
file
=
new
File
(
fileAllName
);
FileOutputStream
out
;
try
{
out
=
new
FileOutputStream
(
file
);
ObjectOutputStream
objOut
=
new
ObjectOutputStream
(
out
);
objOut
.
writeObject
(
obj
);
objOut
.
flush
();
objOut
.
close
();
return
true
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
false
;
}
}
// fileAllName 文件全名
public
static
Object
readObjectFromFile
(
String
fileAllName
)
{
Object
temp
=
null
;
File
file
=
new
File
(
fileAllName
);
FileInputStream
in
;
try
{
in
=
new
FileInputStream
(
file
);
ObjectInputStream
objIn
=
new
ObjectInputStream
(
in
);
temp
=
objIn
.
readObject
();
objIn
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
catch
(
ClassNotFoundException
e
)
{
e
.
printStackTrace
();
}
return
temp
;
}
}
src/main/java/com/qiwu/chatbotbackend/GameEnvironment/Util.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.Reader
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
public
class
Util
{
public
static
String
getJsonString
(
String
fullName
)
{
Reader
reader
=
null
;
String
jsonString
=
""
;
try
{
// System.out.println("以字符为单位读取文件内容,一次读多个字节:");
// 一次读多个字符
char
[]
tempchars
=
new
char
[
256
];
int
charread
=
0
;
reader
=
new
InputStreamReader
(
new
FileInputStream
(
fullName
));
// 读入多个字符到字符数组中,charread为一次读取字符数
while
((
charread
=
reader
.
read
(
tempchars
))
!=
-
1
)
{
// 同样屏蔽掉\r不显示
if
((
charread
==
tempchars
.
length
)
&&
(
tempchars
[
tempchars
.
length
-
1
]
!=
'\r'
))
{
// System.out.println(tempchars);
jsonString
=
jsonString
+
String
.
valueOf
(
tempchars
);
// System.out.print(tempchars);
}
else
{
for
(
int
i
=
0
;
i
<
charread
;
i
++)
{
if
(
tempchars
[
i
]
==
'\r'
)
{
continue
;
}
else
{
jsonString
=
jsonString
+
tempchars
[
i
];
// System.out.print(tempchars[i]);
}
}
}
}
}
catch
(
Exception
e1
)
{
e1
.
printStackTrace
();
}
finally
{
if
(
reader
!=
null
)
{
try
{
reader
.
close
();
}
catch
(
IOException
e1
)
{
}
}
}
return
jsonString
;
}
}
src/main/java/com/qiwu/chatbotbackend/GameEnvironment/bean/Attr.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
public
class
Attr
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
value
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
@Override
public
String
toString
()
{
return
"Attr [name="
+
name
+
", value="
+
value
+
"]"
;
}
}
src/main/java/com/qiwu/chatbotbackend/GameEnvironment/bean/GoodsInstance.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
GoodsInstance
extends
SuperClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
Place
place
;
private
NpcInstance
npc
;
public
Place
getPlace
()
{
return
place
;
}
public
void
setPlace
(
Place
place
)
{
this
.
place
=
place
;
}
public
NpcInstance
getNpc
()
{
return
npc
;
}
public
void
setNpc
(
NpcInstance
npc
)
{
this
.
npc
=
npc
;
}
@Override
public
String
toString
()
{
String
placeName
=
""
;
if
(
place
!=
null
)
{
placeName
=
place
.
getName
();
}
String
npcName
=
""
;
if
(
npc
!=
null
)
{
npcName
=
npc
.
getName
();
}
return
super
.
toString
()+
"GoodsInstance [placeName="
+
placeName
+
", npcName="
+
npcName
+
"]"
;
}
}
src/main/java/com/qiwu/chatbotbackend/GameEnvironment/bean/NpcInstance.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
NpcInstance
extends
SuperClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
Place
place
;
private
List
<
GoodsInstance
>
goodsInstances
;
public
Place
getPlace
()
{
return
place
;
}
public
void
setPlace
(
Place
place
)
{
this
.
place
=
place
;
}
public
List
<
GoodsInstance
>
getGoodsInstances
()
{
return
goodsInstances
;
}
public
void
setGoodsInstances
(
List
<
GoodsInstance
>
goodsInstances
)
{
this
.
goodsInstances
=
goodsInstances
;
}
@Override
public
String
toString
()
{
String
placeName
=
""
;
if
(
place
!=
null
)
{
placeName
=
place
.
getName
();
}
int
goodsInstancesSize
=
0
;
if
(
goodsInstances
!=
null
)
{
goodsInstancesSize
=
goodsInstances
.
size
();
}
return
super
.
toString
()+
"NpcInstance [placeName="
+
placeName
+
", goodsInstancesSize="
+
goodsInstancesSize
+
"]"
;
}
}
src/main/java/com/qiwu/chatbotbackend/GameEnvironment/bean/Place.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
Place
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
intro
;
private
List
<
Place
>
ableGo
;
private
List
<
NpcInstance
>
npcInstances
;
private
List
<
GoodsInstance
>
goodsInstances
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getIntro
()
{
return
intro
;
}
public
void
setIntro
(
String
intro
)
{
this
.
intro
=
intro
;
}
public
List
<
Place
>
getAbleGo
()
{
return
ableGo
;
}
public
void
setAbleGo
(
List
<
Place
>
ableGo
)
{
this
.
ableGo
=
ableGo
;
}
public
List
<
NpcInstance
>
getNpcInstances
()
{
return
npcInstances
;
}
public
void
setNpcInstances
(
List
<
NpcInstance
>
npcInstances
)
{
this
.
npcInstances
=
npcInstances
;
}
public
List
<
GoodsInstance
>
getGoodsInstances
()
{
return
goodsInstances
;
}
public
void
setGoodsInstances
(
List
<
GoodsInstance
>
goodsInstances
)
{
this
.
goodsInstances
=
goodsInstances
;
}
@Override
public
String
toString
()
{
int
ableGoSize
=
0
;
int
npcInstancesSize
=
0
;
int
goodsInstancesSize
=
0
;
if
(
ableGo
!=
null
)
{
ableGoSize
=
ableGo
.
size
();
}
if
(
npcInstances
!=
null
)
{
npcInstancesSize
=
npcInstances
.
size
();
}
if
(
goodsInstances
!=
null
)
{
goodsInstancesSize
=
goodsInstances
.
size
();
}
return
"Place [name="
+
name
+
", intro="
+
intro
+
", ableGo="
+
ableGoSize
+
", npcInstances="
+
npcInstancesSize
+
", goodsInstances="
+
goodsInstancesSize
+
"]"
;
}
}
src/main/java/com/qiwu/chatbotbackend/GameEnvironment/bean/SuperClass.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
GameEnvironment
.
bean
;
import
java.io.Serializable
;
import
java.util.List
;
public
class
SuperClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
private
String
name
;
private
String
intro
;
private
List
<
Attr
>
attrs
;
private
List
<
GoodsInstance
>
goodsInstances
;
private
List
<
NpcInstance
>
npcInstances
;
public
List
<
GoodsInstance
>
getGoodsInstances
()
{
return
goodsInstances
;
}
public
void
setGoodsInstances
(
List
<
GoodsInstance
>
goodsInstances
)
{
this
.
goodsInstances
=
goodsInstances
;
}
public
List
<
NpcInstance
>
getNpcInstances
()
{
return
npcInstances
;
}
public
void
setNpcInstances
(
List
<
NpcInstance
>
npcInstances
)
{
this
.
npcInstances
=
npcInstances
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getIntro
()
{
return
intro
;
}
public
void
setIntro
(
String
intro
)
{
this
.
intro
=
intro
;
}
public
List
<
Attr
>
getAttrs
()
{
return
attrs
;
}
public
void
setAttrs
(
List
<
Attr
>
attrs
)
{
this
.
attrs
=
attrs
;
}
@Override
public
String
toString
()
{
int
goodsInstanceSize
=
0
;
if
(
goodsInstances
!=
null
)
{
goodsInstanceSize
=
goodsInstances
.
size
();
}
return
"SuperClass [name="
+
name
+
", intro="
+
intro
+
"goodsInstancesSize="
+
goodsInstanceSize
+
", attrs="
+
attrs
+
"]"
;
}
}
src/main/java/com/qiwu/chatbotbackend/db/C3p0Utils.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
db
;
import
com.mchange.v2.c3p0.ComboPooledDataSource
;
import
org.apache.log4j.Logger
;
import
java.sql.Connection
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
public
class
C3p0Utils
{
static
Logger
logger
=
Logger
.
getLogger
(
C3p0Utils
.
class
.
getName
());
//通过标识名来创建相应连接池
static
ComboPooledDataSource
dataSource
=
new
ComboPooledDataSource
(
"mysql"
);
//从连接池中取用一个连接
public
static
Connection
getConnection
()
throws
SQLException
{
try
{
return
dataSource
.
getConnection
();
}
catch
(
Exception
e
)
{
logger
.
error
(
"Exception in C3p0Utils!"
,
e
);
throw
e
;
}
}
//释放连接回连接池
public
static
void
close
(
Connection
conn
,
PreparedStatement
pst
,
ResultSet
rs
)
throws
SQLException
{
if
(
rs
!=
null
)
{
try
{
rs
.
close
();
}
catch
(
SQLException
e
)
{
logger
.
error
(
"Exception in C3p0Utils!"
,
e
);
throw
e
;
}
}
if
(
pst
!=
null
)
{
try
{
pst
.
close
();
}
catch
(
SQLException
e
)
{
logger
.
error
(
"Exception in C3p0Utils!"
,
e
);
throw
e
;
}
}
if
(
conn
!=
null
)
{
try
{
conn
.
close
();
}
catch
(
SQLException
e
)
{
logger
.
error
(
"Exception in C3p0Utils!"
,
e
);
throw
e
;
}
}
}
}
src/main/java/com/qiwu/chatbotbackend/db/DB.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
db
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
public
class
DB
{
private
static
String
driver
=
"com.mysql.jdbc.Driver"
;
private
static
String
url
=
"jdbc:mysql://192.168.1.81:3306/chatCN"
;
private
static
String
user
=
"root"
;
private
static
String
pwd
=
"admin"
;
public
static
Connection
getConnection
()
{
Connection
conn
=
null
;
try
{
Class
.
forName
(
driver
);
conn
=
DriverManager
.
getConnection
(
url
,
user
,
pwd
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
conn
;
}
}
src/main/java/com/qiwu/chatbotbackend/db/DBCPUtils.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
db
;
import
org.apache.tomcat.dbcp.dbcp2.BasicDataSourceFactory
;
import
javax.sql.DataSource
;
import
java.io.File
;
import
java.sql.Connection
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
java.util.Properties
;
public
class
DBCPUtils
{
private
static
DataSource
ds
;
//定义一个连接池对象
static
{
try
{
Properties
pro
=
new
Properties
();
File
file
=
new
File
(
"dbcpconfig.properties"
);
pro
.
load
(
DBCPUtils
.
class
.
getClassLoader
().
getResourceAsStream
(
"dbcpconfig.properties"
));
ds
=
BasicDataSourceFactory
.
createDataSource
(
pro
);
//得到一个连接池对象
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
//throw new ExceptionInInitializerError("初始化连接错误,请检查配置文件!");
}
}
//从池中获取一个连接
public
static
Connection
getConnection
()
throws
SQLException
{
return
ds
.
getConnection
();
}
public
static
void
closeAll
(
ResultSet
rs
,
Statement
stmt
,
Connection
conn
)
{
if
(
rs
!=
null
)
{
try
{
rs
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
if
(
stmt
!=
null
)
{
try
{
stmt
.
close
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
if
(
conn
!=
null
)
{
try
{
conn
.
close
();
//关闭
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
}
}
}
\ No newline at end of file
src/main/java/com/qiwu/chatbotbackend/db/DBUtils.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
db
;
public
class
DBUtils
{
}
src/main/java/com/qiwu/chatbotbackend/db/SqlHelper.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
db
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.entity.JConfig
;
import
com.qiwu.chatbotbackend.entity.QuestionKeyWord
;
import
com.qiwu.chatbotbackend.gameDesign.ElementConstructor
;
import
com.qiwu.chatbotbackend.processing.MyFunc
;
import
java.sql.*
;
import
java.util.*
;
public
class
SqlHelper
{
private
Connection
conn
=
null
;
/*
public SqlHelper(){
conn = DB.getConnection();
}
*/
public
SqlHelper
()
throws
SQLException
{
conn
=
C3p0Utils
.
getConnection
();
}
public
void
destroy
()
{
if
(
conn
!=
null
)
{
try
{
conn
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
/*
public boolean insertAction(QuestionKeyWord qkw){
String sql = "insert into user_info (chat_key,action_name) values(?,?)";
boolean b = false;
try{
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1,qkw.getChatKey());
ps.setString(2,qkw.getActionName());
b = ps.execute();
return b;
} catch(Exception e){
e.printStackTrace();
}
return b;
}
public boolean updateAction(QuestionKeyWord qkw){
String sql = "update user_info set action_name=? where chat_key=?";
boolean b = false;
try{
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1,qkw.getActionName());
ps.setString(2,qkw.getChatKey());
b = ps.execute();
return b;
} catch (SQLException e) {
e.printStackTrace();
}
return b;
}
public String queryActionByKey(String chat_key){
String sql = "select * from user_info where chat_key= ?";
String pre_name = "";
try{
PreparedStatement ps = conn.prepareStatement(sql);
ps.setString(1,chat_key);
ResultSet rs = ps.executeQuery();
if(rs.next())
return rs.getString("action_name");
}catch(Exception e){
e.printStackTrace();
}
return "empty";
}
*/
private
static
void
releaseSource
(
Connection
_conn
,
PreparedStatement
_st
,
ResultSet
_rs
)
throws
SQLException
{
C3p0Utils
.
close
(
_conn
,
_st
,
_rs
);
}
public
String
queryUsernameByKey
(
String
chat_key
)
{
String
sql
=
"select * from chats where chat_key = ?"
;
String
userName
=
""
;
String
result
=
"empty"
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
chat_key
);
ResultSet
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
())
result
=
rs
.
getString
(
"bot"
);
ps
.
close
();
rs
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
result
;
}
public
boolean
deleteConfigByIdGroup
(
int
botId
,
List
<
Integer
>
idGroup
)
throws
SQLException
{
StringBuilder
inClause
=
new
StringBuilder
();
boolean
firstValue
=
true
;
int
batchSize
=
idGroup
.
size
();
for
(
int
i
=
0
;
i
<
batchSize
;
i
++)
{
inClause
.
append
(
'?'
);
if
(
firstValue
)
{
firstValue
=
false
;
}
else
{
inClause
.
append
(
','
);
}
}
String
sql
=
"delete from chatbot_config where botId = ? and configId in ("
+
inClause
.
toString
()
+
')'
;
String
userName
=
""
;
boolean
b
=
true
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
b
=
ps
.
execute
();
ps
.
close
();
return
b
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
b
;
}
public
boolean
deleteConfigByBotId
(
int
botId
)
{
boolean
b
;
try
{
PreparedStatement
ps1
=
conn
.
prepareStatement
(
"delete from chatbot_config where botId= ?"
);
ps1
.
setString
(
1
,
String
.
valueOf
(
botId
));
b
=
ps1
.
execute
();
ps1
.
close
();
return
b
;
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
"删除旧数据config失败"
);
e
.
printStackTrace
();
return
false
;
}
}
public
boolean
deleteVariableByBotId
(
int
botId
)
{
String
sql
=
"delete from chatbot_variable where botId= ?"
;
boolean
b
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
b
=
ps
.
execute
();
ps
.
close
();
return
b
;
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
"删除旧数据variable失败"
);
e
.
printStackTrace
();
return
false
;
}
}
public
boolean
deleteCategoryByBotId
(
int
botId
)
{
String
sql
=
"delete from config_categories where botId= ?"
;
boolean
b
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
b
=
ps
.
execute
();
ps
.
close
();
return
b
;
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
"删除旧数据category失败"
);
e
.
printStackTrace
();
return
false
;
}
}
public
boolean
batchInsertVariableByBotId
(
int
botId
,
ElementConstructor
constructor
)
{
int
count
[];
boolean
insertFlag
=
true
;
String
sql
=
""
,
varName
,
varValue
,
description
;
try
{
conn
.
setAutoCommit
(
false
);
sql
=
"insert into chatbot_variable (botId, name, categoryId, description, defaultValue) VALUES (?, ?, 0, ?, ?)"
;
PreparedStatement
ps2
=
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
Iterator
<
String
>
iit
=
constructor
.
getVarInitialMap
().
keySet
().
iterator
();
while
(
iit
.
hasNext
())
{
varName
=
iit
.
next
();
varValue
=
constructor
.
getVarInitialMap
().
get
(
varName
);
if
(
constructor
.
getConditionDescription
().
get
(
varName
)
==
null
)
description
=
""
;
else
description
=
constructor
.
getConditionDescription
().
get
(
varName
);
ps2
.
setString
(
1
,
String
.
valueOf
(
botId
));
ps2
.
setString
(
2
,
varName
);
ps2
.
setString
(
3
,
description
);
ps2
.
setString
(
4
,
varValue
);
ps2
.
addBatch
();
}
count
=
ps2
.
executeBatch
();
conn
.
commit
();
for
(
int
i
:
count
)
{
if
(
i
==
0
)
{
conn
.
rollback
();
System
.
out
.
println
(
"======出现异常,回滚========="
);
insertFlag
=
false
;
}
}
ps2
.
close
();
}
catch
(
SQLException
e
)
{
try
{
conn
.
rollback
();
}
catch
(
SQLException
e1
)
{
e1
.
printStackTrace
();
}
System
.
out
.
println
(
"------出现异常,回滚----------"
);
e
.
printStackTrace
();
}
return
insertFlag
;
}
public
boolean
batchInsertConfigByBotId
(
int
botId
,
List
<
JSONObject
>
jsonList
,
List
<
Integer
>
idList
,
int
categoryId
)
{
int
count
[];
boolean
insertFlag
=
true
;
String
sql
=
"insert into chatbot_config (botId, categoryId, configData, configName) VALUES (?, ?, ?, ?)"
;
try
{
conn
.
setAutoCommit
(
false
);
// 需要用到事务,不能让他自动提交,需要手动提交
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
for
(
JSONObject
json
:
jsonList
)
{
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
ps
.
setString
(
2
,
String
.
valueOf
(
categoryId
));
ps
.
setString
(
3
,
json
.
toJSONString
());
ps
.
setString
(
4
,
(
String
)
json
.
get
(
"configName"
));
ps
.
addBatch
();
}
count
=
ps
.
executeBatch
();
conn
.
commit
();
for
(
int
i
:
count
)
{
if
(
i
==
0
)
{
conn
.
rollback
();
System
.
out
.
println
(
"======出现异常,回滚========="
);
insertFlag
=
false
;
}
}
ResultSet
rs
=
ps
.
getGeneratedKeys
();
while
(
rs
.
next
())
idList
.
add
(
rs
.
getInt
(
1
));
ps
.
close
();
rs
.
close
();
}
catch
(
SQLException
e
)
{
try
{
conn
.
rollback
();
}
catch
(
SQLException
e1
)
{
e1
.
printStackTrace
();
}
System
.
out
.
println
(
"------出现异常,回滚----------"
);
e
.
printStackTrace
();
}
return
insertFlag
;
}
public
boolean
batchInsertCategoryByBotId
(
int
botId
,
Map
<
String
,
Integer
>
categoryMap
)
{
int
count
[],
iterNum
=
0
,
id
;
boolean
insertFlag
=
true
;
String
sql
=
""
,
varName
,
varValue
,
description
;
ArrayList
<
String
>
nameList
=
new
ArrayList
<
String
>();
try
{
conn
.
setAutoCommit
(
false
);
sql
=
"insert into config_categories (botId, categoryParentId, categoryName, categoryStatus) VALUES (?, -1, ?, 'avaliable')"
;
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
Iterator
<
String
>
iit
=
categoryMap
.
keySet
().
iterator
();
while
(
iit
.
hasNext
())
{
varName
=
iit
.
next
();
nameList
.
add
(
varName
);
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
ps
.
setString
(
2
,
varName
);
ps
.
addBatch
();
}
count
=
ps
.
executeBatch
();
conn
.
commit
();
for
(
int
i
:
count
)
{
if
(
i
==
0
)
{
conn
.
rollback
();
System
.
out
.
println
(
"======出现异常,回滚========="
);
insertFlag
=
false
;
}
}
ResultSet
rs
=
ps
.
getGeneratedKeys
();
while
(
rs
.
next
()){
id
=
rs
.
getInt
(
1
);
categoryMap
.
put
(
nameList
.
get
(
iterNum
),
id
);
iterNum
++;
}
ps
.
close
();
rs
.
close
();
}
catch
(
SQLException
e
)
{
try
{
conn
.
rollback
();
}
catch
(
SQLException
e1
)
{
e1
.
printStackTrace
();
}
System
.
out
.
println
(
"------出现异常,回滚----------"
);
e
.
printStackTrace
();
}
return
insertFlag
;
}
public
JSONObject
queryGameElementsByBotId
(
int
id
)
{
String
sql
=
"select * from generate_json_tb where project_id = ?"
;
String
userName
=
""
;
String
result
=
"{}"
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
String
.
valueOf
(
id
));
ResultSet
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
())
result
=
rs
.
getString
(
"json_text"
);
ps
.
close
();
rs
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
JSONObject
.
parseObject
(
result
);
}
public
static
String
queryEnvJsonByBotName
(
String
botName
)
throws
SQLException
{
String
sql
=
"select * from generate_json_tb where bot_name = ?"
;
Connection
conn
=
C3p0Utils
.
getConnection
();
String
result
=
"{}"
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
String
.
valueOf
(
botName
));
ResultSet
rs
=
ps
.
executeQuery
();
if
(
rs
.
next
())
result
=
rs
.
getString
(
"env_json_text"
);
ps
.
close
();
rs
.
close
();
conn
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
result
;
}
public
boolean
insertVariableByBotId
(
int
id
,
String
variableName
,
String
description
,
String
defaultValue
)
{
String
sql
=
"insert into chatbot_variable (botId, name, description, defaultValue) VALUES (?, ?, ?, ?)"
;
String
userName
=
""
;
String
result
=
"empty"
;
boolean
b
=
true
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
);
ps
.
setString
(
1
,
String
.
valueOf
(
id
));
ps
.
setString
(
2
,
variableName
);
ps
.
setString
(
3
,
description
);
ps
.
setString
(
4
,
defaultValue
);
b
=
ps
.
execute
();
ps
.
close
();
conn
.
commit
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
b
;
}
public
boolean
insertConfigByBotId
(
int
botId
,
JSONObject
json
,
List
<
Integer
>
idList
,
int
categoryId
)
{
String
sql
=
"insert into chatbot_config (botId, categoryId, configData, configName) VALUES (?, ?, ?, ?)"
;
int
id
=
0
;
boolean
b
=
true
;
int
bNum
=
0
;
try
{
PreparedStatement
ps
=
conn
.
prepareStatement
(
sql
,
Statement
.
RETURN_GENERATED_KEYS
);
ps
.
setString
(
1
,
String
.
valueOf
(
botId
));
ps
.
setString
(
2
,
String
.
valueOf
(
categoryId
));
ps
.
setString
(
3
,
json
.
toJSONString
());
ps
.
setString
(
4
,
(
String
)
json
.
get
(
"configName"
));
System
.
out
.
println
(
ps
.
toString
());
bNum
=
ps
.
executeUpdate
();
ResultSet
rs
=
ps
.
getGeneratedKeys
();
if
(
rs
.
next
()){
id
=
rs
.
getInt
(
1
);
idList
.
add
(
id
);
}
ps
.
close
();
rs
.
close
();
conn
.
commit
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
b
;
}
// public boolean insertCategoryByBotId(int botId, String categoryName) {
// String sql = "insert into chatbot_config (botId, categoryId, configData, configName) VALUES (?, ?, ?, ?)";
// int id = 0;
// boolean b = true;
// int bNum = 0;
// try {
// PreparedStatement ps = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
// ps.setString(1, String.valueOf(botId));
// ps.setString(2, "0");
// ps.setString(4, jConfig.getConfigName());
//
// System.out.println(ps.toString());
//
// bNum = ps.executeUpdate();
// ResultSet rs = ps.getGeneratedKeys();
// if(rs.next()){
// id = rs.getInt(1);
// idList.add(id);
// }
// ps.close();
// rs.close();
// conn.commit();
//
// } catch (Exception e) {
// e.printStackTrace();
// }
//
// return b;
//
// }
}
src/main/java/com/qiwu/chatbotbackend/entity/ChatCache.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
entity
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.concurrent.ExecutionException
;
import
com.qiwu.chatbotbackend.GameEnvironment.GameEnv
;
public
class
ChatCache
{
private
Map
<
String
,
String
>
infoPoint
=
null
;
private
GameEnv
gameEnv
=
null
;
public
Map
<
String
,
String
>
getInfoPoint
()
{
return
infoPoint
;
}
public
void
setInfoPoint
(
Map
<
String
,
String
>
infoPoint
)
{
this
.
infoPoint
=
infoPoint
;
}
public
GameEnv
getGameEnv
()
{
return
gameEnv
;
}
public
void
setGameEnv
(
GameEnv
gameEnv
)
{
this
.
gameEnv
=
gameEnv
;
}
public
ChatCache
(
UserInfo
userInfo
)
throws
Exception
{
try
{
gameEnv
=
new
GameEnv
(
userInfo
.
botAccount
);
}
catch
(
Exception
e
){
System
.
out
.
println
(
"游戏平台初始化失败"
);
}
String
k
;
infoPoint
=
new
HashMap
<
String
,
String
>();
Iterator
<
String
>
iit
=
userInfo
.
varInitialMap
.
keySet
().
iterator
();
while
(
iit
.
hasNext
())
{
k
=
iit
.
next
();
infoPoint
.
put
(
k
,
userInfo
.
varInitialMap
.
get
(
k
));
}
}
}
src/main/java/com/qiwu/chatbotbackend/entity/Condition.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
entity
;
import
java.util.HashMap
;
import
java.util.HashSet
;
/**
* 保存配置文件每一行(单行)解析后的信息的实体类。
* 独立于引擎的另一种condition
*/
public
class
Condition
{
public
int
priority
=
-
1
;
public
int
activePriority
=
0
;
//如果本condition被其他condition激活
public
int
auxiliaryPriority
=
0
;
//用于priority一样时人为设置的辅助优先级
public
HashSet
<
String
>
keywordSet
=
new
HashSet
<
String
>();
public
HashMap
<
String
,
HashSet
<
String
>>
historyPremise
=
new
HashMap
<
String
,
HashSet
<
String
>>();
public
HashMap
<
String
,
HashSet
<
String
>>
currentPremise
=
new
HashMap
<
String
,
HashSet
<
String
>>();
public
HashMap
<
String
,
String
>
updateKnowledge
=
new
HashMap
<
String
,
String
>();
public
String
[]
answer
=
{
""
,};
public
String
nextStep
=
""
;
public
HashMap
<
String
,
String
>
featureMap
=
new
HashMap
<
String
,
String
>();
public
String
indexName
=
""
;
public
int
id
=
0
;
public
String
status
=
"waiting"
;
//public ArrayList<String> indexName = new ArrayList<String>();
public
Condition
(
int
priority
)
{
this
.
priority
=
priority
;
this
.
activePriority
=
priority
;
}
public
Condition
(
Condition
originCondition
,
int
basePriority
,
int
baseAuxiliaryPriority
)
{
this
.
priority
=
originCondition
.
priority
;
this
.
keywordSet
=
originCondition
.
keywordSet
;
this
.
historyPremise
=
originCondition
.
historyPremise
;
this
.
currentPremise
=
originCondition
.
currentPremise
;
this
.
answer
=
originCondition
.
answer
;
this
.
nextStep
=
originCondition
.
nextStep
;
this
.
featureMap
=
originCondition
.
featureMap
;
this
.
updateKnowledge
=
originCondition
.
updateKnowledge
;
this
.
indexName
=
originCondition
.
indexName
;
this
.
id
=
originCondition
.
id
;
this
.
status
=
originCondition
.
status
;
this
.
activePriority
=
originCondition
.
activePriority
+
basePriority
;
this
.
auxiliaryPriority
=
originCondition
.
auxiliaryPriority
+
baseAuxiliaryPriority
;
}
public
Condition
()
{
}
}
src/main/java/com/qiwu/chatbotbackend/entity/JConfig.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
entity
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
public
class
JConfig
{
private
int
id
=
0
;
private
String
jCurPremise
=
""
;
private
String
jHisPremise
=
""
;
private
String
jFeature
=
""
;
private
String
jNextStep
=
""
;
private
String
jReply
=
""
;
private
String
jAuxiliaryPriority
=
"0"
;
public
void
setjStatus
(
int
jStatus
)
{
this
.
jStatus
=
jStatus
;
}
private
int
jStatus
=
0
;
private
String
curPremise
=
""
;
private
String
hisPremise
=
""
;
private
String
feature
=
""
;
private
String
reply
=
""
;
private
String
nextStep
=
""
;
public
void
setConfigName
(
String
configName
)
{
this
.
configName
=
configName
;
}
public
String
getConfigName
()
{
return
configName
;
}
private
String
configName
=
""
;
public
String
getCurPremise
()
{
return
curPremise
;
}
private
String
auxiliaryPriority
=
"0"
;
private
String
status
=
"waiting"
;
private
String
updateKnowledge
=
""
;
private
String
nextStepStatus
=
"return"
;
Map
<
String
,
String
>
statusMap
=
new
HashMap
<
String
,
String
>()
{
{
put
(
"return"
,
"return"
);
put
(
"return-1"
,
"back"
);
put
(
"return-0"
,
"stay"
);
put
(
"active"
,
"activate"
);
}
};
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
void
setAuxiliaryPriority
(
String
auxiliaryPriority
)
{
this
.
auxiliaryPriority
=
auxiliaryPriority
;
}
public
void
setNextStepStatus
(
String
nextStepStatus
)
{
this
.
nextStepStatus
=
nextStepStatus
;
}
public
JConfig
(
String
curPremise
,
String
hisPremise
,
String
feature
,
String
reply
,
String
nextStep
,
String
updateKnowledge
)
{
this
.
curPremise
=
curPremise
;
this
.
hisPremise
=
hisPremise
;
this
.
feature
=
feature
;
if
(!
updateKnowledge
.
equals
(
""
))
this
.
updateKnowledge
+=
"updateKnowledge-<-"
+
updateKnowledge
;
this
.
reply
=
reply
;
this
.
nextStep
=
nextStep
;
}
public
JConfig
(
List
<
String
>
curPremise
,
List
<
String
>
hisPremise
,
Map
<
String
,
String
>
updateKnowledge
,
String
extraCP
,
String
extraHP
,
String
extraUK
,
String
feature
,
String
reply
,
String
nextStep
,
String
auxiliaryPriority
)
{
this
.
curPremise
=
appendPremiseStr
(
curPremise
,
extraCP
);
this
.
hisPremise
=
appendPremiseStr
(
hisPremise
,
extraHP
);
this
.
updateKnowledge
=
appendKnowledgeStr
(
updateKnowledge
,
extraUK
);
this
.
feature
=
feature
;
this
.
reply
=
reply
;
this
.
nextStep
=
nextStep
;
this
.
auxiliaryPriority
=
auxiliaryPriority
;
}
public
String
appendPremiseStr
(
List
<
String
>
premises
,
String
extraPM
)
{
StringBuffer
sb
=
new
StringBuffer
();
String
premiseStr
=
""
;
for
(
String
premise
:
premises
)
sb
.
append
(
","
+
premise
);
if
(
sb
.
length
()
>
0
)
sb
.
deleteCharAt
(
0
);
//删除第一个逗号
if
(!
extraPM
.
equals
(
""
))
{
if
(
sb
.
length
()
==
0
)
sb
.
append
(
extraPM
);
else
sb
.
append
(
","
+
extraPM
);
}
else
if
(
sb
.
length
()
==
0
)
{
sb
.
append
(
" "
);
}
premiseStr
=
sb
.
toString
();
return
premiseStr
;
}
public
String
appendKnowledgeStr
(
Map
<
String
,
String
>
knowledge
,
String
extraKL
)
{
StringBuffer
sb
=
new
StringBuffer
();
String
varName
=
""
,
varValue
=
""
,
knowledgeStr
;
Iterator
<
String
>
iit
=
knowledge
.
keySet
().
iterator
();
while
(
iit
.
hasNext
())
{
varName
=
iit
.
next
();
varValue
=
knowledge
.
get
(
varName
);
sb
.
append
(
"-<-"
+
varName
+
":"
+
varValue
);
}
if
(!
extraKL
.
equals
(
""
))
{
sb
.
append
(
"-<-"
+
extraKL
);
}
if
(
sb
.
length
()
>
0
)
knowledgeStr
=
"updateKnowledge"
+
sb
.
toString
();
else
knowledgeStr
=
""
;
return
knowledgeStr
;
}
public
void
appendJPremise
(
JSONArray
premiseList
,
String
premise
,
Map
<
String
,
String
>
conditionDescription
)
{
//System.out.println(premise);
String
pair1
[]
=
premise
.
split
(
"="
,
2
);
String
key
=
pair1
[
0
];
String
keywords
=
pair1
[
1
];
String
pair2
[]
=
key
.
split
(
"::"
);
String
conditionName
=
pair2
[
0
];
String
pair3
[]
=
pair2
[
1
].
split
(
"-"
);
String
cmpType
=
pair3
[
0
];
String
operator
=
""
;
if
(
pair3
.
length
>
1
)
operator
=
pair3
[
1
];
String
question
=
""
;
if
(
conditionDescription
.
get
(
conditionName
)
!=
null
)
question
=
conditionDescription
.
get
(
conditionName
);
JSONObject
premiseJ
=
new
JSONObject
();
premiseJ
.
put
(
"keywords"
,
keywords
);
premiseJ
.
put
(
"actionName"
,
conditionName
);
premiseJ
.
put
(
"cmpType"
,
cmpType
);
premiseJ
.
put
(
"question"
,
question
);
premiseJ
.
put
(
"operator"
,
operator
);
premiseList
.
add
(
premiseJ
);
}
public
void
appendJKnowledge
(
JSONArray
knowledgeList
,
String
knowledge
,
Map
<
String
,
String
>
conditionDescription
)
{
String
pair
[]
=
knowledge
.
split
(
":"
,
2
);
if
(
knowledge
.
equals
(
""
)
||
pair
.
length
<
2
)
return
;
String
question
=
""
;
if
(
conditionDescription
.
get
(
pair
[
0
])
!=
null
)
question
=
conditionDescription
.
get
(
pair
[
0
]);
JSONObject
knowledgeJ
=
new
JSONObject
();
knowledgeJ
.
put
(
"variableName"
,
pair
[
0
]);
knowledgeJ
.
put
(
"keyword"
,
pair
[
1
]);
knowledgeList
.
add
(
knowledgeJ
);
}
public
void
appendJNextStep
(
JSONArray
nextStepList
,
String
next
,
Map
<
String
,
String
>
conditionDescription
)
{
String
pair
[]
=
next
.
split
(
"-"
);
JSONObject
nextStepJ
=
new
JSONObject
();
JSONArray
exceptJ
=
new
JSONArray
();
for
(
int
i
=
1
;
i
<
pair
.
length
;
i
++)
exceptJ
.
add
(
pair
[
i
]);
String
question
=
""
;
if
(
conditionDescription
.
get
(
pair
[
0
])
!=
null
)
question
=
conditionDescription
.
get
(
pair
[
0
]);
nextStepJ
.
put
(
"nextStep"
,
pair
[
0
]);
nextStepJ
.
put
(
"except"
,
exceptJ
);
nextStepJ
.
put
(
"nextStepText"
,
question
);
nextStepList
.
add
(
nextStepJ
);
}
public
JSONObject
toJson
(
Map
<
String
,
String
>
conditionDescription
)
{
JSONObject
data
=
new
JSONObject
();
JSONArray
curPremiseList
=
new
JSONArray
();
JSONArray
hisPremiseList
=
new
JSONArray
();
//添加当前对话内容
for
(
String
premise
:
curPremise
.
split
(
","
))
{
if
(!
premise
.
equals
(
""
)
&&
!
premise
.
equals
(
" "
))
appendJPremise
(
curPremiseList
,
premise
,
conditionDescription
);
}
data
.
put
(
"currentPremiseList"
,
curPremiseList
);
//添加已知信息的内容
for
(
String
premise
:
hisPremise
.
split
(
","
))
{
if
(!
premise
.
equals
(
""
)
&&
!
premise
.
equals
(
" "
))
appendJPremise
(
hisPremiseList
,
premise
,
conditionDescription
);
}
data
.
put
(
"historyPremiseList"
,
hisPremiseList
);
//添加下一步状态
data
.
put
(
"nextStepStatus"
,
statusMap
.
get
(
nextStepStatus
));
//添加configName
data
.
put
(
"configName"
,
configName
);
//添加config状态
data
.
put
(
"configStatus"
,
jStatus
);
boolean
doPost
=
false
;
String
postURL
=
""
,
postType
=
"all"
,
pair
[];
for
(
String
feat
:
feature
.
split
(
","
))
{
if
(
feat
.
startsWith
(
"post"
))
{
doPost
=
true
;
pair
=
feat
.
substring
(
0
,
feat
.
length
()
-
1
).
split
(
"\\("
,
2
);
postURL
=
pair
[
1
];
postType
=
pair
[
0
].
split
(
"::"
)[
1
];
}
}
//添加post参数
data
.
put
(
"doPost"
,
doPost
);
data
.
put
(
"postURL"
,
postURL
);
data
.
put
(
"postType"
,
postType
);
//添加回答
data
.
put
(
"reply"
,
reply
);
//添加config类别id
data
.
put
(
"categoryId"
,
0
);
//添加辅助优先级
data
.
put
(
"auxiliaryPriority"
,
auxiliaryPriority
);
//添加更新答案处的信息
JSONArray
knowledgeList
=
new
JSONArray
();
if
(!
updateKnowledge
.
equals
(
""
))
{
for
(
String
knowledge
:
updateKnowledge
.
split
(
"-<-"
))
{
appendJKnowledge
(
knowledgeList
,
knowledge
,
conditionDescription
);
}
}
data
.
put
(
"updateKnowledge"
,
knowledgeList
);
//添加下一步
JSONArray
nextStepList
=
new
JSONArray
();
for
(
String
next
:
nextStep
.
split
(
","
))
{
appendJNextStep
(
nextStepList
,
next
,
conditionDescription
);
}
data
.
put
(
"nextStepList"
,
nextStepList
);
return
data
;
}
public
String
toString
()
{
String
text
=
curPremise
+
"|"
+
hisPremise
+
"|"
+
feature
+
","
+
updateKnowledge
+
","
+
nextStepStatus
+
"|"
+
"auxiliaryPriority="
+
auxiliaryPriority
+
"|=>|"
+
reply
+
"|"
+
"nextStep="
+
nextStep
+
"|"
+
"status="
+
status
+
"|"
+
"configId="
;
return
text
;
}
}
src/main/java/com/qiwu/chatbotbackend/entity/QuestionKeyWord.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
entity
;
/**
* 暂时没用
*/
public
class
QuestionKeyWord
{
private
String
actionName
;
private
String
chatKey
;
private
String
keyWord
;
public
String
getActionName
()
{
return
actionName
;
}
public
String
getChatKey
()
{
return
chatKey
;
}
public
String
getKeyWord
()
{
return
keyWord
;
}
public
void
setActionName
(
String
actionName
)
{
this
.
actionName
=
actionName
;
}
public
void
setChatKey
(
String
chatKey
)
{
this
.
chatKey
=
chatKey
;
}
public
void
setKeyWord
(
String
keyWord
)
{
this
.
keyWord
=
keyWord
;
}
}
src/main/java/com/qiwu/chatbotbackend/entity/Solution.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
entity
;
/**
* 包含后台返回数据的实体类。
*/
public
class
Solution
{
private
int
status
=
0
;
private
String
answer
;
private
String
next
;
public
String
getAnswer
()
{
return
answer
;
}
public
int
getStatus
()
{
return
status
;
}
public
void
setAnswer
(
String
answer
)
{
this
.
answer
=
answer
;
}
public
void
setStatus
(
int
status
)
{
this
.
status
=
status
;
}
public
String
getNext
()
{
return
next
;
}
public
void
setNext
(
String
next
)
{
this
.
next
=
next
;
}
public
Solution
(
int
status
,
String
answers
,
String
next
)
{
this
.
answer
=
answers
;
this
.
next
=
next
;
this
.
status
=
status
;
}
public
Solution
()
{
}
}
src/main/java/com/qiwu/chatbotbackend/entity/UserInfo.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
entity
;
import
java.util.HashMap
;
import
java.util.List
;
/**
* 本地读取的用户配置文件(整个)和提交的用户配置文件的信息经过解析后保存在这里
*/
public
class
UserInfo
{
public
UserInfo
(
String
botAccount
)
{
this
.
conditionTable
=
new
HashMap
<
String
,
List
<
Condition
>>();
this
.
configStr
=
""
;
this
.
botAccount
=
botAccount
;
this
.
extraInfo
=
new
HashMap
<
String
,
String
>()
{
{
put
(
"activeAction"
,
" "
);
}
};
this
.
id2config
=
new
HashMap
<
Integer
,
String
>();
this
.
id2condition
=
new
HashMap
<
Integer
,
Condition
>();
this
.
varInitialMap
=
new
HashMap
<
String
,
String
>();
}
public
HashMap
<
String
,
List
<
Condition
>>
conditionTable
;
public
String
configStr
;
public
String
botAccount
;
public
HashMap
<
String
,
String
>
extraInfo
;
public
HashMap
<
Integer
,
String
>
id2config
;
public
HashMap
<
Integer
,
Condition
>
id2condition
;
//存储需要初始化的变量
public
HashMap
<
String
,
String
>
varInitialMap
;
}
src/main/java/com/qiwu/chatbotbackend/gameDesign/CharacterConstructor.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.entity.JConfig
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
java.util.*
;
public
class
CharacterConstructor
extends
ElementConstructor
{
public
CharacterConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
super
();
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
exceptRelation
=
exceptRelation
;
}
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
String
category
,
name
,
className
,
description
,
attrName
,
attrValue
;
try
{
JSONArray
allNPC
=
gameElements
.
getJSONArray
(
"npc"
);
Map
<
String
,
String
>
attribute
=
null
;
Iterator
<
String
>
attrIter
=
null
;
HashSet
<
String
>
classSet
=
new
HashSet
<
String
>();
//与npc属性相关的所有condition
ArrayList
<
String
>
relateConditions
=
new
ArrayList
<
String
>()
{
{
add
(
"wenzainali"
);
add
(
"shishenme"
);
}
};
//与npc类相关的所有condition
ArrayList
<
String
>
classRelateConditions
=
new
ArrayList
<
String
>()
{
{
add
(
"know_exist_what"
);
}
};
//在condition的三元组中添加与NPC相关的关键词
String
conditionValue
=
"哪里:人称"
,
repValue
;
StringBuffer
keywords
=
new
StringBuffer
();
StringBuffer
classKeywords
=
new
StringBuffer
();
for
(
JSONObject
character
:
allNPC
.
toJavaList
(
JSONObject
.
class
))
{
name
=
(
String
)
character
.
get
(
"name"
);
className
=
(
String
)
character
.
get
(
"class"
);
if
(!
classSet
.
contains
(
className
))
{
classSet
.
add
(
className
);
classKeywords
.
append
(
"+周围:"
+
className
+
"+附近:"
+
className
);
}
attribute
=
gameElements
.
toJavaObject
(
character
.
getJSONObject
(
"attr"
),
Map
.
class
);
attrIter
=
attribute
.
keySet
().
iterator
();
repValue
=
conditionValue
.
replace
(
"人称"
,
name
);
keywords
.
append
(
"+"
+
repValue
);
while
(
attrIter
.
hasNext
())
{
attrName
=
attrIter
.
next
();
attrValue
=
attribute
.
get
(
attrName
);
}
System
.
out
.
println
(
name
);
}
//根据根据NPC名字和属性查询属性值
for
(
String
conditionName
:
relateConditions
)
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
keywords
,
" "
,
"match,return-0"
,
"{NPC_query-2}"
,
"yaobuyao"
,
"NPC_query:queryAttrByNPCName:"
+
conditionName
);
jConfigList
.
add
(
jConfig
);
}
//根据根据NPC类别和地点属性查询所有NPC实例
for
(
String
conditionName
:
relateConditions
)
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
classKeywords
,
" "
,
"match,return-0"
,
"{NPC_query-2}"
,
"yaobuyao"
,
"NPC_query:queryAroundNpcByClassName:"
+
conditionName
);
jConfigList
.
add
(
jConfig
);
}
}
catch
(
Exception
e
){
operationStatus
=
0
;
message
=
"NPC接口处理出现异常"
;
return
;
}
}
}
src/main/java/com/qiwu/chatbotbackend/gameDesign/ElementConstructor.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.entity.JConfig
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
java.util.*
;
public
class
ElementConstructor
{
int
botId
=
0
;
int
operationStatus
=
1
;
SqlHelper
helper
=
null
;
HashSet
<
String
>
exceptRelation
=
null
;
JConfig
jConfig
=
null
;
String
CHITCHAT_URL
=
"http:192.168.1.178:1111/test"
;
String
userName
;
String
message
=
""
;
List
<
JSONObject
>
configDataList
=
new
ArrayList
<
JSONObject
>();
List
<
JConfig
>
jConfigList
=
new
ArrayList
<
JConfig
>();
StringBuffer
configText
=
new
StringBuffer
();
Map
<
String
,
String
>
varInitialMap
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
conditionDescription
=
new
HashMap
<
String
,
String
>();
public
String
getMessage
()
{
return
message
;
}
public
int
getOperationStatus
()
{
return
operationStatus
;
}
public
Map
<
String
,
String
>
getVarInitialMap
()
{
return
varInitialMap
;
}
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
}
public
List
<
JConfig
>
getjConfigList
()
{
return
jConfigList
;
}
public
Map
<
String
,
String
>
getConditionDescription
()
{
return
conditionDescription
;
}
public
List
<
JSONObject
>
getConfigDataList
()
{
return
configDataList
;
}
public
void
ElementConstructor
(
String
userName
)
{
this
.
userName
=
userName
;
}
public
String
getConfigText
()
{
return
configText
.
toString
();
}
public
void
generateConfigText
(
List
<
Integer
>
idList
)
{
int
id
,
length
=
idList
.
size
();
String
varValue
;
JConfig
jConfig
=
null
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
jConfig
=
jConfigList
.
get
(
i
);
id
=
idList
.
get
(
i
);
configText
.
append
(
jConfig
.
toString
()
+
id
+
"\n"
);
}
for
(
String
varName
:
varInitialMap
.
keySet
())
{
varValue
=
varInitialMap
.
get
(
varName
);
configText
.
append
(
"-varInitial-|"
+
varName
+
"|"
+
varValue
.
replace
(
"\n"
,
""
)
+
"\n"
);
}
}
public
void
parseKeyword
(
JSONObject
config
,
Map
<
String
,
HashSet
<
String
>>
relationKeywords
,
HashSet
<
String
>
exceptRelation
){
String
conditionName
,
pair
[];
for
(
Map
premise:
JSONArray
.
parseArray
(
config
.
getJSONArray
(
"currentPremiseList"
).
toJSONString
(),
Map
.
class
)){
conditionName
=
(
String
)
premise
.
get
(
"actionName"
);
if
(!
exceptRelation
.
contains
(
conditionName
))
{
if
(!
relationKeywords
.
containsKey
(
conditionName
+
"_head"
))
{
relationKeywords
.
put
(
conditionName
+
"_head"
,
new
HashSet
<
String
>());
relationKeywords
.
put
(
conditionName
+
"_tail"
,
new
HashSet
<
String
>());
}
for
(
String
keyword
:
((
String
)
premise
.
get
(
"keywords"
)).
split
(
"\\+"
))
{
if
(
keyword
.
equals
(
""
)){
continue
;
}
else
if
(
keyword
.
contains
(
":"
)){
pair
=
keyword
.
split
(
":"
);
relationKeywords
.
get
(
conditionName
+
"_head"
).
add
(
pair
[
0
]);
relationKeywords
.
get
(
conditionName
+
"_tail"
).
add
(
pair
[
1
]);
}
else
{
relationKeywords
.
get
(
conditionName
+
"_tail"
).
add
(
keyword
);
}
}
}
}
}
/**
* 根据插入的数据做后处理
* @param idList
*/
public
void
postProcessing
(
List
<
Integer
>
idList
,
int
categoryId
){}
/**
* 构造参数配置文件的json版
*/
public
void
buildJconfig
()
{
}
}
src/main/java/com/qiwu/chatbotbackend/gameDesign/Floyd.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
/**
* 弗洛伊德算法,用于构造地图时求最短路径
*/
public
class
Floyd
{
/**
* 表示正无穷
*/
int
MAX_WEIGHT
=
Integer
.
MAX_VALUE
;
/**
* 路径矩阵
*/
int
[][]
pathMatirx
;
/**
* 前驱表
*/
int
[][]
preTable
;
public
void
findShortestPath
(
int
[][]
matrix
,
int
length
)
{
//路径矩阵(D),表示顶点到顶点的最短路径权值之和的矩阵,初始时,就是图的邻接矩阵。
pathMatirx
=
new
int
[
length
][
length
];
//前驱表(P),P[m][n] 的值为 m到n的最短路径的前驱顶点,如果是直连,值为n。也就是初始值
preTable
=
new
int
[
length
][
length
];
/*
System.out.println("matrix");
for (int i = 0; i < length; i++){
for(int j = 0; j < length; j++){
System.out.print(matrix[i][j] + " ");
}
System.out.println();
}
*/
//初始化D,P
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
length
;
j
++)
{
pathMatirx
[
i
][
j
]
=
matrix
[
i
][
j
];
preTable
[
i
][
j
]
=
j
;
}
}
//循环 中间经过顶点
for
(
int
k
=
0
;
k
<
length
;
k
++)
{
//循环所有路径
for
(
int
m
=
0
;
m
<
length
;
m
++)
{
for
(
int
n
=
0
;
n
<
length
;
n
++)
{
int
mn
=
pathMatirx
[
m
][
n
];
int
mk
=
pathMatirx
[
m
][
k
];
int
kn
=
pathMatirx
[
k
][
n
];
int
addedPath
=
(
mk
==
MAX_WEIGHT
||
kn
==
MAX_WEIGHT
)
?
MAX_WEIGHT
:
mk
+
kn
;
if
(
mn
>
addedPath
)
{
//如果经过k顶点路径比原两点路径更短,将两点间权值设为更小的一个
pathMatirx
[
m
][
n
]
=
addedPath
;
//前驱设置为经过下标为k的顶点
preTable
[
m
][
n
]
=
preTable
[
m
][
k
];
}
}
}
}
/*
System.out.println("pathMatrix");
for (int i = 0; i < length; i++){
for(int j = 0; j < length; j++){
System.out.print(pathMatirx[i][j] + " ");
}
System.out.println();
}
*/
}
/**
* 打印 所有最短路径
*/
public
void
printPath
(
int
[][]
matrix
,
int
length
)
{
for
(
int
m
=
0
;
m
<
length
;
m
++)
{
for
(
int
n
=
m
+
1
;
n
<
length
;
n
++)
{
int
k
=
preTable
[
m
][
n
];
System
.
out
.
print
(
"("
+
m
+
","
+
n
+
")"
+
pathMatirx
[
m
][
n
]
+
": "
);
System
.
out
.
print
(
m
);
while
(
k
!=
n
)
{
System
.
out
.
print
(
"->"
+
k
);
k
=
preTable
[
k
][
n
];
}
System
.
out
.
println
(
"->"
+
n
);
}
System
.
out
.
println
();
}
}
}
src/main/java/com/qiwu/chatbotbackend/gameDesign/GlobalVariableConstructor.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Iterator
;
import
java.util.Map
;
public
class
GlobalVariableConstructor
extends
ElementConstructor
{
public
GlobalVariableConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
super
();
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
exceptRelation
=
exceptRelation
;
}
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
try
{
String
category
,
name
,
description
,
attrName
,
attrValue
;
JSONArray
globalVariable
=
gameElements
.
getJSONArray
(
"globalVariable"
);
Map
<
String
,
String
>
attribute
=
null
;
Iterator
<
String
>
attrIter
=
null
;
for
(
JSONObject
variableList
:
globalVariable
.
toJavaList
(
JSONObject
.
class
))
{
category
=
(
String
)
variableList
.
get
(
"category"
);
attribute
=
gameElements
.
toJavaObject
(
variableList
.
getJSONObject
(
"variables"
),
Map
.
class
);
attrIter
=
attribute
.
keySet
().
iterator
();
while
(
attrIter
.
hasNext
())
{
attrName
=
attrIter
.
next
();
attrValue
=
attribute
.
get
(
attrName
);
varInitialMap
.
put
(
category
+
"_"
+
attrName
,
attrValue
);
}
}
}
catch
(
Exception
e
){
operationStatus
=
0
;
message
=
"全局变量处理出现异常"
;
return
;
}
}
}
src/main/java/com/qiwu/chatbotbackend/gameDesign/ItemConstructor.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.entity.JConfig
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
java.util.*
;
public
class
ItemConstructor
extends
ElementConstructor
{
public
ItemConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
super
();
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
exceptRelation
=
exceptRelation
;
}
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
try
{
String
category
,
name
,
className
,
description
,
attrName
,
attrValue
;
JSONArray
goods
=
gameElements
.
getJSONArray
(
"goods"
);
Map
<
String
,
String
>
attribute
=
null
;
Iterator
<
String
>
attrIter
=
null
;
HashSet
<
String
>
classSet
=
new
HashSet
<
String
>();
//与物品属性查询相关的所有condition
ArrayList
<
String
>
attrRelateConditions
=
new
ArrayList
<
String
>()
{
{
add
(
"nums"
);
add
(
"shishenme"
);
}
};
//与物品类查询相关的所有condition
ArrayList
<
String
>
classRelateConditions
=
new
ArrayList
<
String
>()
{
{
add
(
"know_exist_what"
);
}
};
StringBuffer
keywords
=
new
StringBuffer
();
StringBuffer
classKeywords
=
new
StringBuffer
();
for
(
JSONObject
good
:
goods
.
toJavaList
(
JSONObject
.
class
))
{
name
=
(
String
)
good
.
get
(
"name"
);
className
=
(
String
)
good
.
get
(
"class"
);
if
(!
classSet
.
contains
(
className
))
{
classSet
.
add
(
className
);
//添加周围有什么士兵等关于类别的关键词
classKeywords
.
append
(
"+周围:"
+
className
+
"+附近:"
+
className
);
}
attribute
=
gameElements
.
toJavaObject
(
good
.
getJSONObject
(
"attr"
),
Map
.
class
);
attrIter
=
attribute
.
keySet
().
iterator
();
while
(
attrIter
.
hasNext
())
{
attrName
=
attrIter
.
next
();
attrValue
=
attribute
.
get
(
attrName
);
keywords
.
append
(
"+"
+
name
+
":"
+
attrName
);
}
}
//根据根据物品名字和属性查询属性值
for
(
String
conditionName
:
attrRelateConditions
)
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
keywords
,
" "
,
"match,return-0"
,
"{goods_query-2}"
,
" "
,
"goods_query:queryAttrByGoodsName:"
+
conditionName
);
jConfigList
.
add
(
jConfig
);
}
//根据类名和地点查询所有实例
for
(
String
conditionName
:
attrRelateConditions
)
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
classKeywords
,
" "
,
"match,return-0"
,
"{goods_query-2}"
,
" "
,
"goods_query:queryAroundGoodsByClassName:"
+
conditionName
);
jConfigList
.
add
(
jConfig
);
}
}
catch
(
Exception
e
){
operationStatus
=
0
;
message
=
"物品处理出现异常"
;
return
;
}
}
}
src/main/java/com/qiwu/chatbotbackend/gameDesign/MapConstructor.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.entity.JConfig
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
java.util.*
;
public
class
MapConstructor
extends
ElementConstructor
{
int
[][]
matrix
;
int
locationNum
;
HashMap
<
Integer
,
JSONObject
>
id2j
=
new
HashMap
<
Integer
,
JSONObject
>();
Map
<
String
,
String
>
question2keyword
=
new
HashMap
<
String
,
String
>();
JSONArray
locations
=
null
;
public
MapConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
super
();
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
exceptRelation
=
exceptRelation
;
}
public
void
constructGreph
(
JSONArray
locations
)
{
JSONObject
jobj
=
null
;
int
locationId
,
index
;
//ArrayList<ArrayList<Integer>> matrix= new ArrayList<ArrayList<Integer>>();
//ArrayList<Integer> vec1d = new ArrayList<Integer>();
locationNum
=
locations
.
size
();
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
jobj
=
locations
.
getJSONObject
(
i
);
jobj
.
put
(
"index"
,
i
);
locationId
=
(
Integer
)
jobj
.
get
(
"id"
);
id2j
.
put
(
locationId
,
jobj
);
}
//邻接矩阵初始化
matrix
=
new
int
[
locationNum
][
locationNum
];
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
for
(
int
j
=
0
;
j
<
locationNum
;
j
++)
{
matrix
[
i
][
j
]
=
Integer
.
MAX_VALUE
;
}
}
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
List
<
Integer
>
neighbours
=
JSONArray
.
parseArray
(
locations
.
getJSONObject
(
i
).
getJSONArray
(
"neighbours"
).
toJSONString
(),
Integer
.
class
);
for
(
int
neighbourId
:
neighbours
)
{
JSONObject
neighbourObject
=
id2j
.
get
(
neighbourId
);
System
.
out
.
println
(
neighbourObject
);
index
=
(
Integer
)
neighbourObject
.
get
(
"index"
);
matrix
[
i
][
index
]
=
1
;
matrix
[
index
][
i
]
=
1
;
}
}
}
public
void
construct
(
JSONObject
gameElements
,
UserInfo
userinfo
)
{
try
{
conditionDescription
.
put
(
"site"
,
"当前地点"
);
varInitialMap
.
put
(
"site"
,
"海边"
);
JSONObject
map
=
gameElements
.
getJSONObject
(
"map"
);
Map
<
String
,
String
>
question2keyword
=
JSONObject
.
toJavaObject
(
map
.
getJSONObject
(
"question"
),
Map
.
class
);
JSONArray
locations
=
map
.
getJSONArray
(
"locations"
);
String
userName
=
(
String
)
gameElements
.
get
(
"userName"
);
this
.
locations
=
locations
;
this
.
question2keyword
=
question2keyword
;
//通过邻接表构造邻接矩阵
constructGreph
(
locations
);
//用弗洛伊德算法求最短路径
Floyd
floyd
=
new
Floyd
();
floyd
.
findShortestPath
(
matrix
,
locationNum
);
floyd
.
printPath
(
matrix
,
locationNum
);
generateWantToThere
(
floyd
.
pathMatirx
,
floyd
.
preTable
,
gameElements
);
generateWhereCanIgo
(
floyd
.
pathMatirx
,
floyd
.
preTable
,
gameElements
);
generateWhereIam
(
gameElements
,
userName
);
generateHowToThere
(
floyd
.
pathMatirx
,
floyd
.
preTable
,
gameElements
);
generateSurroundingItem
();
generateSurroundingPeople
();
generateSurroundThings
();
}
catch
(
Exception
e
){
operationStatus
=
0
;
message
=
"地图处理出现异常"
;
return
;
}
}
/**
* 生成‘我在哪里’所需要的配置文件
*/
public
void
generateWhereIam
(
JSONObject
gameElements
,
String
botName
)
{
String
conditionName
=
"rencheng"
;
String
conditionKeywords
=
"qiwu:哪里+qiwu:哪+现在:哪里+现在:哪"
;
String
zainaliKeywords
=
conditionKeywords
.
replace
(
"botName"
,
botName
);
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
zainaliKeywords
,
" "
,
"match"
,
"你在{site-2}"
,
"yaobuyao"
,
""
);
jConfigList
.
add
(
jConfig
);
}
/**
* 生成‘怎么去哪里’所需要的配置文件
*/
public
void
generateHowToThere
(
int
[][]
pathMatirx
,
int
[][]
preTable
,
JSONObject
gameElements
)
{
String
conditionName
=
"want_know_zenmezuo"
;
String
conditionKeywords
=
"去:地点"
;
String
placeA
,
placeB
,
descriptionB
,
placeKeywords
,
text
,
pathNode
;
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
for
(
int
j
=
0
;
j
<
locationNum
;
j
++)
{
placeA
=
(
String
)
locations
.
getJSONObject
(
i
).
get
(
"name"
);
placeB
=
(
String
)
locations
.
getJSONObject
(
j
).
get
(
"name"
);
placeKeywords
=
conditionKeywords
.
replace
(
"地点"
,
placeB
);
if
(
i
==
j
)
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
"match"
,
"你已经在"
+
placeB
+
"了"
,
"yaobuyao"
,
""
);
jConfigList
.
add
(
jConfig
);
continue
;
}
;
if
(
pathMatirx
[
i
][
j
]
==
1
)
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
"match"
,
placeB
+
"就在附近哦"
,
"yaobuyao"
,
""
);
jConfigList
.
add
(
jConfig
);
}
else
if
(
pathMatirx
[
i
][
j
]
>
1
&&
pathMatirx
[
i
][
j
]
<
Integer
.
MAX_VALUE
)
{
int
k
=
preTable
[
i
][
j
];
pathNode
=
""
;
while
(
k
!=
j
)
{
pathNode
+=
(
String
)
locations
.
getJSONObject
(
k
).
get
(
"name"
);
k
=
preTable
[
k
][
j
];
}
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
"match"
,
"经过"
+
pathNode
+
"就可以到达"
+
placeB
,
"yaobuyao"
,
""
);
jConfigList
.
add
(
jConfig
);
}
}
}
}
/**
* 生成‘我能去哪里’所需要的配置文件
*/
public
void
generateWhereCanIgo
(
int
[][]
pathMatirx
,
int
[][]
preTable
,
JSONObject
gameElements
)
{
String
conditionKeywords
=
"去:哪里+能去:哪+能去:哪里+能去:哪儿"
;
String
conditionName
=
"choose_gowhere"
;
String
placeA
,
placeB
,
pathNode
;
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
placeA
=
(
String
)
locations
.
getJSONObject
(
i
).
get
(
"name"
);
pathNode
=
""
;
for
(
int
j
=
0
;
j
<
locationNum
;
j
++)
{
if
(
pathMatirx
[
i
][
j
]
==
1
)
{
placeB
=
(
String
)
locations
.
getJSONObject
(
j
).
get
(
"name"
);
pathNode
+=
"、"
+
placeB
;
}
}
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
conditionKeywords
,
"site::match-Include="
+
placeA
,
"match"
,
"你可以去"
+
pathNode
,
"yaobuyao"
,
""
);
jConfigList
.
add
(
jConfig
);
}
}
/**
* 生成‘我要去那里’所需要的配置文件
*/
public
void
generateWantToThere
(
int
[][]
pathMatirx
,
int
[][]
preTable
,
JSONObject
gameElements
)
{
String
placeA
,
placeB
,
descriptionB
,
placeKeywords
,
text
,
pathNode
,
lastTaskCondition
,
lastTaskReply
;
String
conditionName
=
"yaobuyao"
;
String
conditionKeywords
=
"地点"
;
String
start
=
(
String
)
gameElements
.
get
(
"start"
);
for
(
int
i
=
0
;
i
<
locationNum
;
i
++)
{
placeA
=
(
String
)
locations
.
getJSONObject
(
i
).
get
(
"name"
);
/**
* 添加初始化变量
*/
if
(!
varInitialMap
.
containsKey
(
"任务线"
+
placeA
+
"最后一个condition"
))
{
varInitialMap
.
put
(
"任务线"
+
placeA
+
"最后一个condition"
,
"yaobuyao"
);
varInitialMap
.
put
(
"任务线"
+
placeA
+
"最后的回答"
,
"你来到了"
+
placeA
+
",现在什么都没有, 请继续之前的剧情,接着往下玩吧!"
);
conditionDescription
.
put
(
"任务线"
+
placeA
+
"最后一个condition"
,
"任务线"
+
placeA
+
"最后一个condition"
);
conditionDescription
.
put
(
"任务线"
+
placeA
+
"最后的回答"
,
"任务线"
+
placeA
+
"最后的回答"
);
}
for
(
int
j
=
0
;
j
<
locationNum
;
j
++)
{
placeB
=
(
String
)
locations
.
getJSONObject
(
j
).
get
(
"name"
);
descriptionB
=
(
String
)
locations
.
getJSONObject
(
j
).
get
(
"description"
);
placeKeywords
=
conditionKeywords
.
replace
(
"地点"
,
placeB
);
lastTaskCondition
=
"任务线"
+
placeB
+
"最后一个condition"
;
lastTaskReply
=
"任务线"
+
placeB
+
"最后的回答"
;
if
(
i
==
j
)
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
"match"
,
"你已经在"
+
placeB
+
"了"
,
"yaobuyao"
,
""
);
jConfigList
.
add
(
jConfig
);
continue
;
}
;
//如果两点相邻
if
(
pathMatirx
[
i
][
j
]
==
1
)
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
+
","
+
lastTaskCondition
+
"::match-Include=null"
+
","
+
lastTaskReply
+
"::match-Include=null"
,
"match, reutrn-0"
,
"地点尚未激活"
,
"yaobuyao"
,
""
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
"match"
,
"{"
+
lastTaskReply
+
"-2}"
,
"yaobuyao"
,
"site:"
+
placeB
+
"-<-process-nextStep:var={"
+
lastTaskCondition
+
"-2}"
);
jConfigList
.
add
(
jConfig
);
//如果两点不是相邻点
}
else
if
(
pathMatirx
[
i
][
j
]
>
1
&&
pathMatirx
[
i
][
j
]
<
Integer
.
MAX_VALUE
)
{
int
k
=
preTable
[
i
][
j
];
pathNode
=
""
;
while
(
k
!=
j
)
{
pathNode
+=
(
String
)
locations
.
getJSONObject
(
k
).
get
(
"name"
);
k
=
preTable
[
k
][
j
];
}
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
placeKeywords
,
"site::match-Include="
+
placeA
,
"match"
,
"从"
+
placeA
+
"不能直接到达"
+
placeB
+
", 需要经过"
+
pathNode
+
"才能到达"
+
placeB
,
"yaobuyao"
,
""
);
jConfigList
.
add
(
jConfig
);
}
}
}
}
public
void
generateSurroundingPeople
(){
String
conditionName
=
"know_exist_what"
;
String
conditionKeywords
=
"周围:人+附近:人"
;
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundNpcBySite:"
);
jConfigList
.
add
(
jConfig
);
}
public
void
generateSurroundingItem
(){
String
conditionName
=
"know_exist_what"
;
String
conditionKeywords
=
"周围:物品+周围:东西+附近:物品+附近:东西"
;
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundGoodsBySite:"
);
jConfigList
.
add
(
jConfig
);
}
public
void
generateSurroundThings
(){
String
conditionName
=
"know_exist_what_mohu"
;
String
conditionKeywords
=
"有什么:周围+有什么:附近"
;
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include="
+
conditionKeywords
,
" "
,
"match,return-0"
,
"周围{map_query-2}。"
,
"yaobuyao"
,
"map_query:queryAroundAllBySite:"
);
jConfigList
.
add
(
jConfig
);
}
}
src/main/java/com/qiwu/chatbotbackend/gameDesign/PlotConstructor.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
gameDesign
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.entity.JConfig
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
org.apache.http.message.BasicNameValuePair
;
import
com.qiwu.chatbotbackend.processing.MyFunc
;
import
java.io.UnsupportedEncodingException
;
import
java.util.*
;
public
class
PlotConstructor
extends
ElementConstructor
{
String
botName
=
""
;
JSONArray
plots
=
null
;
HashMap
<
String
,
ArrayList
<
String
>>
adjList
=
new
HashMap
<
String
,
ArrayList
<
String
>>();
HashMap
<
String
,
ArrayList
<
String
>>
revAdjList
=
new
HashMap
<
String
,
ArrayList
<
String
>>();
private
HashMap
<
String
,
JSONObject
>
id2j
=
new
HashMap
<
String
,
JSONObject
>();
HashMap
<
String
,
Boolean
>
visited
=
new
HashMap
<
String
,
Boolean
>();
public
HashMap
<
String
,
JSONObject
>
getId2j
()
{
return
id2j
;
}
public
PlotConstructor
(
SqlHelper
helper
,
int
botId
,
HashSet
<
String
>
exceptRelation
)
{
super
();
this
.
helper
=
helper
;
this
.
botId
=
botId
;
this
.
exceptRelation
=
exceptRelation
;
}
public
void
construct
(
JSONObject
jsonObject
,
UserInfo
userinfo
)
{
try
{
JSONArray
plots
=
jsonObject
.
getJSONArray
(
"plots"
);
String
start
=
(
String
)
jsonObject
.
get
(
"start"
),
startCondition
;
JSONObject
returnMessage
=
null
;
this
.
plots
=
plots
;
constructAdjList
(
plots
);
if
(
id2j
.
containsKey
(
start
))
{
String
taskLineName
=
"任务线_"
+
id2j
.
get
(
start
).
get
(
"place"
)
+
"进度"
;
conditionDescription
.
put
(
taskLineName
,
taskLineName
);
varInitialMap
.
put
(
taskLineName
,
start
);
varInitialMap
.
put
(
"unknownText"
,
"你说啥?"
);
varInitialMap
.
put
(
"game_step"
,
(
String
)
id2j
.
get
(
start
).
get
(
"id"
));
conditionDescription
.
put
(
"unknownText"
,
"对于无法识别的问题做出的回答"
);
conditionDescription
.
put
(
"game_step"
,
"QA问答游戏进度"
);
BFSGenerate4
(
id2j
.
get
(
start
),
userinfo
,
jsonObject
);
varInitialMap
.
put
(
start
,
"1"
);
}
else
{
System
.
out
.
println
(
"start剧情不存在"
);
operationStatus
=
0
;
message
=
"start剧情不存在"
;
return
;
}
}
catch
(
Exception
e
){
operationStatus
=
0
;
message
=
"地图接口处理出现异常"
;
return
;
}
}
//根据id构造邻接表
public
void
constructAdjList
(
JSONArray
plots
)
{
int
length
=
plots
.
size
(),
branchSize
;
String
id
=
""
,
nextPlotId
=
""
;
JSONObject
plot
=
null
;
JSONArray
branch
=
null
;
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
plot
=
plots
.
getJSONObject
(
i
);
id
=
(
String
)
plot
.
get
(
"id"
);
plot
.
put
(
"index"
,
i
);
if
(
adjList
.
get
(
id
)
==
null
)
{
adjList
.
put
(
id
,
new
ArrayList
<>());
}
//添加branch中的下一个plot
branch
=
plot
.
getJSONArray
(
"branch"
);
branchSize
=
branch
.
size
();
for
(
int
j
=
0
;
j
<
branchSize
;
j
++)
{
nextPlotId
=
(
String
)
branch
.
getJSONObject
(
j
).
get
(
"nextPlotId"
);
if
(
revAdjList
.
get
(
nextPlotId
)
==
null
)
{
revAdjList
.
put
(
nextPlotId
,
new
ArrayList
<>());
}
adjList
.
get
(
id
).
add
(
nextPlotId
);
revAdjList
.
get
(
nextPlotId
).
add
(
id
);
}
id2j
.
put
(
id
,
plot
);
}
}
/**
* 根据每个剧情点的进度设置计数器
* @param root
* @param userinfo
*/
public
void
BFSGenerate
(
JSONObject
root
,
UserInfo
userinfo
)
{
String
id
=
(
String
)
root
.
get
(
"id"
),
adjId
,
nextId
,
taskName
=
""
,
value
=
""
,
extraHP
=
""
,
extraUK
=
""
,
nextTaskName
,
keywordOptions
,
conditionName
,
nextUnknownText
,
curUnknownText
,
nextCondition
;
boolean
newBranch
,
manyParent
;
JSONObject
node
=
null
,
branchNode
=
null
,
adjNode
=
null
;
JSONArray
branch
=
null
;
List
<
String
>
adjNodeList
=
null
;
int
priority
,
taskStep
,
nextPriority
,
nextTaskStep
,
branchSize
;
root
.
put
(
"priority"
,
0
);
root
.
put
(
"taskName"
,
id
);
root
.
put
(
"taskStep"
,
0
);
root
.
put
(
"nextUnknownText"
,
varInitialMap
.
get
(
"unknownText"
));
;
Queue
<
JSONObject
>
queue
=
new
LinkedList
<
JSONObject
>();
queue
.
add
(
root
);
while
(!
queue
.
isEmpty
())
{
node
=
queue
.
remove
();
id
=
(
String
)
node
.
get
(
"id"
);
conditionDescription
.
put
(
id
,
"剧情"
+
id
+
"进度"
);
varInitialMap
.
put
(
id
,
""
);
taskName
=
(
String
)
node
.
get
(
"taskName"
);
priority
=
(
Integer
)
node
.
get
(
"priority"
);
taskStep
=
(
Integer
)
node
.
get
(
"taskStep"
);
conditionName
=
(
String
)
node
.
get
(
"conditionName"
);
curUnknownText
=
(
String
)
node
.
get
(
"nextUnknownText"
);
//初始化
newBranch
=
false
;
manyParent
=
false
;
adjNodeList
=
adjList
.
get
(
id
);
visited
.
put
(
id
,
true
);
//查看是否存在多个子结点,如果有就是一个分支
if
(
adjNodeList
.
size
()
>
1
)
newBranch
=
true
;
//查看是否存在多个父节点
if
(
revAdjList
.
get
(
id
)
!=
null
)
manyParent
=
revAdjList
.
get
(
id
).
size
()
>
1
;
if
(
newBranch
)
{
//多个分支时nextTaskName为子结点的id名,不在这里设
nextTaskStep
=
1
;
}
else
{
if
(
manyParent
)
{
nextTaskName
=
id
;
nextTaskStep
=
1
;
priority
++;
}
else
{
nextTaskName
=
taskName
;
nextTaskStep
=
taskStep
+
1
;
}
}
branch
=
node
.
getJSONArray
(
"branch"
);
branchSize
=
branch
.
size
();
//当两次出现unknown时给用户一下候选项
keywordOptions
=
""
;
for
(
int
i
=
0
;
i
<
branchSize
;
i
++)
{
branchNode
=
branch
.
getJSONObject
(
i
);
nextId
=
(
String
)
branchNode
.
get
(
"nextPlotId"
);
Map
<
String
,
String
>
updateKnowledge
=
JSONObject
.
toJavaObject
(
branchNode
.
getJSONObject
(
"updateKnowledge"
),
Map
.
class
);
nextUnknownText
=
updateKnowledge
.
get
(
"unknownText"
);
if
(
id2j
.
get
(
nextId
)
!=
null
)
nextCondition
=
(
String
)
id2j
.
get
(
nextId
).
get
(
"conditionName"
);
else
nextCondition
=
" "
;
//unknown计数器更新为0, 当前任务状态+1
if
(
newBranch
)
extraUK
=
taskName
+
":"
+
taskStep
;
//多余步骤,以后要处理掉
else
extraUK
=
taskName
+
":"
+
(
taskStep
+
1
);
extraHP
=
taskName
+
"::match-Include="
+
taskStep
;
if
(
newBranch
||
(
revAdjList
.
get
(
nextId
)
!=
null
&&
revAdjList
.
get
(
nextId
).
size
()
>
1
))
extraHP
+=
","
+
nextId
+
"::match-Include=null"
;
extraUK
+=
"-<-"
+
nextId
+
":"
+
1
;
jConfig
=
new
JConfig
(
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
String
.
class
),
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"hisPremise"
).
toJSONString
(),
String
.
class
),
updateKnowledge
,
""
,
extraHP
,
extraUK
,
"match"
,
(
String
)
branchNode
.
get
(
"reply"
),
(
String
)
nextCondition
,
String
.
valueOf
(
priority
)
);
jConfigList
.
add
(
jConfig
);
try
{
keywordOptions
+=
jConfig
.
getCurPremise
().
split
(
","
)[
0
].
split
(
"="
)[
1
].
split
(
"\\+"
)[
0
]
+
" 或者"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
branchNode
.
get
(
"nextPlotId"
)
!=
null
)
{
adjId
=
(
String
)
branchNode
.
get
(
"nextPlotId"
);
if
(
visited
.
get
(
adjId
)
==
null
)
{
if
(
id2j
.
get
(
adjId
)
!=
null
)
{
adjNode
=
id2j
.
get
(
adjId
);
adjNode
.
put
(
"nextUnknownText"
,
nextUnknownText
);
adjNode
.
put
(
"taskStep"
,
nextTaskStep
);
if
(
newBranch
)
{
adjNode
.
put
(
"priority"
,
priority
+
1
);
adjNode
.
put
(
"taskName"
,
adjId
);
}
else
{
adjNode
.
put
(
"priority"
,
priority
);
adjNode
.
put
(
"taskName"
,
taskName
);
}
queue
.
add
(
adjNode
);
}
else
{
conditionDescription
.
put
(
adjId
,
"剧情"
+
adjId
+
"进度"
);
varInitialMap
.
put
(
adjId
,
""
);
}
}
}
}
//对于unknown的特殊处理
if
(
curUnknownText
.
equals
(
""
))
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include=unknown"
,
extraHP
=
taskName
+
"::match-Include="
+
taskStep
,
"match,return-0,post::all("
+
CHITCHAT_URL
+
")"
,
" "
,
" "
,
""
);
jConfigList
.
add
(
jConfig
);
}
/*
jConfig.setNextStepStatus("return-0");
jConfigList.add(jConfig);
jConfig = new JConfig(
conditionName + "::match-Keyword=unknown",
extraHP + ",unknown_counter::number-SmallOrEqual=0",
"match",
"{unknownReply-2}",
" ",
"unknown_counter:+1"
);
jConfig.setNextStepStatus("return-0");
jConfigList.add(jConfig);
jConfig = new JConfig(
conditionName + "::match-Keyword=unknown",
extraHP + ",unknown_counter::number-BiggerOrEqual=1",
"match",
"你可以说" + keywordOptions,
" ",
"unknown_counter:+1"
);
jConfig.setNextStepStatus("return-0");
jConfigList.add(jConfig);
*/
}
//unknown时的处理
jConfig
=
new
JConfig
(
" "
,
" "
,
""
,
"{unknownText-2}"
,
" "
,
""
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
}
//每个结点分为0、1、2三种状态
public
void
BFSGenerate2
(
JSONObject
root
)
{
String
id
=
(
String
)
root
.
get
(
"id"
),
adjId
,
nextId
,
taskName
=
""
,
value
=
""
,
extraHP
=
""
,
extraUK
=
""
,
nextTaskName
,
keywordOptions
,
conditionName
,
unknownReply1
,
unknownReply2
,
nextCondition
;
boolean
newBranch
,
manyParent
;
JSONObject
node
=
null
,
branchNode
=
null
,
adjNode
=
null
;
JSONArray
branch
=
null
;
List
<
String
>
adjNodeList
=
null
;
int
priority
,
taskStep
,
nextPriority
,
nextTaskStep
,
branchSize
;
root
.
put
(
"priority"
,
0
);
root
.
put
(
"taskName"
,
id
);
root
.
put
(
"taskStep"
,
0
);
Queue
<
JSONObject
>
queue
=
new
LinkedList
<
JSONObject
>();
queue
.
add
(
root
);
while
(!
queue
.
isEmpty
())
{
node
=
queue
.
remove
();
id
=
(
String
)
node
.
get
(
"id"
);
//初始化
newBranch
=
false
;
manyParent
=
false
;
adjNodeList
=
adjList
.
get
(
id
);
visited
.
put
(
id
,
true
);
/*
//查看是否存在多个子结点,如果有就是一个分支
if(adjNodeList.size() > 1)
newBranch = true;
//查看是否存在多个父节点
if(revAdjList.get(id) != null)
manyParent = revAdjList.get(id).size() > 1;
if(newBranch){
//多个分支时nextTaskName为子结点的id名,不在这里设
nextTaskStep = 1;
}
else{
if(manyParent){
nextTaskName = id;
nextTaskStep = 1;
priority++;
}
else{
nextTaskName = taskName;
nextTaskStep = taskStep + 1;
}
}
*/
branch
=
node
.
getJSONArray
(
"branch"
);
branchSize
=
branch
.
size
();
//当两次出现unknown时给用户一下候选项
keywordOptions
=
""
;
extraHP
=
id
+
"::match-Include="
+
1
;
for
(
int
i
=
0
;
i
<
branchSize
;
i
++)
{
branchNode
=
branch
.
getJSONObject
(
i
);
nextId
=
(
String
)
branchNode
.
get
(
"nextPlotId"
);
if
(
id2j
.
get
(
nextId
)
!=
null
)
nextCondition
=
(
String
)
id2j
.
get
(
nextId
).
get
(
"conditionName"
);
else
nextCondition
=
" "
;
extraUK
=
id
+
":"
+
"+1-<-"
+
nextId
+
":"
+
"+1"
;
//if(newBranch || (revAdjList.get(nextId) != null && revAdjList.get(nextId).size() > 1))
// extraUK += "-<-" + nextId + ":" + 1;
jConfig
=
new
JConfig
(
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
String
.
class
),
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"hisPremise"
).
toJSONString
(),
String
.
class
),
JSONObject
.
toJavaObject
(
branchNode
.
getJSONObject
(
"updateKnowledge"
),
Map
.
class
),
""
,
extraHP
,
extraUK
,
"match"
,
(
String
)
branchNode
.
get
(
"reply"
),
(
String
)
nextCondition
,
"0"
);
jConfigList
.
add
(
jConfig
);
try
{
keywordOptions
+=
jConfig
.
getCurPremise
().
split
(
","
)[
0
].
split
(
"="
)[
1
].
split
(
"\\+"
)[
0
]
+
" 或者"
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
branchNode
.
get
(
"nextPlotId"
)
!=
null
)
{
adjId
=
(
String
)
branchNode
.
get
(
"nextPlotId"
);
if
(
visited
.
get
(
adjId
)
==
null
&&
id2j
.
get
(
adjId
)
!=
null
)
{
adjNode
=
id2j
.
get
(
adjId
);
queue
.
add
(
adjNode
);
}
}
}
}
//unknown时的处理
jConfig
=
new
JConfig
(
" "
,
" "
,
""
,
"{unknownText-2}"
,
" "
,
""
);
jConfig
.
setNextStepStatus
(
"return-0"
);
jConfigList
.
add
(
jConfig
);
}
/**
* 将所有剧情根据地点分为多条剧情线,每一条剧情线都有一个计数器,记录当前地点的剧情到了第几步。
* @param root
* @param userinfo
*/
public
void
BFSGenerate3
(
JSONObject
root
,
UserInfo
userinfo
)
{
String
id
,
rootId
=
(
String
)
root
.
get
(
"id"
),
adjId
,
nextId
,
parentId
,
taskName
=
""
,
value
=
""
,
extraHP
=
""
,
extraUK
=
""
,
nextTaskName
,
keywordOptions
,
conditionName
,
nextUnknownText
,
curUnknownText
,
nextCondition
,
location
,
nextLocation
,
taskLineName
,
nTaskLineName
,
lastTaskReply
,
lastTaskCondition
;
boolean
newBranch
,
manyParent
;
JSONObject
node
=
null
,
branchNode
=
null
,
adjNode
=
null
;
JSONArray
branch
=
null
;
List
<
String
>
adjNodeList
=
null
;
int
priority
,
taskStep
,
nextPriority
,
nextTaskStep
,
branchSize
;
root
.
put
(
"nextUnknownText"
,
varInitialMap
.
get
(
"unknownText"
));
root
.
put
(
"parentId"
,
"null"
);
Queue
<
JSONObject
>
queue
=
new
LinkedList
<
JSONObject
>();
System
.
out
.
println
(
"rootId"
);
queue
.
add
(
root
);
while
(!
queue
.
isEmpty
())
{
node
=
queue
.
remove
();
id
=
(
String
)
node
.
get
(
"id"
);
parentId
=
(
String
)
node
.
get
(
"parentId"
);
location
=
(
String
)
node
.
get
(
"place"
);
conditionName
=
(
String
)
node
.
get
(
"conditionName"
);
curUnknownText
=
(
String
)
node
.
get
(
"nextUnknownText"
);
taskLineName
=
"任务线_"
+
location
+
"进度"
;
//本任务线的最后一个condition和本任务线的最后一个回答
if
(!
varInitialMap
.
containsKey
(
taskLineName
))
{
conditionDescription
.
put
(
taskLineName
,
taskLineName
);
varInitialMap
.
put
(
taskLineName
,
""
);
}
//初始化
newBranch
=
false
;
manyParent
=
false
;
adjNodeList
=
adjList
.
get
(
id
);
visited
.
put
(
id
,
true
);
branch
=
node
.
getJSONArray
(
"branch"
);
branchSize
=
branch
.
size
();
//当两次出现unknown时给用户一下候选项
keywordOptions
=
""
;
for
(
int
i
=
0
;
i
<
branchSize
;
i
++)
{
branchNode
=
branch
.
getJSONObject
(
i
);
nextId
=
(
String
)
branchNode
.
get
(
"nextPlotId"
);
Map
<
String
,
String
>
updateKnowledge
=
JSONObject
.
toJavaObject
(
branchNode
.
getJSONObject
(
"updateKnowledge"
),
Map
.
class
);
nextUnknownText
=
updateKnowledge
.
get
(
"unknownText"
);
//如果存在下一剧情,就将下一步剧情的condition设为下一个激活的conditin,把地点更新为下一步剧情的地点,并更新任务线进度
if
(
id2j
.
get
(
nextId
)
!=
null
)
{
nextCondition
=
(
String
)
id2j
.
get
(
nextId
).
get
(
"conditionName"
);
nextLocation
=
(
String
)
id2j
.
get
(
nextId
).
get
(
"place"
);
nTaskLineName
=
"任务线_"
+
nextLocation
+
"进度"
;
}
else
{
//如果不存在下一剧情,就将condition设为空,任务线进度不变
nextCondition
=
" "
;
nTaskLineName
=
taskLineName
;
nextLocation
=
location
;
}
lastTaskCondition
=
"任务线"
+
nextLocation
+
"最后一个condition"
;
lastTaskReply
=
"任务线"
+
nextLocation
+
"最后的回答"
;
//额外条件是任务线进度达到当前剧情,额外更新变量是将任务线移动至下一剧情
extraHP
=
taskLineName
+
"::match-Include="
+
id
+
",site::match-Include="
+
location
;
//测试用
System
.
out
.
println
(
id
);
extraUK
=
nTaskLineName
+
":"
+
nextId
+
"-<-site:"
+
nextLocation
+
"-<-"
+
lastTaskCondition
+
":var={nextStep-3}"
+
"-<-"
+
lastTaskReply
+
":var={reply-3}"
;
jConfig
=
new
JConfig
(
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
String
.
class
),
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"hisPremise"
).
toJSONString
(),
String
.
class
),
updateKnowledge
,
""
,
extraHP
,
extraUK
,
"match"
,
(
String
)
branchNode
.
get
(
"reply"
),
(
String
)
nextCondition
,
"0"
);
jConfigList
.
add
(
jConfig
);
// try {
// keywordOptions += jConfig.getCurPremise().split(",")[0].split("=")[1].split("\\+")[0] + " 或者";
// } catch (Exception e) {
// e.printStackTrace();
// }
if
(
branchNode
.
get
(
"nextPlotId"
)
!=
null
)
{
adjId
=
(
String
)
branchNode
.
get
(
"nextPlotId"
);
if
(
visited
.
get
(
adjId
)
==
null
)
{
if
(
id2j
.
get
(
adjId
)
!=
null
)
{
adjNode
=
id2j
.
get
(
adjId
);
adjNode
.
put
(
"parentId"
,
id
);
adjNode
.
put
(
"nextUnknownText"
,
nextUnknownText
);
queue
.
add
(
adjNode
);
}
else
{
conditionDescription
.
put
(
adjId
,
"剧情"
+
adjId
+
"进度"
);
varInitialMap
.
put
(
adjId
,
""
);
}
}
}
}
//对于unknown的特殊处理
if
(
curUnknownText
.
equals
(
""
))
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include=unknown"
,
extraHP
=
"任务线_"
+
location
+
"进度::match-Include="
+
parentId
,
"match,return-0,post::all("
+
CHITCHAT_URL
+
")"
,
" "
,
" "
,
""
);
jConfigList
.
add
(
jConfig
);
}
}
jConfig
=
new
JConfig
(
" "
,
" "
,
""
,
" "
,
" "
,
""
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
""
,
""
,
" "
,
" "
,
""
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"common_answer"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
}
/**
* 将所有剧情根据地点分为多条剧情线,每一条剧情线都有一个计数器,记录当前地点的剧情到了第几步。
* 加上剧情计数器, 每一步分为三个状态
* @param root
* @param userinfo
*/
public
void
BFSGenerate4
(
JSONObject
root
,
UserInfo
userinfo
,
JSONObject
jsonObject
)
{
String
id
,
rootId
=
(
String
)
root
.
get
(
"id"
),
adjId
,
nextId
,
parentId
,
taskName
=
""
,
value
=
""
,
extraHP
=
""
,
extraUK
=
""
,
nextTaskName
,
keywordOptions
,
conditionName
,
nextUnknownText
,
curUnknownText
,
nextCondition
,
location
,
nextLocation
,
taskLineName
,
nTaskLineName
,
lastTaskReply
,
lastTaskCondition
;
boolean
newBranch
,
manyParent
;
JSONObject
node
=
null
,
branchNode
=
null
,
adjNode
=
null
;
JSONArray
branch
=
null
;
List
<
String
>
adjNodeList
=
null
;
int
priority
,
taskStep
,
nextPriority
,
nextTaskStep
,
branchSize
;
root
.
put
(
"nextUnknownText"
,
varInitialMap
.
get
(
"unknownText"
));
root
.
put
(
"parentId"
,
"null"
);
String
startPlace
=
(
String
)
root
.
get
(
"place"
);
varInitialMap
.
put
(
"任务线"
+
startPlace
+
"最后一个condition"
,
(
String
)
root
.
get
(
"conditionName"
));
varInitialMap
.
put
(
"任务线"
+
startPlace
+
"最后的回答"
,
(
String
)
jsonObject
.
get
(
"plotStartText"
));
conditionDescription
.
put
(
"任务线"
+
startPlace
+
"最后一个condition"
,
"任务线"
+
startPlace
+
"最后一个condition"
);
conditionDescription
.
put
(
"任务线"
+
startPlace
+
"最后的回答"
,
"任务线"
+
startPlace
+
"最后的回答"
);
Queue
<
JSONObject
>
queue
=
new
LinkedList
<
JSONObject
>();
queue
.
add
(
root
);
while
(!
queue
.
isEmpty
())
{
node
=
queue
.
remove
();
id
=
(
String
)
node
.
get
(
"id"
);
parentId
=
(
String
)
node
.
get
(
"parentId"
);
location
=
(
String
)
node
.
get
(
"place"
);
conditionName
=
(
String
)
node
.
get
(
"conditionName"
);
curUnknownText
=
(
String
)
node
.
get
(
"nextUnknownText"
);
taskLineName
=
"任务线_"
+
location
+
"进度"
;
conditionDescription
.
put
(
id
,
"剧情"
+
id
+
"状态"
);
varInitialMap
.
put
(
id
,
""
);
nextUnknownText
=
""
;
//本任务线的最后一个condition和本任务线的最后一个回答
if
(!
varInitialMap
.
containsKey
(
taskLineName
))
{
conditionDescription
.
put
(
taskLineName
,
taskLineName
);
varInitialMap
.
put
(
taskLineName
,
""
);
}
//初始化
newBranch
=
false
;
manyParent
=
false
;
adjNodeList
=
adjList
.
get
(
id
);
visited
.
put
(
id
,
true
);
branch
=
node
.
getJSONArray
(
"branch"
);
branchSize
=
branch
.
size
();
//当两次出现unknown时给用户一下候选项
keywordOptions
=
""
;
for
(
int
i
=
0
;
i
<
branchSize
;
i
++)
{
branchNode
=
branch
.
getJSONObject
(
i
);
nextId
=
(
String
)
branchNode
.
get
(
"nextPlotId"
);
Map
<
String
,
String
>
updateKnowledge
=
JSONObject
.
toJavaObject
(
branchNode
.
getJSONObject
(
"updateKnowledge"
),
Map
.
class
);
if
(
updateKnowledge
.
containsKey
(
"unkonwnText"
))
nextUnknownText
=
updateKnowledge
.
get
(
"unknownText"
);
else
nextUnknownText
=
"unknown"
;
//如果存在下一剧情,就将下一步剧情的condition设为下一个激活的conditin,把地点更新为下一步剧情的地点,并更新任务线进度
if
(
id2j
.
get
(
nextId
)
!=
null
)
{
nextCondition
=
(
String
)
id2j
.
get
(
nextId
).
get
(
"conditionName"
);
nextLocation
=
(
String
)
id2j
.
get
(
nextId
).
get
(
"place"
);
nTaskLineName
=
"任务线_"
+
nextLocation
+
"进度"
;
}
else
{
//如果不存在下一剧情,就将condition设为空,任务线进度不变
nextCondition
=
" "
;
nTaskLineName
=
taskLineName
;
nextLocation
=
location
;
}
lastTaskCondition
=
"任务线"
+
nextLocation
+
"最后一个condition"
;
lastTaskReply
=
"任务线"
+
nextLocation
+
"最后的回答"
;
//额外条件是任务线进度达到当前剧情,额外更新变量是将任务线移动至下一剧情
extraHP
=
taskLineName
+
"::match-Include="
+
id
+
",site::match-Include="
+
location
+
","
+
id
+
"::number-BiggerOrEqual="
+
1
+
","
+
nextId
+
"::match-Include=null"
;
extraUK
=
nTaskLineName
+
":"
+
nextId
+
"-<-site:"
+
nextLocation
+
"-<-"
+
lastTaskCondition
+
":var={nextStep-3}"
+
"-<-"
+
lastTaskReply
+
":var={reply-3}"
+
"-<-"
+
id
+
":"
+
"+1-<-"
+
nextId
+
":"
+
"+1"
+
"-<-game_step:"
+
botName
+
"_plot_"
+
nextId
;
jConfig
=
new
JConfig
(
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"curPremise"
).
toJSONString
(),
String
.
class
),
JSONArray
.
parseArray
(
branchNode
.
getJSONArray
(
"hisPremise"
).
toJSONString
(),
String
.
class
),
updateKnowledge
,
""
,
extraHP
,
extraUK
,
"match"
,
(
String
)
branchNode
.
get
(
"reply"
),
(
String
)
nextCondition
,
"0"
);
jConfigList
.
add
(
jConfig
);
// try {
// keywordOptions += jConfig.getCurPremise().split(",")[0].split("=")[1].split("\\+")[0] + " 或者";
// } catch (Exception e) {
// e.printStackTrace();
// }
if
(
branchNode
.
get
(
"nextPlotId"
)
!=
null
)
{
adjId
=
(
String
)
branchNode
.
get
(
"nextPlotId"
);
if
(
visited
.
get
(
adjId
)
==
null
)
{
if
(
id2j
.
get
(
adjId
)
!=
null
)
{
adjNode
=
id2j
.
get
(
adjId
);
adjNode
.
put
(
"parentId"
,
id
);
adjNode
.
put
(
"nextUnknownText"
,
nextUnknownText
);
queue
.
add
(
adjNode
);
}
else
{
conditionDescription
.
put
(
adjId
,
"剧情"
+
adjId
+
"进度"
);
varInitialMap
.
put
(
adjId
,
""
);
}
}
}
}
//对于unknown的特殊处理
//对于unknown的特殊处理
if
(
curUnknownText
.
equals
(
""
))
{
jConfig
=
new
JConfig
(
conditionName
+
"::match-Include=unknown"
,
extraHP
=
"任务线_"
+
location
+
"进度::match-Include="
+
parentId
,
"match,return-0,post::all("
+
CHITCHAT_URL
+
")"
,
" "
,
" "
,
""
);
jConfigList
.
add
(
jConfig
);
}
}
/**
* ----------------------------------------------------------------------------------------------------
* 待激活列表,用于qa问答
*/
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=not_found"
,
"match,return-0"
,
"{unknownText-2}"
,
" "
,
""
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown1"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=not_found,unknownText::match-Include=null"
,
"match,return-0"
,
"不好意思,我没听懂你刚才说的话,请换个别的问题试试吧~哎呀,刚才开了小差,没理解你的意思,请换个问题吧~请根据上文信息,认真回答吧,谢谢~我们好像不在一个频道上,换个问题试试,希望我们能够接轨上吧"
,
" "
,
""
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown2"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=ok,qa_score::number-Smaller=90,unknownText::match-Include=null"
,
"match,return-0"
,
"不好意思,我没听懂你刚才说的话,请换个别的问题试试吧~哎呀,刚才开了小差,没理解你的意思,请换个问题吧~请根据上文信息,认真回答吧,谢谢~我们好像不在一个频道上,换个问题试试,希望我们能够接轨上吧"
,
" "
,
""
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown3"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=ok,qa_score::number-Smaller=90"
,
"match,return-0"
,
"{unknownText-2}"
,
" "
,
""
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"unknown4"
);
jConfig
.
setjStatus
(
1
);
jConfigList
.
add
(
jConfig
);
jConfig
=
new
JConfig
(
" "
,
"qa_status::match-Include=ok,qa_score::number-BiggerOrEqual=90"
,
"match,return-0"
,
"{common_answer-2}"
,
" "
,
""
);
jConfig
.
setStatus
(
"sleeping"
);
jConfig
.
setConfigName
(
"common_answer"
);
jConfigList
.
add
(
jConfig
);
//---------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------------
}
@Override
public
void
postProcessing
(
List
<
Integer
>
idList
,
int
categoryId
){
if
(
idList
.
size
()
!=
0
)
{
jConfig
=
new
JConfig
(
" "
,
" "
,
"activate,post::all(http://simqa.sz.chewrobot.com:28081/game)"
,
""
,
idList
.
get
(
idList
.
size
()
-
5
)
+
","
+
idList
.
get
(
idList
.
size
()
-
4
)
+
","
+
idList
.
get
(
idList
.
size
()
-
3
)
+
","
+
idList
.
get
(
idList
.
size
()
-
2
)
+
","
+
idList
.
get
(
idList
.
size
()
-
1
),
""
);
jConfig
.
setNextStepStatus
(
"active"
);
JSONObject
json
=
jConfig
.
toJson
(
this
.
getConditionDescription
());
helper
.
insertConfigByBotId
(
botId
,
json
,
idList
,
categoryId
);
jConfigList
.
add
(
jConfig
);
}
}
}
src/main/java/com/qiwu/chatbotbackend/processing/ChatCacheController.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
com.qiwu.chatbotbackend.GameEnvironment.GameEnv
;
import
com.alibaba.fastjson.JSON
;
import
com.qiwu.chatbotbackend.entity.ChatCache
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
javax.servlet.ServletContext
;
import
java.io.*
;
import
java.sql.SQLException
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Map
;
public
class
ChatCacheController
{
/**
* 通过chat_key获得后台保存的历史信息点
* chatCache:存储了chatKye相对应的对话记录(历史信息点)
*
* @return 历史信息点,对话过程中引擎提取的用户信息
*/
// public static synchronized Map<String, String> getChatCache(String chatKey, ServletContext context) {
//
// GameEnv gameEnv = new GameEnv(chatKey);
// Map<String, String> historyInfoPoint = null;
// Map<String, Map<String, String>> chatCache = null;
// if (context.getAttribute("chatCache") == null) {
// chatCache = new HashMap<String, Map<String, String>>();
// context.setAttribute("chatCache", chatCache);
// } else {
// chatCache = (Map<String, Map<String, String>>) context.getAttribute("chatCache");
// }
// String chatkey;
//
//
// try {
// historyInfoPoint = chatCache.get(chatKey);
// //historyInfoPoint = (Map<String, String>) context.getAttribute("chat_key+"+userinfo.userName);
// } catch (Exception e) {
//
// //可整合
// historyInfoPoint = null;
//
// }
//
// return historyInfoPoint;
// }
/**
* chatChche中每个chatkey都有对应的最后更新时间,如果最后更新时间已经是x分钟前(超时),就清除该chatKey的数据
*/
// public static synchronized void updateChatCache4Delete(ServletContext context) {
// String chatKey;
// long lastChatTime, now;
// Map<String, String> history = new HashMap<String, String>();
// Map<String, Map<String, String>> chatCache = (Map<String, Map<String, String>>) context.getAttribute("chatCache");
//
//
// Iterator<String> it = chatCache.keySet().iterator();
// while (it.hasNext()) {
// chatKey = it.next();
// history = chatCache.get(chatKey);
// lastChatTime = Long.valueOf(history.get("lastUpdateTime"));
// now = System.currentTimeMillis();
// if (now - lastChatTime > 300000) {
// it.remove();
// }
// }
// context.setAttribute("chatCache", chatCache);
// }
/**
* 根据chatKey更新chatCache的数据,并修改最后更新时间
*/
// public static synchronized void updateChatCache4Insert(Map<String, String[]> curInfoPoint, Map<String, String> historyInfoPoint, ServletContext context) {
// historyInfoPoint.put("lastUpdateTime", String.valueOf(System.currentTimeMillis()));
// Map<String, Map<String, String>> keyCache = (Map<String, Map<String, String>>) context.getAttribute("chatCache");
// keyCache.put(curInfoPoint.get("chat_key")[0], historyInfoPoint);
// context.setAttribute("chatCache", keyCache);
// }
public
static
boolean
saveChatCache
(
String
userName
,
HashMap
<
String
,
String
>
infoPoints
)
throws
IOException
{
String
fileDir
=
System
.
getProperty
(
"user.dir"
)
+
"/ChatCache"
;
String
key
;
boolean
saveFlag
=
true
;
try
{
File
dir
=
new
File
(
fileDir
);
if
(!
dir
.
exists
())
dir
.
mkdir
();
File
file
=
new
File
(
fileDir
+
"/"
+
userName
+
".txt"
);
FileWriter
fw
=
new
FileWriter
(
file
);
Iterator
<
String
>
infoIter
=
infoPoints
.
keySet
().
iterator
();
while
(
infoIter
.
hasNext
())
{
key
=
infoIter
.
next
();
fw
.
write
(
key
+
"-----"
+
infoPoints
.
get
(
key
)
+
"\n"
);
}
fw
.
close
();
}
catch
(
Exception
e
)
{
saveFlag
=
false
;
}
return
saveFlag
;
}
public
static
boolean
loadChatCache
(
String
userName
,
ServletContext
context
)
{
String
fileDir
=
System
.
getProperty
(
"user.dir"
)
+
"/ChatCache"
;
String
line
,
pair
[];
Map
<
String
,
String
>
infoPoints
=
new
HashMap
<
String
,
String
>();
try
{
File
file
=
new
File
(
fileDir
+
"/"
+
userName
+
".txt"
);
if
(!
file
.
exists
())
{
return
false
;
}
else
{
FileReader
fr
=
new
FileReader
(
file
);
BufferedReader
br
=
new
BufferedReader
(
fr
);
while
((
line
=
br
.
readLine
())
!=
null
)
{
pair
=
line
.
trim
().
split
(
"-----"
);
infoPoints
.
put
(
pair
[
0
],
pair
[
1
]);
}
// context.setAttribute(userName, );
fr
.
close
();
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
true
;
}
public
static
synchronized
ChatCache
getChatCache
(
String
chatKey
,
ServletContext
context
,
UserInfo
userinfo
)
throws
Exception
{
Map
<
String
,
ChatCache
>
chatCacheMap
=
null
;
ChatCache
chatCache
=
null
;
if
(
context
.
getAttribute
(
"chatCache"
)
==
null
)
{
chatCacheMap
=
new
HashMap
<
String
,
ChatCache
>();
chatCacheMap
.
put
(
chatKey
,
new
ChatCache
(
userinfo
));
context
.
setAttribute
(
"chatCache"
,
chatCacheMap
);
}
else
{
chatCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
}
String
chatkey
;
try
{
chatCache
=
chatCacheMap
.
get
(
chatKey
);
if
(
chatCache
==
null
){
chatCache
=
new
ChatCache
(
userinfo
);
chatCacheMap
.
put
(
chatKey
,
chatCache
);
}
//historyInfoPoint = (Map<String, String>) context.getAttribute("chat_key+"+userinfo.userName);
}
catch
(
Exception
e
)
{
//可整合
chatCache
=
new
ChatCache
(
userinfo
);
}
return
chatCache
;
}
/**
* chatChche中每个chatkey都有对应的最后更新时间,如果最后更新时间已经是x分钟前(超时),就清除该chatKey的数据
*/
public
static
synchronized
void
updateChatCache4Delete
(
String
curChatKey
,
ServletContext
context
)
{
String
chatKey
;
ChatCache
chatCache
=
null
;
long
lastChatTime
,
now
;
Map
<
String
,
String
>
history
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
ChatCache
>
chatCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
Iterator
<
String
>
it
=
chatCacheMap
.
keySet
().
iterator
();
while
(
it
.
hasNext
())
{
chatKey
=
it
.
next
();
if
(
curChatKey
.
equals
(
chatKey
))
continue
;
history
=
chatCacheMap
.
get
(
chatKey
).
getInfoPoint
();
lastChatTime
=
Long
.
valueOf
(
history
.
get
(
"lastUpdateTime"
));
now
=
System
.
currentTimeMillis
();
if
(
now
-
lastChatTime
>
300000
)
{
chatCache
=
chatCacheMap
.
get
(
chatKey
);
saveChatCache
(
chatKey
,
chatCache
);
it
.
remove
();
}
}
context
.
setAttribute
(
"chatCache"
,
chatCacheMap
);
}
/**
* 根据chatKey更新chatCache的数据,并修改最后更新时间
*/
public
static
synchronized
void
updateChatCache4Insert
(
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
GameEnv
gameEnv
,
ServletContext
context
)
{
historyInfoPoint
.
put
(
"lastUpdateTime"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
Map
<
String
,
ChatCache
>
keyCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
ChatCache
chatCache
=
keyCacheMap
.
get
(
curInfoPoint
.
get
(
"chat_key"
));
chatCache
.
setInfoPoint
(
historyInfoPoint
);
chatCache
.
setGameEnv
(
gameEnv
);
context
.
setAttribute
(
"chatCache"
,
keyCacheMap
);
}
public
static
synchronized
String
saveChatCache
(
String
chatKey
,
ChatCache
chatCache
){
if
(
chatCache
==
null
){
return
"chat_key不存在或者已失效"
;
}
else
{
String
jChatCache
=
JSON
.
toJSONString
(
chatCache
);
System
.
out
.
println
(
jChatCache
);
chatCache
=
JSON
.
parseObject
(
jChatCache
,
ChatCache
.
class
);
System
.
out
.
println
(
chatCache
.
getInfoPoint
().
size
());
return
"成功"
;
}
}
}
src/main/java/com/qiwu/chatbotbackend/processing/ConditionTableController.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
com.qiwu.chatbotbackend.entity.Condition
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
javax.servlet.ServletContext
;
import
java.io.BufferedWriter
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
public
class
ConditionTableController
{
public
static
boolean
deleteConfig
(
String
userName
,
String
configId
,
String
data
,
ServletContext
context
)
throws
IOException
{
int
id
=
Integer
.
parseInt
(
configId
);
Condition
condition
=
new
Condition
();
UserInfoController
userInfoController
=
new
UserInfoController
();
//data=configLine+"---"+conditionNameList
String
conditionNameList
[]
=
data
.
split
(
","
);
String
conditionName
=
""
;
if
(
context
.
getAttribute
(
userName
)
==
null
)
{
userInfoController
.
userConfigInit
(
userName
,
context
);
}
UserInfo
userInfo
=
(
UserInfo
)
context
.
getAttribute
(
userName
);
if
(
userInfo
.
id2config
.
containsKey
(
id
))
{
//-------------------
try
{
Condition
oldCondition
=
userInfo
.
id2condition
.
get
(
id
);
conditionName
=
oldCondition
.
indexName
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
userInfo
.
conditionTable
.
get
(
conditionName
)
!=
null
)
{
List
<
Condition
>
conditionList
=
userInfo
.
conditionTable
.
get
(
conditionName
);
Iterator
<
Condition
>
condIter
=
userInfo
.
conditionTable
.
get
(
conditionName
).
iterator
();
while
(
condIter
.
hasNext
())
{
Condition
c
=
condIter
.
next
();
if
(
c
.
id
==
id
)
{
condIter
.
remove
();
}
}
}
userInfo
.
id2config
.
remove
(
id
);
userInfo
.
id2condition
.
remove
(
id
);
}
else
{
System
.
out
.
println
(
"未找到要删除的configId"
);
}
return
true
;
}
public
static
boolean
batchDeleteConfig
(
String
userName
,
List
<
Integer
>
idGroup
,
UserInfo
userInfo
)
throws
IOException
{
Condition
condition
=
new
Condition
();
String
conditionName
=
""
;
for
(
int
configId
:
idGroup
)
{
if
(
userInfo
.
id2config
.
containsKey
(
configId
))
{
try
{
Condition
oldCondition
=
userInfo
.
id2condition
.
get
(
configId
);
conditionName
=
oldCondition
.
indexName
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
userInfo
.
conditionTable
.
get
(
conditionName
)
!=
null
)
{
List
<
Condition
>
conditionList
=
userInfo
.
conditionTable
.
get
(
conditionName
);
Iterator
<
Condition
>
condIter
=
userInfo
.
conditionTable
.
get
(
conditionName
).
iterator
();
while
(
condIter
.
hasNext
())
{
Condition
c
=
condIter
.
next
();
if
(
c
.
id
==
configId
)
{
condIter
.
remove
();
}
}
}
userInfo
.
id2config
.
remove
(
configId
);
userInfo
.
id2condition
.
remove
(
configId
);
}
else
{
System
.
out
.
println
(
"未找到要删除的configId:"
+
configId
);
}
}
return
true
;
}
public
static
boolean
insertConfig
(
String
userName
,
String
configId
,
String
data
,
ServletContext
context
)
throws
IOException
{
Condition
condition
=
new
Condition
();
//data=configLine+"---"+conditionNameList
String
dataPair
[]
=
data
.
split
(
"---"
);
String
configLine
=
dataPair
[
0
];
String
conditionNameList
[];
UserInfoController
userInfoController
=
new
UserInfoController
();
int
id
=
Integer
.
parseInt
(
configId
);
condition
=
userInfoController
.
buildCondition
(
condition
,
configLine
);
if
(
context
.
getAttribute
(
userName
)
==
null
)
{
userInfoController
.
userConfigInit
(
userName
,
context
);
}
UserInfo
userinfo
=
(
UserInfo
)
context
.
getAttribute
(
userName
);
if
(
userinfo
.
conditionTable
.
get
(
condition
.
indexName
)
==
null
)
{
List
<
Condition
>
conditionList
=
new
ArrayList
<
Condition
>();
userinfo
.
conditionTable
.
put
(
condition
.
indexName
,
conditionList
);
}
userinfo
.
conditionTable
.
get
(
condition
.
indexName
).
add
(
condition
);
userinfo
.
id2config
.
put
(
id
,
configLine
);
userinfo
.
id2condition
.
put
(
id
,
condition
);
return
true
;
}
public
static
boolean
updateVariable
(
String
userName
,
String
configId
,
String
data
,
ServletContext
context
)
throws
IOException
{
Condition
condition
=
new
Condition
();
//data=configLine+"---"+conditionNameList
String
dataPair
[]
=
data
.
split
(
"---"
,
-
1
);
String
name
=
dataPair
[
0
],
value
=
dataPair
[
1
];
UserInfoController
userInfoController
=
new
UserInfoController
();
if
(
context
.
getAttribute
(
userName
)
==
null
)
{
userInfoController
.
userConfigInit
(
userName
,
context
);
}
UserInfo
userinfo
=
(
UserInfo
)
context
.
getAttribute
(
userName
);
userinfo
.
varInitialMap
.
put
(
name
,
value
);
return
true
;
}
public
static
boolean
deleteVariable
(
String
userName
,
String
configId
,
String
data
,
ServletContext
context
)
throws
IOException
{
//data=configLine+"---"+conditionNameList
String
name
=
data
;
UserInfoController
userInfoController
=
new
UserInfoController
();
if
(
context
.
getAttribute
(
userName
)
==
null
)
{
userInfoController
.
userConfigInit
(
userName
,
context
);
}
UserInfo
userinfo
=
(
UserInfo
)
context
.
getAttribute
(
userName
);
userinfo
.
varInitialMap
.
remove
(
name
);
return
true
;
}
public
static
boolean
updateExtraInfo
(
String
userName
,
String
data
,
ServletContext
context
)
throws
IOException
{
UserInfoController
userInfoController
=
new
UserInfoController
();
if
(
context
.
getAttribute
(
userName
)
==
null
)
{
userInfoController
.
userConfigInit
(
userName
,
context
);
}
UserInfo
userinfo
=
(
UserInfo
)
context
.
getAttribute
(
userName
);
String
extraElements
[]
=
data
.
split
(
"\\|"
);
userinfo
.
extraInfo
.
put
(
extraElements
[
1
],
extraElements
[
2
]);
return
true
;
}
public
static
String
writeConfigText
(
String
userName
,
UserInfo
userinfo
)
throws
IOException
{
System
.
out
.
println
(
"p"
);
System
.
out
.
println
(
userName
);
String
CONFIG_DIR
=
System
.
getProperty
(
"user.dir"
)
+
"/config"
,
configText
;
String
path
=
CONFIG_DIR
+
"/"
+
userName
+
".txt"
;
File
file
=
new
File
(
path
);
File
dir
=
new
File
(
System
.
getProperty
(
"user.dir"
)
+
"/config"
);
String
returnMessage
=
"success"
;
if
(!
dir
.
exists
())
dir
.
mkdir
();
if
(!
file
.
exists
())
{
file
.
createNewFile
();
}
FileWriter
fw
=
new
FileWriter
(
file
);
BufferedWriter
bw
=
new
BufferedWriter
(
fw
);
try
{
Iterator
<
String
>
keyIter
=
userinfo
.
extraInfo
.
keySet
().
iterator
();
while
(
keyIter
.
hasNext
())
{
String
info
=
keyIter
.
next
();
if
(!
userinfo
.
extraInfo
.
get
(
info
).
equals
(
""
))
bw
.
write
(
"-extraInfo-|"
+
info
+
"|"
+
userinfo
.
extraInfo
.
get
(
info
)
+
"\n"
);
}
keyIter
=
userinfo
.
varInitialMap
.
keySet
().
iterator
();
while
(
keyIter
.
hasNext
())
{
String
info
=
keyIter
.
next
();
bw
.
write
(
"-varInitial-|"
+
info
+
"|"
+
userinfo
.
varInitialMap
.
get
(
info
)
+
"\n"
);
}
Iterator
<
Integer
>
idIter
=
userinfo
.
id2config
.
keySet
().
iterator
();
while
(
idIter
.
hasNext
())
{
int
id
=
idIter
.
next
();
bw
.
write
(
userinfo
.
id2config
.
get
(
id
)
+
"\n"
);
}
bw
.
write
(
"\n"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
returnMessage
=
"config file write error"
;
}
finally
{
bw
.
close
();
fw
.
close
();
}
return
returnMessage
;
}
}
src/main/java/com/qiwu/chatbotbackend/processing/LogWriter.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
java.io.*
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.HashMap
;
import
java.util.Map
;
public
class
LogWriter
{
private
PrintWriter
recorder
=
null
;
DateTimeFormatter
dtf
=
DateTimeFormatter
.
ofPattern
(
"MM-dd HH:mm:ss"
);
LocalDateTime
ldt
=
null
;
String
PRINT_PATTERN
=
"<font color=\"%s\">[%s] %s"
+
"----------------------------------------------------------------------------<br></font>"
;
Map
<
Integer
,
String
>
colerMap
=
new
HashMap
<
Integer
,
String
>(){
{
put
(
0
,
"black"
);
put
(
1
,
"gray"
);
put
(
2
,
"green"
);
put
(
3
,
"yellow"
);
put
(
4
,
"green"
);
put
(
5
,
"red"
);
}
};
public
LogWriter
(
String
filePath
,
String
fileName
)
throws
IOException
{
File
file
=
new
File
(
filePath
+
"/"
+
fileName
+
".html"
);
System
.
out
.
println
(
file
.
getAbsolutePath
());
if
(!
file
.
exists
())
{
file
.
createNewFile
();
}
file
.
setReadable
(
true
,
false
);
FileWriter
fw
=
new
FileWriter
(
file
,
true
);
BufferedWriter
bw
=
new
BufferedWriter
(
fw
);
recorder
=
new
PrintWriter
(
bw
);
recorder
.
println
(
"<!DOCTYPE html>\n"
+
"<html>\n"
+
"<head>\n"
+
" <meta charset=\"UTF-8\">\n"
+
" <title>log</title>\n"
+
"</head>"
);
}
public
void
record
(
String
text
,
int
level
){
ldt
=
LocalDateTime
.
now
();
recorder
.
println
(
String
.
format
(
PRINT_PATTERN
,
colerMap
.
get
(
level
),
ldt
.
format
(
dtf
),
text
));
}
public
void
writeln
(){
recorder
.
println
(
"<br>"
);
}
public
void
close
(){
recorder
.
close
();
}
}
src/main/java/com/qiwu/chatbotbackend/processing/MyFunc.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.entity.Solution
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
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.HttpClients
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
public
class
MyFunc
{
/**
* 将后台返回的数据转成json格式
*/
public
static
String
toJson
(
Solution
ans
)
{
JSONObject
jobj
=
new
JSONObject
();
jobj
.
put
(
"solution"
,
ans
.
getAnswer
());
jobj
.
put
(
"status"
,
ans
.
getStatus
());
jobj
.
put
(
"process"
,
ans
.
getNext
());
return
jobj
.
toString
();
}
public
static
String
toJson
(
String
returnStr
)
{
JSONObject
jobj
=
new
JSONObject
();
jobj
.
put
(
"returnString"
,
returnStr
);
return
jobj
.
toString
();
}
/**
* 当请求中的数据是json格式时,该函数用于提取request中的json数据
*
* @param request
* @return json字符串
*/
public
static
String
readJSONString
(
HttpServletRequest
request
)
{
StringBuffer
json
=
new
StringBuffer
();
String
line
=
null
;
try
{
BufferedReader
reader
=
request
.
getReader
();
while
((
line
=
reader
.
readLine
())
!=
null
)
{
json
.
append
(
line
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
json
.
toString
();
}
/**
* 通过get方法传递参数时需要对参数的编码进行转换
*/
public
static
String
convert2Utf8
(
String
s
)
{
if
(
s
==
null
)
return
null
;
try
{
s
=
new
String
(
s
.
getBytes
(
"iso-8859-1"
),
"utf-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
return
s
;
}
public
static
long
transferToMillisecond
(
String
keyword
)
throws
ParseException
{
long
time
;
System
.
out
.
println
(
keyword
);
String
timeSeries
[]
=
{
"时"
,
"分"
,
"秒"
};
for
(
String
f
:
timeSeries
)
{
if
(!
keyword
.
contains
(
f
))
keyword
+=
"0"
+
f
;
}
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy年M月d日H时m分s秒"
);
time
=
format
.
parse
(
keyword
).
getTime
();
return
time
;
}
public
static
String
transferToStandardTime
(
long
time
)
throws
ParseException
{
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy年M月d日H时m分s秒"
);
Date
date
=
new
Date
(
time
);
return
format
.
format
(
date
);
}
public
static
boolean
isInteger
(
String
str
){
return
true
;
}
public
static
JSONObject
postJSON
(
String
url
,
JSONObject
data
)
throws
UnsupportedEncodingException
{
JSONObject
jobj
=
new
JSONObject
();
HttpPost
httpPost
=
new
HttpPost
(
url
);
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
String
respContent
=
null
;
String
keyName
=
null
;
StringEntity
entity
=
new
StringEntity
(
data
.
toJSONString
(),
"utf-8"
);
entity
.
setContentType
(
"application/json; charset=utf-8"
);
httpPost
.
setEntity
(
entity
);
try
{
HttpResponse
resp
=
client
.
execute
(
httpPost
);
if
(
resp
.
getStatusLine
().
getStatusCode
()
==
200
)
{
HttpEntity
he
=
resp
.
getEntity
();
respContent
=
EntityUtils
.
toString
(
he
,
"UTF-8"
);
jobj
=
JSONObject
.
parseObject
(
respContent
);
}
else
{
jobj
.
put
(
"status"
,
0
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
jobj
;
}
}
src/main/java/com/qiwu/chatbotbackend/processing/QuestionMatcher.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.GameEnvironment.GameEnv
;
import
com.qiwu.chatbotbackend.entity.Solution
;
import
com.qiwu.chatbotbackend.entity.Condition
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.methods.HttpPost
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
javax.servlet.ServletContext
;
import
java.io.*
;
import
java.text.ParseException
;
import
java.util.*
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
public
class
QuestionMatcher
{
Map
<
Integer
,
Condition
>
activatedMap
=
new
HashMap
<
Integer
,
Condition
>();
static
String
POST_DATA_ERROR
=
"post数据有误"
;
static
String
POST_ERROR
=
"数据post时出错了"
;
static
String
API_ERROR
=
"api处理过程中出错了"
;
static
String
VARIABLE_REPLACE_PATTERN
=
"(\\{.*?\\-[12]\\})"
;
Pattern
replacePattern
=
Pattern
.
compile
(
VARIABLE_REPLACE_PATTERN
);
public
LogWriter
logWriter
=
null
;
public
UserInfo
userinfo
=
null
;
public
ServletContext
context
=
null
;
public
GameEnv
gameEnv
=
null
;
public
Map
<
String
,
String
>
curInfoPoint
=
null
;
public
Map
<
String
,
String
>
historyInfoPoint
=
null
;
public
WorldController
worldController
=
null
;
public
QuestionMatcher
(
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
LogWriter
logWriter
,
UserInfo
userinfo
,
ServletContext
context
,
GameEnv
gameEnv
)
{
this
.
curInfoPoint
=
curInfoPoint
;
this
.
historyInfoPoint
=
historyInfoPoint
;
this
.
logWriter
=
logWriter
;
this
.
userinfo
=
userinfo
;
this
.
context
=
context
;
this
.
gameEnv
=
gameEnv
;
this
.
worldController
=
new
WorldController
(
logWriter
);
}
/**
public void updateDB(QuestionKeyWord qkw) throws SQLException {
SqlHelper helper = new SqlHelper();
String result = helper.queryActionByKey(qkw.getChatKey());
if(result != "empty")
//待添加
//qkw.setActionName(result+"+"+qkw.getActionName());
helper.updateAction(qkw);
else
helper.insertAction(qkw);
helper.destroy();
}
*/
public
boolean
infoPointPreprocessing
(
Map
<
String
,
String
[]>
receiveParameters
,
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
UserInfo
userinfo
,
ServletContext
context
)
throws
IOException
{
String
return_str
=
""
,
k
;
String
receiveParameterStr
=
""
;
boolean
debugFlag
=
false
;
HashSet
<
String
>
skipSet
=
new
HashSet
<
String
>()
{
{
add
(
"chat_key"
);
add
(
"action_name"
);
add
(
"bot_name"
);
add
(
"emptySet"
);
add
(
"query_text"
);
}
};
//输出所有actionName的值
Iterator
<
String
>
iit
=
receiveParameters
.
keySet
().
iterator
();
receiveParameterStr
+=
"-----------------------------------------识别数据列表-------------------------------------------<br>"
;
while
(
iit
.
hasNext
())
{
k
=
iit
.
next
();
//
receiveParameterStr
+=
k
+
": "
;
curInfoPoint
.
put
(
k
,
receiveParameters
.
get
(
k
)[
0
]);
if
(
k
.
equals
(
"debug_mode"
))
debugFlag
=
true
;
String
values
[]
=
receiveParameters
.
get
(
k
);
for
(
String
v
:
values
)
{
receiveParameterStr
+=
v
+
" "
;
}
receiveParameterStr
+=
"<br>"
;
if
(
values
[
0
].
equals
(
":"
))
{
curInfoPoint
.
put
(
k
,
""
);
}
if
(!
historyInfoPoint
.
containsKey
(
k
))
historyInfoPoint
.
put
(
k
,
""
);
}
logWriter
.
record
(
receiveParameterStr
,
0
);
//如果引擎什么信息都没识别到,那就将上一轮的nextStep(也就是当前轮的actionName)设为unknown
iit
=
curInfoPoint
.
keySet
().
iterator
();
boolean
unknown_flag
=
true
;
while
(
iit
.
hasNext
())
{
k
=
iit
.
next
();
String
values
=
curInfoPoint
.
get
(
k
);
if
(
skipSet
.
contains
(
k
))
continue
;
if
(!
values
.
equals
(
""
))
{
unknown_flag
=
false
;
break
;
}
}
String
currentAction
=
""
;
if
(
historyInfoPoint
.
containsKey
(
"currentAction"
))
currentAction
=
historyInfoPoint
.
get
(
"currentAction"
);
else
if
(
userinfo
.
extraInfo
.
containsKey
(
"activeAction"
))
{
currentAction
=
userinfo
.
extraInfo
.
get
(
"activeAction"
);
historyInfoPoint
.
put
(
"currentAction"
,
currentAction
);
}
else
currentAction
=
" "
;
curInfoPoint
.
put
(
"emptySet"
,
" "
);
if
(
historyInfoPoint
.
get
(
"activeList"
)
==
null
)
{
historyInfoPoint
.
put
(
"activeList"
,
currentAction
);
}
if
(
unknown_flag
&&
!
currentAction
.
equals
(
""
))
{
String
i
=
"unknown"
;
curInfoPoint
.
put
(
currentAction
,
i
);
}
return
debugFlag
;
}
/**
* 用迭代器迭代当前信息点中的非空关键字,由conditionName索引到状态表中保存包含conditionName这个条件的列表,并查询状态表中的条件是否满足及其优先级,满足条件且优先级更高就设为bestMatch
*
* @param conditionTable 满足什么条件,就回答什么,下一步跳什么
* @return bestMatch 状态表中满足条件最多的一条
*/
public
Condition
getBestMatch
(
HashMap
<
String
,
List
<
Condition
>>
conditionTable
,
ServletContext
context
,
UserInfo
userInfo
)
throws
IOException
{
Integer
configId
=
0
;
List
<
Condition
>
conditionList
=
null
;
Condition
bestMatch
=
new
Condition
(-
1
),
iterCon
;
Iterator
<
String
>
it
=
curInfoPoint
.
keySet
().
iterator
();
Queue
<
Condition
>
activatedQueue
=
new
LinkedList
<
Condition
>();
Queue
<
Condition
>
activatedCondition
=
new
LinkedList
<
Condition
>();
while
(
it
.
hasNext
())
{
String
conditionName
=
it
.
next
();
String
keywords
=
curInfoPoint
.
get
(
conditionName
);
String
keyword
=
null
;
if
(
keywords
!=
null
&&
!
keywords
.
equals
(
""
))
keyword
=
keywords
;
if
(
keyword
!=
null
&&
conditionTable
.
get
(
conditionName
)
!=
null
)
{
conditionList
=
conditionTable
.
get
(
conditionName
);
for
(
Condition
condition
:
conditionList
)
{
if
(
condition
.
status
.
equals
(
"waiting"
)
&&
conditionSatisfy
(
condition
))
{
logWriter
.
record
(
"匹配更新为:\""
+
userinfo
.
id2config
.
get
(
condition
.
id
)
+
"\""
,
2
);
logWriter
.
writeln
();
if
(
condition
.
featureMap
.
get
(
"instantPost"
)
!=
null
)
{
}
//Post后还是可以激活
if
(
condition
.
featureMap
.
get
(
"activate"
)
!=
null
&&
!
condition
.
featureMap
.
containsKey
(
"post"
))
{
//有post这个feature的配置条目会在最后激活它的待激活列表,这里就不激活了。
bestMatch
=
condition
;
activateCondition
(
activatedQueue
,
curInfoPoint
.
get
(
"bot_name"
),
condition
.
priority
,
condition
.
auxiliaryPriority
,
condition
.
nextStep
,
context
);
//} else if ((condition.priority > bestMatch.priority) || (condition.priority == bestMatch.priority && condition.auxiliaryPriority > bestMatch.auxiliaryPriority))
}
else
if
((
condition
.
auxiliaryPriority
>
bestMatch
.
auxiliaryPriority
)
||
(
condition
.
auxiliaryPriority
==
bestMatch
.
auxiliaryPriority
&&
condition
.
priority
>
bestMatch
.
priority
))
bestMatch
=
condition
;
}
}
}
}
logWriter
.
record
(
"----------------------匹配结束"
,
2
);
bestMatch
=
activatedQueueMatching
(
bestMatch
,
activatedQueue
,
context
);
return
bestMatch
;
}
/**
* 在激活列表中选择满足匹配且优先级最高的一条配置条目
* @param bestMatch
* @param activatedQueue
* @param context
* @return
* @throws IOException
*/
public
Condition
activatedQueueMatching
(
Condition
bestMatch
,
Queue
<
Condition
>
activatedQueue
,
ServletContext
context
)
throws
IOException
{
Condition
condition
;
//待激活配置条目被激活后的匹配
while
(!
activatedQueue
.
isEmpty
())
{
condition
=
activatedQueue
.
remove
();
activatedMap
.
remove
(
condition
.
id
);
if
(
conditionSatisfy
(
condition
))
{
if
(
condition
.
featureMap
.
containsKey
(
"activate"
)
&&
!
condition
.
featureMap
.
containsKey
(
"post"
))
{
logWriter
.
record
(
"匹配更新为:\""
+
userinfo
.
id2config
.
get
(
condition
.
id
)
+
"\""
,
2
);
logWriter
.
writeln
();
bestMatch
=
condition
;
activateCondition
(
activatedQueue
,
curInfoPoint
.
get
(
"bot_name"
),
condition
.
priority
,
condition
.
auxiliaryPriority
,
condition
.
nextStep
,
context
);
//} else if ((condition.activePriority > bestMatch.activePriority) || (condition.activePriority == bestMatch.activePriority && condition.auxiliaryPriority > bestMatch.auxiliaryPriority)) {
}
else
if
((
condition
.
auxiliaryPriority
>
bestMatch
.
auxiliaryPriority
)
||
(
condition
.
auxiliaryPriority
==
bestMatch
.
auxiliaryPriority
&&
condition
.
activePriority
>
bestMatch
.
activePriority
))
{
bestMatch
=
condition
;
logWriter
.
record
(
"匹配更新为:\""
+
userinfo
.
id2config
.
get
(
condition
.
id
)
+
"\""
,
2
);
logWriter
.
writeln
();
}
}
}
return
bestMatch
;
}
/**
* 根据当前信息点,历史信息点,判断是否满足该condition的条件,match关键字指引擎识别的关键字包含在condition相应的关键词列表中,这里可以根据特征添加其他操作。
* currentPremise是当前信息点需要满足的条件,historyPremise是历史信息点需要满足的条件
*
* @param condition 配置文件(状态表)的一行
* @return 满足条件就为True, 不满足就为False
*/
public
boolean
conditionSatisfy
(
Condition
condition
)
{
boolean
flag
=
true
;
String
actionName
,
keywords
,
keyword
,
comparePair
[],
cmpType
,
premiseStr
;
HashSet
<
String
>
keywordSet
=
null
;
logWriter
.
record
(
"-----------------------------------检索到配置条目"
,
0
);
logWriter
.
record
(
userinfo
.
id2config
.
get
(
condition
.
id
),
1
);
if
(
condition
.
featureMap
.
containsKey
(
"match"
))
{
Iterator
<
String
>
it
=
condition
.
currentPremise
.
keySet
().
iterator
();
while
(
flag
&&
it
.
hasNext
())
{
premiseStr
=
it
.
next
();
comparePair
=
premiseStr
.
split
(
"::"
);
actionName
=
comparePair
[
0
];
cmpType
=
comparePair
[
1
];
keyword
=
getKeyword
(
curInfoPoint
,
actionName
);
if
(
keyword
==
null
)
{
flag
=
false
;
if
(
flag
==
false
){
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过------------------------"
,
5
);
logWriter
.
writeln
();
}
break
;
}
keywordSet
=
condition
.
currentPremise
.
get
(
premiseStr
);
if
(!
premiseSatisfy
(
keyword
,
cmpType
,
keywordSet
))
flag
=
false
;
if
(
flag
==
false
){
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过------------------------"
,
5
);
logWriter
.
writeln
();
}
}
it
=
condition
.
historyPremise
.
keySet
().
iterator
();
while
(
flag
&&
it
.
hasNext
())
{
premiseStr
=
it
.
next
();
comparePair
=
premiseStr
.
split
(
"::"
);
cmpType
=
comparePair
[
1
];
actionName
=
comparePair
[
0
];
keyword
=
getKeyword
(
historyInfoPoint
,
actionName
);
if
(
keyword
==
null
)
{
flag
=
false
;
if
(
flag
==
false
){
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过------------------------"
,
5
);
logWriter
.
writeln
();
}
break
;
}
keywordSet
=
condition
.
historyPremise
.
get
(
premiseStr
);
if
(!
premiseSatisfy
(
keyword
,
cmpType
,
keywordSet
))
flag
=
false
;
if
(
flag
==
false
){
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过------------------------"
,
5
);
logWriter
.
writeln
();
}
}
}
return
flag
;
}
public
String
getKeyword
(
Map
<
String
,
String
>
infoPoint
,
String
actionName
){
String
keyword
=
""
;
String
nameSeries
[]
=
actionName
.
split
(
"_"
);
if
(
actionName
.
startsWith
(
"npc_"
)){
if
(
nameSeries
.
length
==
4
){
String
keywrod
=
gameEnv
.
queryNpcAttrByNpcName
(
nameSeries
[
3
],
nameSeries
[
4
]);
}
}
else
if
(
actionName
.
startsWith
(
"goods_"
)){
if
(
nameSeries
.
length
==
4
){
keyword
=
gameEnv
.
queryGoodsAttrByGoodsName
(
nameSeries
[
2
],
nameSeries
[
3
]);
System
.
out
.
println
(
"return"
+
keyword
);
}
}
else
{
keyword
=
infoPoint
.
get
(
actionName
);
}
return
keyword
;
};
/**
* 单个条件的匹配,判断是否满足条件
* 比较类型分为 match、number、time、variable,
* curVarCmp和hisVarCmp是变量比较的两种形式,分别是比较当前信息和比较已知信息
*
* @param keyword
* @param cmpType 比较类型
* @param keywordSet 候选关键字集合,满足其中任意一个都算满足条件
* @return 返回匹配或者不匹配
*/
public
boolean
premiseSatisfy
(
String
keyword
,
String
cmpType
,
HashSet
<
String
>
keywordSet
)
{
boolean
flag
=
true
;
String
operator
=
""
;
try
{
String
splitPair
[]
=
cmpType
.
split
(
"-"
);
if
(
splitPair
.
length
>
1
)
{
operator
=
splitPair
[
1
];
cmpType
=
splitPair
[
0
];
}
if
(
cmpType
.
equals
(
"match"
))
{
if
(
operator
.
equals
(
"Keyword"
)
||
operator
.
equals
(
"Include"
))
{
if
(!
keywordSet
.
contains
(
keyword
))
{
flag
=
false
;
}
if
(
flag
==
false
&&
keyword
.
contains
(
":"
))
{
String
ks
[]
=
keyword
.
split
(
":"
);
for
(
String
k
:
ks
)
{
if
(
keywordSet
.
contains
(
k
))
flag
=
true
;
}
}
}
else
if
(
operator
.
equals
(
"Exclude"
))
{
if
(
keywordSet
.
contains
(
keyword
))
{
flag
=
false
;
}
}
else
{
flag
=
false
;
}
}
else
if
(
cmpType
.
equals
(
"number"
)
&&
!
keyword
.
equals
(
""
))
{
int
candidateA
=
0
;
int
candidateB
=
0
;
if
(
keyword
.
contains
(
":"
))
{
String
ks
[]
=
keyword
.
split
(
":"
);
for
(
String
k
:
ks
)
{
if
(
StringUtils
.
isNumeric
(
k
))
keyword
=
k
;
}
}
if
(!
StringUtils
.
isNumeric
(
keyword
)){
return
false
;
}
candidateA
=
Integer
.
parseInt
(
keyword
);
for
(
String
k
:
keywordSet
)
{
if
(!
k
.
equals
(
""
))
{
candidateB
=
Integer
.
parseInt
(
k
);
break
;
}
}
if
(
operator
.
equals
(
"Bigger"
))
flag
=
candidateA
>
candidateB
;
else
if
(
operator
.
equals
(
"BiggerOrEqual"
))
flag
=
candidateA
>=
candidateB
;
else
if
(
operator
.
equals
(
"Smaller"
))
flag
=
candidateA
<
candidateB
;
else
if
(
operator
.
equals
(
"SmallerOrEqual"
))
flag
=
candidateA
<=
candidateB
;
else
if
(
operator
.
equals
(
"NotEqual"
))
flag
=
candidateA
!=
candidateB
;
}
else
if
(
cmpType
.
equals
(
"time"
))
{
long
candidateA
,
candidateB
=
0
;
if
(
keyword
.
contains
(
":"
))
{
String
ks
[]
=
keyword
.
split
(
":"
);
for
(
String
k
:
ks
)
{
if
(
k
.
contains
(
"年"
)
&&
k
.
contains
(
"月"
)
&&
k
.
contains
(
"日"
))
keyword
=
k
;
}
}
candidateA
=
MyFunc
.
transferToMillisecond
(
keyword
);
for
(
String
k
:
keywordSet
)
{
if
(!
k
.
equals
(
""
))
{
candidateB
=
MyFunc
.
transferToMillisecond
(
k
);
break
;
}
}
if
(
operator
.
equals
(
"Early"
))
flag
=
candidateA
<
candidateB
;
else
if
(
operator
.
equals
(
"Later"
))
flag
=
candidateA
>
candidateB
;
}
else
if
(
cmpType
.
equals
(
"curVarCmp"
)
||
cmpType
.
equals
(
"hisVarCmp"
))
{
String
conditionName2
=
""
,
conditionValue2
=
""
;
for
(
String
k
:
keywordSet
)
{
if
(!
k
.
equals
(
""
))
{
conditionName2
=
k
;
break
;
}
}
if
(
cmpType
.
equals
(
"curVarCmp"
)
&&
curInfoPoint
.
get
(
conditionName2
)
!=
null
&&
!
curInfoPoint
.
get
(
conditionName2
).
equals
(
""
))
{
conditionValue2
=
getKeyword
(
curInfoPoint
,
conditionName2
);
}
else
if
(
cmpType
.
equals
(
"hisVarCmp"
)
&&
historyInfoPoint
.
get
(
conditionName2
)
!=
null
&&
!
historyInfoPoint
.
get
(
conditionName2
).
equals
(
""
)){
conditionValue2
=
getKeyword
(
historyInfoPoint
,
conditionName2
);
}
else
{
flag
=
false
;
}
if
(
flag
){
/**
* flag 默认为空, 当同为数字或者时间且比较结果为真是flag才为true
*/
flag
=
false
;
if
(
operator
.
equals
(
"Equal"
)){
flag
=
keyword
.
equals
(
conditionValue2
);
}
else
if
(
keyword
.
contains
(
":"
)
&&
conditionValue2
.
contains
(
":"
)){
String
relPair1
[]
=
keyword
.
split
(
":"
,
2
),
keyword1
=
""
;
String
relPair2
[]
=
conditionValue2
.
split
(
":"
,
2
),
keyword2
=
""
;
boolean
similar
=
false
;
if
(
relPair1
[
0
].
equals
(
relPair2
[
0
])){
similar
=
true
;
keyword1
=
relPair1
[
1
];
keyword2
=
relPair2
[
1
];
}
else
if
(
relPair1
[
1
].
equals
(
relPair2
[
1
])){
similar
=
true
;
keyword1
=
relPair1
[
0
];
keyword2
=
relPair2
[
0
];
}
if
(
similar
){
if
(
StringUtils
.
isNumeric
(
keyword1
)
&&
StringUtils
.
isNumeric
(
keyword2
)){
int
candidateA
=
Integer
.
parseInt
(
keyword1
);
int
candidateB
=
Integer
.
parseInt
(
keyword2
);
if
(
operator
.
equals
(
"Bigger"
))
flag
=
candidateA
>
candidateB
;
else
if
(
operator
.
equals
(
"BiggerOrEqual"
))
flag
=
candidateA
>=
candidateB
;
else
if
(
operator
.
equals
(
"Smaller"
))
flag
=
candidateA
<
candidateB
;
else
if
(
operator
.
equals
(
"SmallerOrEqual"
))
flag
=
candidateA
<=
candidateB
;
else
if
(
operator
.
equals
(
"Equal"
))
flag
=
candidateA
==
candidateB
;
else
if
(
operator
.
equals
(
"NotEqual"
))
flag
=
candidateA
!=
candidateB
;
}
else
if
(
keyword1
.
contains
(
"年"
)
&&
keyword1
.
contains
(
"月"
)
&&
keyword1
.
contains
(
"日"
)
&&
keyword2
.
contains
(
"年"
)
&&
keyword2
.
contains
(
"月"
)
&&
keyword2
.
contains
(
"日"
)){
long
candidateA
=
MyFunc
.
transferToMillisecond
(
keyword1
);
long
candidateB
=
MyFunc
.
transferToMillisecond
(
keyword2
);
if
(
operator
.
equals
(
"Bigger"
))
flag
=
candidateA
>
candidateB
;
else
if
(
operator
.
equals
(
"BiggerOrEqual"
))
flag
=
candidateA
>=
candidateB
;
else
if
(
operator
.
equals
(
"Smaller"
))
flag
=
candidateA
<
candidateB
;
else
if
(
operator
.
equals
(
"SmallerOrEqual"
))
flag
=
candidateA
<=
candidateB
;
else
if
(
operator
.
equals
(
"Equal"
))
flag
=
candidateA
==
candidateB
;
else
if
(
operator
.
equals
(
"NotEqual"
))
flag
=
candidateA
!=
candidateB
;
// 操作符为等于时可以比较两个字符串是否相同
}
}
}
else
if
(!
keyword
.
contains
(
":"
)
&&
!
conditionValue2
.
contains
(
":"
)){
if
(
StringUtils
.
isNumeric
(
keyword
)
&&
StringUtils
.
isNumeric
(
conditionValue2
)){
int
candidateA
=
Integer
.
parseInt
(
keyword
);
int
candidateB
=
Integer
.
parseInt
(
conditionValue2
);
if
(
operator
.
equals
(
"Bigger"
))
flag
=
candidateA
>
candidateB
;
else
if
(
operator
.
equals
(
"BiggerOrEqual"
))
flag
=
candidateA
>=
candidateB
;
else
if
(
operator
.
equals
(
"Smaller"
))
flag
=
candidateA
<
candidateB
;
else
if
(
operator
.
equals
(
"SmallerOrEqual"
))
flag
=
candidateA
<=
candidateB
;
else
if
(
operator
.
equals
(
"Equal"
))
flag
=
candidateA
==
candidateB
;
else
if
(
operator
.
equals
(
"NotEqual"
))
flag
=
candidateA
!=
candidateB
;
}
else
if
(
keyword
.
contains
(
"年"
)
&&
keyword
.
contains
(
"月"
)
&&
keyword
.
contains
(
"日"
)
&&
conditionValue2
.
contains
(
"年"
)
&&
conditionValue2
.
contains
(
"月"
)
&&
conditionValue2
.
contains
(
"日"
)){
long
candidateA
=
MyFunc
.
transferToMillisecond
(
keyword
);
long
candidateB
=
MyFunc
.
transferToMillisecond
(
conditionValue2
);
if
(
operator
.
equals
(
"Bigger"
))
flag
=
candidateA
>
candidateB
;
else
if
(
operator
.
equals
(
"BiggerOrEqual"
))
flag
=
candidateA
>=
candidateB
;
else
if
(
operator
.
equals
(
"Smaller"
))
flag
=
candidateA
<
candidateB
;
else
if
(
operator
.
equals
(
"SmallerOrEqual"
))
flag
=
candidateA
<=
candidateB
;
else
if
(
operator
.
equals
(
"Equal"
))
flag
=
candidateA
==
candidateB
;
else
if
(
operator
.
equals
(
"NotEqual"
))
flag
=
candidateA
!=
candidateB
;
// 操作符为等于时可以比较两个字符串是否相同
}
}
}
}
//--------------------------------------------------------------------
//为兼容旧数据
else
if
(
cmpType
.
equals
(
"numberBigger"
)
&&
StringUtils
.
isNumeric
(
keyword
))
{
int
candidateA
=
0
;
int
candidateB
=
0
;
candidateA
=
Integer
.
parseInt
(
keyword
);
for
(
String
k
:
keywordSet
)
{
if
(!
k
.
equals
(
""
))
{
candidateB
=
Integer
.
parseInt
(
k
);
break
;
}
}
flag
=
candidateA
>
candidateB
;
}
else
if
(
cmpType
.
equals
(
"numberBiggerOrEqual"
)
&&
StringUtils
.
isNumeric
(
keyword
))
{
int
candidateA
=
0
;
int
candidateB
=
0
;
candidateA
=
Integer
.
parseInt
(
keyword
);
for
(
String
k
:
keywordSet
)
{
if
(!
k
.
equals
(
""
))
{
candidateB
=
Integer
.
parseInt
(
k
);
break
;
}
}
flag
=
candidateA
>=
candidateB
;
}
else
if
(
cmpType
.
equals
(
"numberSmaller"
)
&&
StringUtils
.
isNumeric
(
keyword
))
{
int
candidateA
=
0
;
int
candidateB
=
0
;
candidateA
=
Integer
.
parseInt
(
keyword
);
for
(
String
k
:
keywordSet
)
{
if
(!
k
.
equals
(
""
))
{
candidateB
=
Integer
.
parseInt
(
k
);
break
;
}
}
flag
=
candidateA
<
candidateB
;
}
else
if
(
cmpType
.
equals
(
"numberSmallerOrEqual"
)
&&
StringUtils
.
isNumeric
(
keyword
))
{
int
candidateA
=
0
;
int
candidateB
=
0
;
candidateA
=
Integer
.
parseInt
(
keyword
);
for
(
String
k
:
keywordSet
)
{
if
(!
k
.
equals
(
""
))
{
candidateB
=
Integer
.
parseInt
(
k
);
break
;
}
}
flag
=
candidateA
<=
candidateB
;
}
else
if
(
cmpType
.
equals
(
"timeEarly"
))
{
long
candidateA
,
candidateB
=
0
;
candidateA
=
MyFunc
.
transferToMillisecond
(
keyword
);
for
(
String
k
:
keywordSet
)
{
if
(!
k
.
equals
(
""
))
{
candidateB
=
MyFunc
.
transferToMillisecond
(
k
);
break
;
}
}
flag
=
candidateA
<
candidateB
;
}
else
if
(
cmpType
.
equals
(
"timeLater"
))
{
long
candidateA
,
candidateB
=
0
;
candidateA
=
MyFunc
.
transferToMillisecond
(
keyword
);
for
(
String
k
:
keywordSet
)
{
if
(!
k
.
equals
(
""
))
{
candidateB
=
MyFunc
.
transferToMillisecond
(
k
);
break
;
}
}
flag
=
candidateA
>
candidateB
;
}
else
if
(
cmpType
.
equals
(
"any"
))
{
if
(
keyword
.
equals
(
""
))
//当前信息点中的关键词不为空即满足条件,为空则不满足
flag
=
false
;
}
else
{
flag
=
false
;
}
}
catch
(
IndexOutOfBoundsException
e
)
{
System
.
out
.
println
(
"配置文件格式有误"
);
flag
=
false
;
e
.
printStackTrace
();
}
catch
(
ParseException
e
)
{
System
.
out
.
println
(
"时间解析错误"
);
e
.
printStackTrace
();
flag
=
false
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"操作符有误"
);
e
.
printStackTrace
();
flag
=
false
;
}
return
flag
;
}
/**
* 替换答案中相应的变量{xxx-1},并根据当前信息点更新历史信息点(当前在下一轮变成历史)。
*
* @return 返回给引擎的数据
*/
public
Solution
getSolution
(
Condition
ansCondition
,
ServletContext
context
,
UserInfo
userinfo
)
throws
IOException
,
ParseException
{
Iterator
<
String
>
it
=
curInfoPoint
.
keySet
().
iterator
();
String
actionName
,
reply
,
variable
;
Solution
ans
=
new
Solution
(
0
,
""
,
""
);
//如果一条配置文件有多个答案,则随
// 机选择一个答案
int
randNum
=
(
int
)
(
Math
.
random
()
*
ansCondition
.
answer
.
length
);
ans
.
setAnswer
(
ansCondition
.
answer
[
randNum
]);
//System.out.println(ans.getAnswer());
//post关键字
if
(
ansCondition
.
featureMap
.
containsKey
(
"post"
))
{
logWriter
.
record
(
"---------------------进入表单结束"
,
1
);
ans
=
postToServer
(
ans
,
ansCondition
);
logWriter
.
record
(
"---------------------提交表单结束"
,
1
);
//nextNext关键字
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//updateKnowledge关键字
if
(
ansCondition
.
featureMap
.
containsKey
(
"updateKnowledge"
))
{
logWriter
.
record
(
"---------------------进入更新答案【略】"
,
1
);
updateKnowledge
(
ansCondition
);
logWriter
.
record
(
"---------------------更新答案结束"
,
1
);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
if
(
ansCondition
.
featureMap
.
containsKey
(
"newNext"
))
{
logWriter
.
record
(
"---------------------进入判断下一步【略】"
,
1
);
ans
=
findNewNext
(
ans
,
ansCondition
);
logWriter
.
record
(
"---------------------判断下一步结束"
,
1
);
//上一步
}
else
if
(
ansCondition
.
featureMap
.
containsKey
(
"return-1"
))
{
String
activeList
[]
=
historyInfoPoint
.
get
(
"activeList"
).
split
(
"\\|"
);
if
(
activeList
.
length
==
1
)
ans
.
setNext
(
"nextStep="
+
activeList
[
activeList
.
length
-
1
]);
else
{
ans
.
setNext
(
"nextStep="
+
activeList
[
activeList
.
length
-
2
]);
}
//停留
}
else
if
(
ansCondition
.
featureMap
.
containsKey
(
"return-0"
))
{
String
activeList
[]
=
historyInfoPoint
.
get
(
"activeList"
).
split
(
"\\|"
);
ans
.
setNext
(
"nextStep="
+
activeList
[
activeList
.
length
-
1
]);
//激活
}
else
if
(
ansCondition
.
featureMap
.
containsKey
(
"activate"
))
{
String
activeList
[]
=
historyInfoPoint
.
get
(
"activeList"
).
split
(
"\\|"
);
if
(
activeList
.
length
==
1
)
ans
.
setNext
(
"nextStep="
+
activeList
[
activeList
.
length
-
1
]);
else
{
ans
.
setNext
(
"nextStep="
+
activeList
[
activeList
.
length
-
2
]);
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
if
(
ans
.
getNext
().
equals
(
""
))
{
ans
.
setNext
(
"nextStep="
+
ansCondition
.
nextStep
);
}
try
{
//用正则表达式将回答中的变量模板{conditionName-2}替换成后台存储的变量值
reply
=
ans
.
getAnswer
();
Matcher
m
=
replacePattern
.
matcher
(
reply
);
while
(
m
.
find
())
{
variable
=
m
.
group
(
1
).
substring
(
1
,
m
.
group
(
1
).
length
()
-
3
);
if
(
m
.
group
(
1
).
endsWith
(
"-1}"
))
{
if
(
curInfoPoint
.
get
(
variable
)
!=
null
&&
!
curInfoPoint
.
get
(
variable
).
equals
(
""
))
reply
=
reply
.
replace
(
"{"
+
variable
+
"-1}"
,
curInfoPoint
.
get
(
variable
));
}
else
if
(
m
.
group
(
1
).
endsWith
(
"-2}"
))
{
if
(
historyInfoPoint
.
get
(
variable
)
!=
null
)
if
(
historyInfoPoint
.
get
(
variable
).
equals
(
"do_reset"
)){
reply
=
reply
.
replace
(
"{"
+
variable
+
"-2}"
,
""
);
}
else
reply
=
reply
.
replace
(
"{"
+
variable
+
"-2}"
,
historyInfoPoint
.
get
(
variable
));
}
}
ans
.
setAnswer
(
reply
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
ans
;
}
/**
* 请求处理结束后台将当前信息的信息点转移到已知信息
* @param ans
* @param context
* @param debugFlag
*/
public
void
infoTransfer
(
Solution
ans
,
ServletContext
context
,
boolean
debugFlag
)
{
//将当前信息点更新至历史信息点
Iterator
<
String
>
it
=
curInfoPoint
.
keySet
().
iterator
();
String
actionName
,
lastReply
;
String
next
=
ans
.
getNext
().
split
(
"="
,
2
)[
1
];
//保存即将跳转的action名以供下一轮使用,nextStep的结构是nextStep=xxx
historyInfoPoint
.
put
(
"currentAction"
,
next
);
historyInfoPoint
.
put
(
"activeList"
,
historyInfoPoint
.
get
(
"activeList"
)
+
"|"
+
next
);
HashSet
<
String
>
skipSet
=
new
HashSet
<
String
>()
{
{
add
(
"chat_key"
);
add
(
"action_name"
);
add
(
"bot_name"
);
add
(
"emptySet"
);
add
(
"query_text"
);
}
};
if
(
debugFlag
)
lastReply
=
ans
.
getAnswer
().
split
(
")"
)[
2
];
else
lastReply
=
ans
.
getAnswer
();
historyInfoPoint
.
put
(
"lastReply"
,
lastReply
);
try
{
String
keyword1
,
keyword2
;
while
(
it
.
hasNext
())
{
actionName
=
it
.
next
();
if
(
skipSet
.
contains
(
actionName
))
continue
;
keyword1
=
curInfoPoint
.
get
(
actionName
);
keyword2
=
historyInfoPoint
.
get
(
actionName
);
if
(
keyword2
==
null
)
{
historyInfoPoint
.
put
(
actionName
,
keyword1
);
}
else
if
(
historyInfoPoint
.
get
(
actionName
).
equals
(
"do_reset"
)){
historyInfoPoint
.
put
(
actionName
,
""
);
}
else
if
(
keyword2
!=
null
&&
!
keyword1
.
equals
(
""
))
historyInfoPoint
.
put
(
actionName
,
keyword1
);
}
ChatCacheController
.
updateChatCache4Insert
(
curInfoPoint
,
historyInfoPoint
,
gameEnv
,
context
);
//context.setAttribute("chat_key+"+userinfo.botAccount,historyInfoPoint);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
/**
* 在新平台添加debug_mode这个关键字, 后台会将存储的变量值返回给页面以作调试
*
* @param ans 最终返回的数据
* @param context
*/
public
void
appendDebugInfo
(
Solution
ans
,
ServletContext
context
)
{
Iterator
<
String
>
it
=
null
;
String
key
,
values
,
value
;
HashSet
<
String
>
skipSet
=
new
HashSet
<
String
>()
{
{
add
(
"activeList"
);
add
(
"currentAction"
);
add
(
"lastUpdateTime"
);
add
(
"bot_name"
);
add
(
"action_name"
);
add
(
"lastReply"
);
}
};
it
=
curInfoPoint
.
keySet
().
iterator
();
String
debugInfo
=
""
;
debugInfo
+=
"<font color=\"green\">(识别:"
;
while
(
it
.
hasNext
())
{
key
=
it
.
next
();
values
=
curInfoPoint
.
get
(
key
);
if
(
values
!=
null
&&
!
values
.
equals
(
" "
)
&&
!
values
.
equals
(
""
)
&&
!
skipSet
.
contains
(
key
))
{
if
(
key
.
endsWith
(
"_backup"
))
{
key
=
key
.
substring
(
0
,
key
.
length
()
-
7
);
}
debugInfo
+=
(
" "
+
key
+
":\'"
+
values
+
"\' "
);
}
}
debugInfo
+=
")(已知:"
;
it
=
historyInfoPoint
.
keySet
().
iterator
();
while
(
it
.
hasNext
())
{
key
=
it
.
next
();
value
=
historyInfoPoint
.
get
(
key
);
if
(
value
!=
null
&&
!
value
.
equals
(
" "
)
&&
!
value
.
equals
(
""
)
&&
!
skipSet
.
contains
(
key
)
&&
!
key
.
endsWith
(
"最后的回答"
)
&&
!
key
.
endsWith
(
"最后一个condition"
))
debugInfo
+=
(
" "
+
key
+
":\'"
+
value
+
"\' "
);
}
ans
.
setAnswer
(
debugInfo
+
")</font>"
+
ans
.
getAnswer
());
}
/**
* 重新post到其他服务器读取数据,并根据这些数据修改返回给用户的信息,可能包括nextStep,和回答文本中的可变参数(用replace方法替换)
*
* @param ans 返回给用户的数据
* @param ansCondition 满足条件最多的condition(配置文件的某一行)
*/
public
Solution
postToServer
(
Solution
ans
,
Condition
ansCondition
)
throws
IOException
{
String
url
=
null
,
elem
[],
subElem
[],
key
,
keys
,
postType
=
"all"
;
Map
<
String
,
String
>
infoMap
=
new
HashMap
<
String
,
String
>();
List
<
BasicNameValuePair
>
pairList
=
new
ArrayList
<
BasicNameValuePair
>();
Iterator
<
String
>
k_iter
=
null
;
HashSet
<
String
>
skipSet
=
new
HashSet
<
String
>()
{
{
add
(
"activeList"
);
add
(
"currentAction"
);
add
(
"lastUpdateTime"
);
add
(
"lastReply"
);
}
};
elem
=
ansCondition
.
featureMap
.
get
(
"post"
).
split
(
"\\|"
);
url
=
elem
[
0
];
postType
=
elem
[
1
];
//提交类型为all时,会把当前信息点和历史信息点都作为post到另一个服务器
if
(
postType
.
equals
(
"all"
))
{
k_iter
=
curInfoPoint
.
keySet
().
iterator
();
while
(
k_iter
.
hasNext
())
{
key
=
k_iter
.
next
();
if
(
curInfoPoint
.
get
(
key
)
!=
""
)
//infoMap.put(key + "_cur", curInfoPoint.get(key)[0]);
pairList
.
add
(
new
BasicNameValuePair
(
key
,
curInfoPoint
.
get
(
key
)));
}
k_iter
=
historyInfoPoint
.
keySet
().
iterator
();
while
(
k_iter
.
hasNext
())
{
key
=
k_iter
.
next
();
if
(
historyInfoPoint
.
get
(
key
)
!=
""
)
//infoMap.put(key + "_his", historyInfoPoint.get(key));
if
(
key
.
equals
(
"game_step"
))
pairList
.
add
(
new
BasicNameValuePair
(
key
,
historyInfoPoint
.
get
(
key
)));
else
if
(
skipSet
.
contains
(
key
)){}
else
pairList
.
add
(
new
BasicNameValuePair
(
key
+
"_his"
,
historyInfoPoint
.
get
(
key
)));
}
//提交类型为term时只会提交最佳匹配的配置条目中包含的条件和值
}
else
if
(
postType
.
equals
(
"term"
))
{
pairList
.
add
(
new
BasicNameValuePair
(
"chat_key"
,
curInfoPoint
.
get
(
"chat_key"
)));
pairList
.
add
(
new
BasicNameValuePair
(
"action_name"
,
curInfoPoint
.
get
(
"action_name"
)));
pairList
.
add
(
new
BasicNameValuePair
(
"bot_name"
,
curInfoPoint
.
get
(
"bot_name"
)));
k_iter
=
ansCondition
.
currentPremise
.
keySet
().
iterator
();
while
(
k_iter
.
hasNext
())
{
key
=
k_iter
.
next
().
split
(
"::"
)[
0
];
if
(
curInfoPoint
.
get
(
key
)
!=
""
)
pairList
.
add
(
new
BasicNameValuePair
(
key
,
curInfoPoint
.
get
(
key
)));
}
k_iter
=
ansCondition
.
historyPremise
.
keySet
().
iterator
();
while
(
k_iter
.
hasNext
())
{
key
=
k_iter
.
next
().
split
(
"::"
)[
0
];
if
(
historyInfoPoint
.
get
(
key
)
!=
""
)
pairList
.
add
(
new
BasicNameValuePair
(
key
+
"_his"
,
historyInfoPoint
.
get
(
key
)));
//infoMap.put(key + "_his", historyInfoPoint.get(key));
}
}
logWriter
.
record
(
"提交表单的数据:<br>"
+
pairList
.
toString
(),
2
);
HttpPost
httpPost
=
new
HttpPost
(
url
);
CloseableHttpClient
client
=
HttpClients
.
createDefault
();
String
respContent
=
null
;
String
keyName
=
null
;
UrlEncodedFormEntity
entity
=
new
UrlEncodedFormEntity
(
pairList
,
"utf-8"
);
entity
.
setContentType
(
"application/x-www-form-urlencoded"
);
httpPost
.
setEntity
(
entity
);
try
{
HttpResponse
resp
=
client
.
execute
(
httpPost
);
if
(
resp
.
getStatusLine
().
getStatusCode
()
==
200
)
{
HttpEntity
he
=
resp
.
getEntity
();
respContent
=
EntityUtils
.
toString
(
he
,
"UTF-8"
);
logWriter
.
record
(
"提交表单接收到的数据:<br>"
+
respContent
,
2
);
JSONObject
jobj
=
JSONObject
.
parseObject
(
respContent
);
Iterator
<
String
>
kit
=
jobj
.
keySet
().
iterator
();
while
(
kit
.
hasNext
())
{
keyName
=
kit
.
next
();
if
(
keyName
.
equals
(
"process"
))
{
ans
.
setNext
((
String
)
jobj
.
get
(
keyName
));
historyInfoPoint
.
put
(
"process"
,
(
String
)
jobj
.
get
(
keyName
));
}
else
if
(
keyName
.
equals
(
"solution"
))
{
ans
.
setAnswer
((
String
)
jobj
.
get
(
keyName
));
}
else
if
(
keyName
.
equals
(
"status"
)){
continue
;
}
else
{
historyInfoPoint
.
put
(
keyName
,
jobj
.
getString
(
keyName
));
}
}
}
else
{
ans
.
setAnswer
(
API_ERROR
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
ans
.
setAnswer
(
POST_ERROR
+
url
);
return
ans
;
}
return
ans
;
}
public
Solution
findNewNext
(
Solution
ans
,
Condition
ansCondition
)
{
String
nextOptions
[]
=
ansCondition
.
nextStep
.
split
(
","
);
String
conditionName
,
premises
[],
cpPair
[];
boolean
flag
=
true
;
String
activeList
=
historyInfoPoint
.
get
(
"activeList"
);
for
(
String
option
:
nextOptions
)
{
flag
=
true
;
cpPair
=
option
.
split
(
":"
);
conditionName
=
cpPair
[
0
];
if
(
cpPair
.
length
==
1
)
{
ans
.
setNext
(
"nextStep="
+
conditionName
);
break
;
}
premises
=
cpPair
[
1
].
split
(
"-"
);
for
(
String
premise
:
premises
)
{
if
(
premise
.
equals
(
"known"
))
{
//如果当前/历史信息点中有option这个键,并且这个键的值不为空也不为unknown,那么证明这个option(即相应condition)已经被识别
boolean
conditionExistInCurInfoPoint
=
curInfoPoint
.
containsKey
(
conditionName
)
&&
!
curInfoPoint
.
get
(
conditionName
).
equals
(
""
)
&&
!
curInfoPoint
.
get
(
conditionName
).
equals
(
"unknown"
)
&&
!
curInfoPoint
.
get
(
conditionName
).
equals
(
"do_reset"
);
boolean
conditionExistInHistoryInfoPoint
=
historyInfoPoint
.
containsKey
(
conditionName
)
&&
!
historyInfoPoint
.
get
(
conditionName
).
equals
(
""
)
&&
!
historyInfoPoint
.
get
(
conditionName
).
equals
(
"unknown"
)
&&
!
historyInfoPoint
.
get
(
conditionName
).
equals
(
"do_reset"
);
//只有前两者都为假时,conditionExist才为真
boolean
conditionExist
=
(
conditionExistInCurInfoPoint
||
conditionExistInHistoryInfoPoint
);
if
(
conditionExist
)
flag
=
false
;
}
if
(
premise
.
equals
(
"active"
))
{
boolean
isActive
=
activeList
.
contains
(
conditionName
);
if
(
isActive
)
flag
=
false
;
}
}
if
(
flag
)
{
ans
.
setNext
(
"nextStep="
+
conditionName
);
break
;
}
}
return
ans
;
}
public
void
updateKnowledge
(
Condition
condition
)
throws
ParseException
{
String
keyword
,
variableName
,
updateValue
,
returnStr
=
"1"
;
Iterator
<
String
>
iit
=
condition
.
updateKnowledge
.
keySet
().
iterator
();
while
(
iit
.
hasNext
())
{
variableName
=
iit
.
next
();
updateValue
=
condition
.
updateKnowledge
.
get
(
variableName
);
keyword
=
historyInfoPoint
.
get
(
variableName
);
//如果变量名开头为NPC或者item,就专门交给world处理
if
(
variableName
.
startsWith
(
"npc_"
)
||
variableName
.
startsWith
(
"goods_"
)
||
variableName
.
startsWith
(
"map_"
)){
try
{
returnStr
=
worldController
.
worldOperation
(
gameEnv
,
variableName
,
updateValue
,
curInfoPoint
,
historyInfoPoint
);
updateValue
=
returnStr
;
}
catch
(
Exception
e
){
e
.
printStackTrace
();
updateValue
=
"游戏模块处理出错"
;
}
}
else
{
try
{
//做数字加法
if
(
updateValue
.
startsWith
(
"+"
))
{
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
"0"
;
if
(
keyword
.
matches
(
"\\d{4}年\\d{1,2}月\\d{1,2}日.*"
))
{
long
time
=
MyFunc
.
transferToMillisecond
(
keyword
);
int
offset
=
Integer
.
parseInt
(
updateValue
.
substring
(
1
));
updateValue
=
MyFunc
.
transferToStandardTime
(
time
+
(
1000
*
offset
));
}
else
if
(
StringUtils
.
isNumeric
(
keyword
))
{
int
number
=
Integer
.
parseInt
(
keyword
);
int
offset
=
Integer
.
parseInt
(
updateValue
.
substring
(
1
));
updateValue
=
String
.
valueOf
(
number
+
offset
);
}
//做数字减法
}
else
if
(
updateValue
.
startsWith
(
"-"
))
{
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
"0"
;
if
(
keyword
.
matches
(
"\\d{4}年\\d{1,2}月\\d{1,2}日.*"
))
{
long
time
=
MyFunc
.
transferToMillisecond
(
keyword
);
int
offset
=
Integer
.
parseInt
(
updateValue
.
substring
(
1
));
updateValue
=
MyFunc
.
transferToStandardTime
(
time
-
(
1000
*
offset
));
}
else
if
(
StringUtils
.
isNumeric
(
keyword
))
{
int
number
=
Integer
.
parseInt
(
keyword
);
int
offset
=
Integer
.
parseInt
(
updateValue
.
substring
(
1
));
updateValue
=
String
.
valueOf
(
number
-
offset
);
}
//做字符串累加
}
else
if
(
updateValue
.
startsWith
(
"str+"
))
{
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
""
;
updateValue
=
keyword
+
updateValue
.
substring
(
4
);
//做字符串删除
}
else
if
(
updateValue
.
startsWith
(
"str-"
))
{
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
""
;
updateValue
=
keyword
.
replace
(
updateValue
.
substring
(
4
),
""
);
}
else
if
(
updateValue
.
startsWith
(
"int+="
))
{
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
"0"
;
if
(
keyword
.
matches
(
"\\d{4}年\\d{1,2}月\\d{1,2}日.*"
))
{
long
time
=
MyFunc
.
transferToMillisecond
(
keyword
);
int
offset
=
Integer
.
parseInt
(
updateValue
.
substring
(
1
));
updateValue
=
MyFunc
.
transferToStandardTime
(
time
+
(
1000
*
offset
));
}
else
if
(
StringUtils
.
isNumeric
(
keyword
))
{
int
number
=
Integer
.
parseInt
(
keyword
);
int
offset
=
Integer
.
parseInt
(
updateValue
.
substring
(
5
));
updateValue
=
String
.
valueOf
(
number
+
offset
);
}
//做数字减法
}
else
if
(
updateValue
.
startsWith
(
"int-="
))
{
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
"0"
;
if
(
keyword
.
matches
(
"\\d{4}年\\d{1,2}月\\d{1,2}日.*"
))
{
long
time
=
MyFunc
.
transferToMillisecond
(
keyword
);
int
offset
=
Integer
.
parseInt
(
updateValue
.
substring
(
5
));
updateValue
=
MyFunc
.
transferToStandardTime
(
time
-
(
1000
*
offset
));
}
else
if
(
StringUtils
.
isNumeric
(
keyword
))
{
int
number
=
Integer
.
parseInt
(
keyword
);
int
offset
=
Integer
.
parseInt
(
updateValue
.
substring
(
1
));
updateValue
=
String
.
valueOf
(
number
-
offset
);
}
//做字符串累加
}
else
if
(
updateValue
.
startsWith
(
"str+="
))
{
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
""
;
updateValue
=
keyword
+
updateValue
.
substring
(
5
);
//做字符串删除
}
else
if
(
updateValue
.
startsWith
(
"str-="
))
{
if
(
keyword
==
null
||
keyword
.
equals
(
""
))
keyword
=
""
;
updateValue
=
keyword
.
replace
(
updateValue
.
substring
(
5
),
""
);
}
else
if
(
updateValue
.
startsWith
(
"var="
))
{
String
conditionName
=
updateValue
.
substring
(
5
,
updateValue
.
length
()
-
3
);
if
(
updateValue
.
endsWith
(
"-1}"
))
{
if
(
curInfoPoint
.
get
(
conditionName
)
!=
null
)
{
updateValue
=
curInfoPoint
.
get
(
conditionName
);
}
else
{
updateValue
=
""
;
}
}
else
if
(
updateValue
.
endsWith
(
"-2}"
))
{
if
(
historyInfoPoint
.
get
(
conditionName
)
!=
null
)
{
updateValue
=
historyInfoPoint
.
get
(
conditionName
);
}
else
{
updateValue
=
""
;
}
}
else
if
(
updateValue
.
endsWith
(
"nextStep-3}"
))
{
updateValue
=
condition
.
nextStep
;
}
else
if
(
updateValue
.
endsWith
(
"reply-3}"
))
{
updateValue
=
condition
.
answer
[
0
];
}
if
(
variableName
.
startsWith
(
"process-nextStep"
))
{
condition
.
nextStep
=
updateValue
;
updateValue
=
""
;
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
continue
;
}
}
if
(
updateValue
.
equals
(
""
))
{
curInfoPoint
.
put
(
variableName
+
"_backup"
,
curInfoPoint
.
get
(
variableName
));
//更新答案将某变量设为空时,要将当前信息点也清空,不然后边信息点转移时这个变量的已知信息依然不是空的。
// 为了避免将当前信息点清空后debug信息显示不完整,现创造一个备份,在appendDebugInfo后会将这个备份清空。
curInfoPoint
.
put
(
variableName
,
""
);
}
historyInfoPoint
.
put
(
variableName
,
updateValue
);
}
}
public
void
activateCondition
(
Queue
<
Condition
>
activatedQueue
,
String
botAccount
,
int
basePriority
,
int
baseAuxiliaryPriority
,
String
activateList
,
ServletContext
context
)
throws
IOException
{
UserInfo
userinfo
=
(
UserInfo
)
context
.
getAttribute
(
botAccount
);
String
configStr
=
""
;
Integer
configId
;
Condition
newCondition
,
originCondition
;
for
(
String
configIdStr
:
activateList
.
split
(
","
))
{
if
(!
StringUtils
.
isNumeric
(
configIdStr
))
continue
;
configId
=
Integer
.
parseInt
(
configIdStr
);
configStr
=
userinfo
.
id2config
.
get
(
configId
);
if
(
configStr
!=
null
)
{
originCondition
=
userinfo
.
id2condition
.
get
(
configId
);
newCondition
=
new
Condition
(
originCondition
,
basePriority
,
baseAuxiliaryPriority
);
//condition = QuestionMatcher.buildCondition(condition, configStr);
logWriter
.
record
(
"------激活-------"
+
userinfo
.
id2config
.
get
(
configId
)
+
"-------<br>"
,
0
);
if
(
activatedMap
.
containsKey
(
configId
)
&&
newCondition
.
activePriority
>
activatedMap
.
get
(
configId
).
activePriority
)
{
activatedMap
.
get
(
configId
).
activePriority
=
newCondition
.
activePriority
;
}
else
if
(!
activatedMap
.
containsKey
(
configId
))
{
activatedMap
.
put
(
configId
,
newCondition
);
activatedQueue
.
add
(
newCondition
);
}
}
}
}
/**
* 一个提交表单后在激活的操作
* @param ansCondition
* @param context
* @param userinfo
* @return
* @throws IOException
* @throws ParseException
*/
public
Solution
postActivate
(
Condition
ansCondition
,
ServletContext
context
,
UserInfo
userinfo
)
throws
IOException
,
ParseException
{
Queue
<
Condition
>
activatedQueue
=
new
LinkedList
<
Condition
>();
Solution
bestMatch
=
null
;
activateCondition
(
activatedQueue
,
userinfo
.
botAccount
,
ansCondition
.
priority
,
ansCondition
.
auxiliaryPriority
,
ansCondition
.
nextStep
,
context
);
ansCondition
=
activatedQueueMatching
(
ansCondition
,
activatedQueue
,
context
);
bestMatch
=
getSolution
(
ansCondition
,
context
,
userinfo
);
return
bestMatch
;
}
}
src/main/java/com/qiwu/chatbotbackend/processing/UserInfoController.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
com.qiwu.chatbotbackend.entity.Condition
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
javax.servlet.ServletContext
;
import
java.io.*
;
import
java.sql.SQLException
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
public
class
UserInfoController
{
static
String
CONFIG_DIR
=
System
.
getProperty
(
"user.dir"
)
+
"/config"
;
static
String
FILE_ERROR
=
".txt文件有误"
;
/**
* 根据本地配置文件生成用户信息
*/
public
static
void
configInit
(
ServletContext
context
)
throws
IOException
{
String
line
;
System
.
out
.
println
(
"configDir"
+
CONFIG_DIR
);
File
dir
=
new
File
(
CONFIG_DIR
);
if
(!
dir
.
exists
())
dir
.
mkdir
();
for
(
File
configFile
:
dir
.
listFiles
())
{
FileReader
reader
=
new
FileReader
(
configFile
);
BufferedReader
br
=
new
BufferedReader
(
reader
);
String
fileName
=
configFile
.
getName
();
UserInfo
userinfo
=
new
UserInfo
(
fileName
.
split
(
"\\."
)[
0
]);
try
{
userinfo
=
buildUserInfo
(
br
,
userinfo
,
true
);
context
.
setAttribute
(
userinfo
.
botAccount
,
userinfo
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
userinfo
.
botAccount
+
FILE_ERROR
);
e
.
printStackTrace
();
}
reader
.
close
();
br
.
close
();
}
}
public
static
void
userConfigInit
(
String
botAccount
,
ServletContext
context
)
throws
IOException
{
String
line
;
File
userFile
=
new
File
(
CONFIG_DIR
+
"/"
+
botAccount
+
".txt"
);
System
.
out
.
println
(
userFile
.
getAbsolutePath
());
if
(!
userFile
.
exists
())
{
BufferedReader
br
=
new
BufferedReader
(
new
StringReader
(
""
));
UserInfo
userinfo
=
new
UserInfo
(
botAccount
);
try
{
userinfo
=
buildUserInfo
(
br
,
userinfo
,
true
);
context
.
setAttribute
(
userinfo
.
botAccount
,
userinfo
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
userinfo
.
botAccount
+
FILE_ERROR
);
e
.
printStackTrace
();
}
}
else
{
FileReader
reader
=
new
FileReader
(
userFile
);
BufferedReader
br
=
new
BufferedReader
(
reader
);
UserInfo
userinfo
=
new
UserInfo
(
botAccount
);
try
{
userinfo
=
buildUserInfo
(
br
,
userinfo
,
true
);
context
.
setAttribute
(
userinfo
.
botAccount
,
userinfo
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
userinfo
.
botAccount
+
FILE_ERROR
);
e
.
printStackTrace
();
}
reader
.
close
();
br
.
close
();
}
}
public
static
Condition
buildCondition
(
Condition
condition
,
String
line
)
{
String
feature
,
url
,
element
[],
pair
[],
next
[],
cur_premises
[],
history_premises
[],
premises
[],
features
[],
firstCnditionName
;
try
{
line
=
line
.
split
(
"---"
)[
0
];
element
=
line
.
replace
(
"\n"
,
""
).
split
(
"\\|=\\>\\|"
);
premises
=
element
[
0
].
split
(
"\\|"
);
//System.out.println("element[0]:" + element[0]);
feature
=
premises
[
2
];
cur_premises
=
premises
[
0
].
split
(
","
);
history_premises
=
premises
[
1
].
split
(
","
);
if
(
premises
.
length
<
4
)
condition
.
auxiliaryPriority
=
0
;
else
condition
.
auxiliaryPriority
=
Integer
.
parseInt
(
premises
[
3
].
split
(
"="
)[
1
]);
next
=
element
[
1
].
split
(
"\\|"
);
if
(
next
.
length
<
4
)
return
condition
;
condition
.
answer
=
next
[
0
].
split
(
"~"
);
//condition.nextStep = next[1];
//第二处
condition
.
nextStep
=
next
[
1
].
split
(
"="
,
2
)[
1
];
condition
.
id
=
Integer
.
parseInt
(
next
[
3
].
split
(
"="
)[
1
]);
condition
.
status
=
next
[
2
].
split
(
"="
)[
1
];
//featureMap的构建
features
=
feature
.
split
(
","
);
for
(
String
feat
:
features
)
{
if
(
feat
.
equals
(
""
)
||
feat
.
equals
(
" "
))
{
continue
;
}
else
if
(
feat
.
startsWith
(
"updateKnowledge"
))
{
String
[]
knowledge
=
feat
.
split
(
"-<-"
);
int
length
=
knowledge
.
length
;
condition
.
featureMap
.
put
(
"updateKnowledge"
,
""
);
for
(
int
i
=
1
;
i
<
length
;
i
++)
{
if
(
knowledge
[
i
].
equals
(
""
)
||
knowledge
[
i
].
equals
(
" "
))
continue
;
pair
=
knowledge
[
i
].
split
(
":"
,
2
);
condition
.
updateKnowledge
.
put
(
pair
[
0
],
pair
[
1
]);
}
}
else
if
(
feat
.
startsWith
(
"post"
))
{
pair
=
feat
.
split
(
"\\("
,
2
);
url
=
pair
[
1
];
url
=
url
.
substring
(
0
,
url
.
length
()
-
1
);
pair
=
pair
[
0
].
split
(
"::"
);
condition
.
featureMap
.
put
(
"post"
,
url
+
"|"
+
pair
[
1
]);
}
else
{
condition
.
featureMap
.
put
(
feat
,
""
);
}
}
insertPremise
(
condition
.
currentPremise
,
cur_premises
);
insertPremise
(
condition
.
historyPremise
,
history_premises
);
//满足条件越多,优先级越大
condition
.
priority
=
condition
.
historyPremise
.
size
()
+
condition
.
currentPremise
.
size
();
condition
.
activePriority
=
condition
.
priority
;
/*
for(String premise:cur_premises){
pair = premise.split("=");
condition.indexName.add(pair[0]);
}
*/
firstCnditionName
=
cur_premises
[
0
];
if
(
firstCnditionName
.
equals
(
" "
))
condition
.
indexName
=
"emptySet"
;
else
condition
.
indexName
=
firstCnditionName
.
split
(
"="
)[
0
].
split
(
"::"
)[
0
];
}
catch
(
IndexOutOfBoundsException
e
)
{
e
.
printStackTrace
();
System
.
out
.
println
(
line
);
System
.
out
.
println
(
"文本格式有误"
);
}
return
condition
;
}
/**
* @param br
* @param userinfo
* @param overRide 覆盖之前的状态表
* @return
* @throws IOException
*/
public
static
UserInfo
buildUserInfo
(
BufferedReader
br
,
UserInfo
userinfo
,
boolean
overRide
)
throws
IOException
{
String
line
,
infoName
,
extraElements
[];
HashMap
<
String
,
List
<
Condition
>>
conditionTable
=
null
;
//是否覆盖原有的数据
if
(
overRide
)
{
conditionTable
=
new
HashMap
<
String
,
List
<
Condition
>>();
userinfo
.
id2condition
.
clear
();
userinfo
.
id2config
.
clear
();
userinfo
.
configStr
=
""
;
userinfo
.
varInitialMap
.
clear
();
}
else
{
conditionTable
=
userinfo
.
conditionTable
;
}
List
<
Condition
>
conditionList
=
null
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
try
{
if
(
line
.
trim
().
equals
(
""
))
continue
;
line
=
line
.
replace
(
"\n"
,
""
);
//在用户信息中添加额外信息,如设为active的action
if
(
line
.
contains
(
"extraInfo"
))
{
extraElements
=
line
.
split
(
"\\|"
,
-
1
);
userinfo
.
extraInfo
.
put
(
extraElements
[
1
],
extraElements
[
2
]);
}
else
if
(
line
.
contains
(
"varInitial"
))
{
extraElements
=
line
.
split
(
"\\|"
,
-
1
);
userinfo
.
varInitialMap
.
put
(
extraElements
[
1
],
extraElements
[
2
]);
}
else
{
Condition
condition
=
new
Condition
();
condition
=
buildCondition
(
condition
,
line
);
conditionList
=
conditionTable
.
get
(
condition
.
indexName
);
if
(
conditionList
==
null
)
conditionList
=
new
ArrayList
<
Condition
>();
conditionList
.
add
(
condition
);
conditionTable
.
put
(
condition
.
indexName
,
conditionList
);
if
(
condition
.
id
!=
0
)
{
userinfo
.
id2config
.
put
(
condition
.
id
,
line
);
userinfo
.
id2condition
.
put
(
condition
.
id
,
condition
);
}
}
}
catch
(
ArrayIndexOutOfBoundsException
e
)
{
System
.
out
.
println
(
"数据格式有误"
);
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
userinfo
.
conditionTable
=
conditionTable
;
return
userinfo
;
}
/**
* 通过split方法解析配置文件中的条件部分(如:xihuan=+dota+英雄联盟)
*
* @param premiseMap 前提条件哈希表
*/
public
static
void
insertPremise
(
HashMap
<
String
,
HashSet
<
String
>>
premiseMap
,
String
[]
premisesString
)
{
String
pair
[];
HashSet
<
String
>
keyWordSet
=
null
;
for
(
String
premise
:
premisesString
)
{
// System.out.println(premise);
if
(
premise
.
equals
(
""
)
||
premise
.
equals
(
" "
))
continue
;
pair
=
premise
.
split
(
"="
,
2
);
keyWordSet
=
new
HashSet
<
String
>();
for
(
String
keyword
:
pair
[
1
].
split
(
"\\+"
))
//为了处理条件不满足(为空)时的特殊情况,
if
(
keyword
.
equals
(
"null"
))
keyWordSet
.
add
(
""
);
else
if
(!
keyword
.
equals
(
""
))
keyWordSet
.
add
(
keyword
);
premiseMap
.
put
(
pair
[
0
],
keyWordSet
);
}
}
/**
* 原为通过用户chat_key从数据库中获得用户名
* 根据用户名从servletContext中获得用户的数据userinfo(配置文件及相应的状态表)
* 如果context中没有,就重新加载本地配置文件(即初始化)
* 初始化后还是没有就创建一个userinfo
* -------------
* 修改后直接从request获得用户名,并从context根据用户名获得userinfo
*
* @param bot_name 用户名
* @return 用户信息
*/
public
UserInfo
userInfoQuery
(
String
bot_name
,
ServletContext
context
)
throws
IOException
,
SQLException
{
/*根据数据库得到botAccount改为直接得到
SqlHelper helper = new SqlHelper();
String botAccount = helper.querybotAccountByKey(chat_key);
*/
String
botAccount
=
bot_name
;
UserInfo
userinfo
=
null
;
if
(
context
.
getAttribute
(
botAccount
)
==
null
)
{
userConfigInit
(
botAccount
,
context
);
}
if
(
context
.
getAttribute
(
botAccount
)
==
null
)
{
return
null
;
//userinfo = new UserInfo(botAccount);
//userinfo.conditionTable = new HashMap<String, List<Condition>>();
}
else
{
userinfo
=
(
UserInfo
)
context
.
getAttribute
(
botAccount
);
}
//helper.destroy();
return
userinfo
;
}
}
src/main/java/com/qiwu/chatbotbackend/processing/WorldController.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
com.qiwu.chatbotbackend.GameEnvironment.GameEnv
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
public
class
WorldController
{
public
LogWriter
logWriter
=
null
;
public
WorldController
(
LogWriter
logWriter
)
{
this
.
logWriter
=
logWriter
;
}
public
String
worldOperation
(
GameEnv
gameEnv
,
String
varName
,
String
varValue
,
Map
<
String
,
String
>
currentInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
){
String
moduleName
=
""
,
valuePair
[]
=
varValue
.
split
(
":"
,
2
),
returnStr
=
""
;
String
namePair
[]
=
varName
.
split
(
"_"
);
boolean
operationFlag
=
true
;
List
<
String
>
textList
=
null
;
String
subValuePair
[]
=
null
;
logWriter
.
record
(
String
.
format
(
"---------------------key:%s, value:%s"
,
varName
,
varValue
),
0
);
if
(
valuePair
[
0
].
startsWith
(
"query"
)){
//查询专用
if
(
varName
.
startsWith
(
"goods_"
))
{
switch
(
valuePair
[
0
])
{
case
"queryGoodsIntro"
:
subValuePair
=
currentInfoPoint
.
get
(
valuePair
[
1
]).
split
(
":"
,
2
);
returnStr
=
gameEnv
.
queryGoodsIntroByGoodsName
(
subValuePair
[
1
]);
if
(
returnStr
==
null
)
returnStr
=
"无"
;
break
;
case
"queryAttrByGoodsName"
:
subValuePair
=
currentInfoPoint
.
get
(
valuePair
[
1
]).
split
(
":"
,
2
);
subValuePair
[
0
]
=
subValuePair
[
0
].
replace
(
"哪里"
,
"location"
);
returnStr
=
gameEnv
.
queryGoodsAttrByGoodsName
(
subValuePair
[
0
],
subValuePair
[
1
]);
if
(
returnStr
==
null
)
returnStr
=
"无"
;
break
;
case
"queryAllAttrByGoodsName"
:
textList
=
gameEnv
.
queryGoodsAllAttrByGoodsName
(
varName
);
if
(
textList
==
null
||
textList
.
size
()
==
0
)
returnStr
=
"无"
;
else
{
for
(
String
site
:
textList
)
returnStr
+=
"、"
+
site
;
returnStr
=
returnStr
.
substring
(
1
);
}
break
;
case
"queryAroundGoodsByClassName"
:
textList
=
gameEnv
.
queryGoodsByClassAndSite
(
namePair
[
1
],
historyInfoPoint
.
get
(
"site"
));
if
(
textList
==
null
||
textList
.
size
()
==
0
)
returnStr
=
"无"
;
else
{
for
(
String
site
:
textList
)
returnStr
+=
"、"
+
site
;
returnStr
=
returnStr
.
substring
(
1
);
}
break
;
default
:
}
}
else
if
(
varName
.
startsWith
(
"NPC_"
))
{
switch
(
valuePair
[
0
]){
case
"queryNpcIntro"
:
//operationFlag = gameEnv.queryNpcIntro(valuePair[1], namePair[2]);
subValuePair
=
currentInfoPoint
.
get
(
valuePair
[
1
]).
split
(
":"
,
2
);
returnStr
=
gameEnv
.
queryNpcIntroByNpcName
(
subValuePair
[
1
]);
if
(
returnStr
==
null
)
returnStr
=
"无"
;
break
;
case
"queryAttrByNPCName"
:
subValuePair
=
currentInfoPoint
.
get
(
valuePair
[
1
]).
split
(
":"
,
2
);
subValuePair
[
0
]
=
subValuePair
[
0
].
replace
(
"哪里"
,
"location"
);
returnStr
=
gameEnv
.
queryNpcAttrByNpcName
(
subValuePair
[
0
],
subValuePair
[
1
]);
if
(
returnStr
==
null
)
returnStr
=
"无"
;
break
;
default
:
}
}
else
if
(
varName
.
startsWith
(
"map_"
))
{
List
<
String
>
sites
=
new
ArrayList
<>();
switch
(
valuePair
[
0
])
{
case
"queryAroundAllBySite"
:
sites
=
gameEnv
.
queryAroundAllBySite
(
historyInfoPoint
.
get
(
"site"
));
break
;
case
"queryAroundNpcBySite"
:
sites
=
gameEnv
.
queryAroundNpcBySite
(
historyInfoPoint
.
get
(
"site"
));
break
;
case
"queryAroundGoodsBySite"
:
sites
=
gameEnv
.
queryAroundGoodsBySite
(
historyInfoPoint
.
get
(
"site"
));
break
;
case
"queryCanGoBySite"
:
sites
=
gameEnv
.
queryCanGoBySite
(
historyInfoPoint
.
get
(
"site"
));
break
;
case
"queryPathBySite"
:
sites
=
gameEnv
.
queryPathBySite
(
historyInfoPoint
.
get
(
"site"
),
valuePair
[
1
]);
break
;
}
if
(
sites
==
null
||
sites
.
size
()
==
0
)
returnStr
=
"啥都没有"
;
else
{
returnStr
=
"有"
;
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
}
else
{
returnStr
=
"啥都没有"
;
}
}
}
}
else
{
//增删改统一使用
gameEnv
.
CUD
(
varName
,
valuePair
[
0
],
valuePair
[
1
]);
}
logWriter
.
record
(
"---------------------return:"
+
returnStr
,
0
);
return
returnStr
;
}
}
src/main/java/com/qiwu/chatbotbackend/servlet/GameDesignServlet.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
com.qiwu.chatbotbackend.entity.JConfig
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
com.qiwu.chatbotbackend.gameDesign.*
;
import
com.qiwu.chatbotbackend.processing.MyFunc
;
import
com.qiwu.chatbotbackend.processing.ConditionTableController
;
import
com.qiwu.chatbotbackend.processing.UserInfoController
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.sql.SQLException
;
import
java.util.*
;
import
static
java
.
lang
.
System
.
out
;
@WebServlet
(
name
=
"GameDesignServlet"
,
urlPatterns
=
{
"/gameDesign"
})
public
class
GameDesignServlet
extends
HttpServlet
{
String
POST_URL
=
"http://localhost:1111/conditionProcess"
;
//分组及其相应的id,id初始化为0, 新建分组成功后id会更新。
HashMap
<
String
,
Integer
>
categoryMap
=
new
HashMap
<
String
,
Integer
>(){
{
put
(
"地图"
,
0
);
put
(
"剧情"
,
0
);
put
(
"物品"
,
0
);
put
(
"NPC"
,
0
);
put
(
"全局变量"
,
0
);
}
};
//每个condition的三元组两端需要补充的关键词,比如npc名字、npc属性等
HashMap
<
String
,
HashSet
<
String
>>
relationKeywords
=
new
HashMap
<
String
,
HashSet
<
String
>>();
//特定的relation的三元组不会被添加到relationKeywords
HashSet
<
String
>
exceptRelation
=
new
HashSet
<
String
>();
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
Integer
botId
,
projectId
,
dataId
,
returnStatus
=
1
;
String
botAccount
=
null
,
moduleName
,
userName
,
moduleName2
,
returnMessage
=
"Success"
;
ServletContext
context
=
this
.
getServletContext
();
JSONObject
json
=
null
,
root
=
null
;
Boolean
flag
;
SqlHelper
helper
=
null
;
List
<
Integer
>
idList
=
new
ArrayList
<>();
ElementConstructor
constructor
=
new
ElementConstructor
();
try
{
helper
=
new
SqlHelper
();
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
//读取并解析json数据
String
jsonStr
=
MyFunc
.
readJSONString
(
request
);
if
(
jsonStr
!=
null
&&
!
jsonStr
.
equals
(
""
))
{
JSONObject
receiveParaneters
=
JSONObject
.
parseObject
(
jsonStr
);
dataId
=
(
Integer
)
receiveParaneters
.
get
(
"id"
);
JSONObject
gameElements
=
helper
.
queryGameElementsByBotId
(
dataId
);
out
.
println
(
gameElements
.
toJSONString
());
botId
=
(
Integer
)
gameElements
.
get
(
"botId"
);
botAccount
=
(
String
)
gameElements
.
get
(
"botAccount"
);
userName
=
(
String
)
gameElements
.
get
(
"userName"
);
out
.
println
(
"botId:"
+
botId
+
",botAccount:"
+
botAccount
);
//假设重建用户信息
if
(
context
.
getAttribute
(
botAccount
)
==
null
)
{
UserInfoController
.
userConfigInit
(
botAccount
,
context
);
}
UserInfo
userinfo
=
(
UserInfo
)
context
.
getAttribute
(
botAccount
);
//UserInfo userinfo = new UserInfo(botAccount);
//清空之前生成的配置条目
try
{
flag
=
botInit
(
botId
,
userinfo
,
helper
);
}
catch
(
SQLException
e
)
{
out
.
println
(
"清空旧数据失败"
);
e
.
printStackTrace
();
}
Iterator
<
String
>
moduleIter
=
gameElements
.
keySet
().
iterator
();
StringBuffer
mergedConfigText
=
new
StringBuffer
();
while
(
moduleIter
.
hasNext
())
{
moduleName
=
moduleIter
.
next
();
switch
(
moduleName
)
{
case
"map"
:
moduleName2
=
"地图"
;
constructor
=
new
MapConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
case
"plots"
:
moduleName2
=
"剧情"
;
constructor
=
new
PlotConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
.
construct
(
gameElements
,
userinfo
);
root
=
((
PlotConstructor
)
constructor
).
getId2j
().
get
((
String
)
gameElements
.
get
(
"start"
));
break
;
case
"goods"
:
moduleName2
=
"物品"
;
constructor
=
new
ItemConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
case
"globalVarialbe"
:
moduleName2
=
"全局变量"
;
constructor
=
new
GlobalVariableConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
case
"npc"
:
moduleName2
=
"NPC"
;
constructor
=
new
CharacterConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
default
:
continue
;
}
if
(
constructor
.
getOperationStatus
()
==
1
)
{
out
.
println
(
moduleName
);
//先清空再插入
idList
.
clear
();
helper
.
batchInsertVariableByBotId
(
botId
,
constructor
);
List
<
JSONObject
>
jsonList
=
new
ArrayList
<
JSONObject
>();
for
(
JConfig
jConfig:
constructor
.
getjConfigList
()){
json
=
jConfig
.
toJson
(
constructor
.
getConditionDescription
());
constructor
.
parseKeyword
(
json
,
relationKeywords
,
exceptRelation
);
jsonList
.
add
(
json
);
}
helper
.
batchInsertConfigByBotId
(
botId
,
jsonList
,
idList
,
categoryMap
.
get
(
moduleName2
));
constructor
.
postProcessing
(
idList
,
categoryMap
.
get
(
moduleName2
));
constructor
.
generateConfigText
(
idList
);
mergedConfigText
.
append
(
constructor
.
getConfigText
());
}
else
{
returnStatus
=
0
;
returnMessage
=
constructor
.
getMessage
();
break
;
}
}
if
(
returnStatus
==
1
)
{
StringReader
sr
=
new
StringReader
(
mergedConfigText
.
toString
());
BufferedReader
br
=
new
BufferedReader
(
sr
);
UserInfoController
.
buildUserInfo
(
br
,
userinfo
,
true
);
context
.
setAttribute
(
botAccount
,
userinfo
);
ConditionTableController
.
writeConfigText
(
botAccount
,
userinfo
);
Boolean
postResult
=
actionRegenerate
(
root
,
gameElements
,
userinfo
);
}
helper
.
destroy
();
}
else
{
returnStatus
=
0
;
returnMessage
=
"请求解析失败"
;
}
JSONObject
responseJSONObject
=
new
JSONObject
();
responseJSONObject
.
put
(
"status"
,
returnStatus
);
responseJSONObject
.
put
(
"message"
,
returnMessage
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setContentType
(
"application/json; charset=utf-8"
);
System
.
out
.
println
(
"xx:"
+
responseJSONObject
.
toJSONString
());
try
{
PrintWriter
out
=
response
.
getWriter
();
out
.
append
(
responseJSONObject
.
toString
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
out
!=
null
)
{
out
.
close
();
}
}
}
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
OutputStream
out
=
response
.
getOutputStream
();
out
.
write
(
"ssss"
.
getBytes
());
out
.
flush
();
}
public
boolean
botInit
(
int
botId
,
UserInfo
userInfo
,
SqlHelper
helper
)
throws
SQLException
,
IOException
{
boolean
deleteConfigFlag
=
helper
.
deleteConfigByBotId
(
botId
);
boolean
deleteVariableFlag
=
helper
.
deleteVariableByBotId
(
botId
);
boolean
deleteCategoryFlag
=
helper
.
deleteCategoryByBotId
(
botId
);
boolean
batchInsertCategoryFlag
=
helper
.
batchInsertCategoryByBotId
(
botId
,
categoryMap
);
return
deleteConfigFlag
&&
deleteVariableFlag
;
}
public
boolean
actionRegenerate
(
JSONObject
root
,
JSONObject
gameElements
,
UserInfo
userInfo
){
String
startCondition
;
String
botName
=
(
String
)
gameElements
.
get
(
"botName"
);
JSONObject
returnMessage
=
null
;
JSONObject
actionPostData
=
new
JSONObject
();
out
.
println
(
"root"
+
root
.
toJSONString
());
startCondition
=
(
String
)
root
.
get
(
"conditionName"
);
actionPostData
.
put
(
"startCondition"
,
startCondition
);
actionPostData
.
put
(
"botName_yhm"
,
(
String
)
gameElements
.
get
(
"botName"
));
actionPostData
.
put
(
"botName"
,
botName
);
actionPostData
.
put
(
"botId"
,
(
Integer
)
gameElements
.
get
(
"botId"
));
actionPostData
.
put
(
"type"
,
"game_plot_init"
);
actionPostData
.
put
(
"welcome"
,
(
String
)
gameElements
.
get
(
"plotStartText"
));
actionPostData
.
put
(
"relationKeywords"
,
relationKeywords
);
out
.
println
(
actionPostData
.
toJSONString
());
userInfo
.
extraInfo
.
put
(
"activeAction"
,
startCondition
);
try
{
returnMessage
=
MyFunc
.
postJSON
(
POST_URL
,
actionPostData
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
if
((
Integer
)
returnMessage
.
get
(
"status"
)
==
1
)
{
return
true
;
}
else
{
out
.
println
(
returnMessage
.
get
(
"parameter"
));
out
.
println
(
"剧情初始化失败"
);
return
false
;
}
}
}
src/main/java/com/qiwu/chatbotbackend/servlet/GetAnswerServlet.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
com.qiwu.chatbotbackend.entity.*
;
import
com.qiwu.chatbotbackend.processing.*
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.sql.SQLException
;
import
java.text.ParseException
;
import
java.util.*
;
@WebServlet
(
name
=
"GetAnswerServlet"
,
urlPatterns
=
{
"/test"
,
"/test/"
,
"/dialog"
})
public
class
GetAnswerServlet
extends
HttpServlet
{
/**
* GetAnswerServlet就是处理post请求并返回答案的入口
*/
String
NAME_MISSING_ERROR
=
"没找到bot名?"
;
String
LOG_PATH
=
"/var/www/html/logs/"
;
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
request
.
setCharacterEncoding
(
"UTF-8"
);
Map
<
String
,
String
[]>
receiveParamters
=
new
HashMap
<>(
request
.
getParameterMap
());
Map
<
String
,
String
>
curInfoPoint
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
historyInfoPoint
=
null
;
Solution
bestMatch
=
null
;
Condition
ansCondition
=
null
;
String
ansJ
=
""
,
return_str
=
""
,
state
=
""
;
String
chatKey
=
receiveParamters
.
get
(
"chat_key"
)[
0
];
String
botName
=
receiveParamters
.
get
(
"bot_name"
)[
0
];
OutputStream
out
=
response
.
getOutputStream
();
ServletContext
context
=
this
.
getServletContext
();
boolean
debugFlag
=
false
;
LogWriter
logWriter
=
new
LogWriter
(
LOG_PATH
,
chatKey
);
UserInfo
userinfo
=
null
;
UserInfoController
uiController
=
new
UserInfoController
();
try
{
//userinfo = process.userInfoQuery(chatKey,context);
//从servlet根据用户名查询用户信息
userinfo
=
uiController
.
userInfoQuery
(
request
.
getParameter
(
"bot_name"
),
context
);
}
catch
(
SQLException
e
)
{
state
=
NAME_MISSING_ERROR
;
e
.
printStackTrace
();
}
if
(
userinfo
!=
null
)
{
//获得用户历史信息
ChatCache
chatCache
=
null
;
try
{
chatCache
=
ChatCacheController
.
getChatCache
(
chatKey
,
context
,
userinfo
);
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
historyInfoPoint
=
chatCache
.
getInfoPoint
();
//信息点预处理
QuestionMatcher
matcher
=
new
QuestionMatcher
(
curInfoPoint
,
historyInfoPoint
,
logWriter
,
userinfo
,
context
,
chatCache
.
getGameEnv
());
debugFlag
=
matcher
.
infoPointPreprocessing
(
receiveParamters
,
curInfoPoint
,
historyInfoPoint
,
userinfo
,
context
);
/*得到答案更新历史信息点&生成答案,,清楚超时chatkey_key,生成更新数据库,转成json,输出*/
//process.removeTimeoutChatkey(context);
//System.out.println(userinfo.conditionTable); //测试
ansCondition
=
matcher
.
getBestMatch
(
userinfo
.
conditionTable
,
context
,
userinfo
);
if
(
state
.
equals
(
""
)
&&
ansCondition
.
priority
==
-
1
)
state
=
"我不理解,"
;
if
(
state
.
equals
(
""
))
{
try
{
bestMatch
=
matcher
.
getSolution
(
ansCondition
,
context
,
userinfo
);
if
(
ansCondition
.
featureMap
.
containsKey
(
"activate"
)
&&
ansCondition
.
featureMap
.
containsKey
(
"post"
))
{
//如果当前condition包含激活和提交表单两个操作,那么在所有操作操作完成之后会再激活一次待激活列表,简称后激活阶段
bestMatch
=
matcher
.
postActivate
(
ansCondition
,
context
,
userinfo
);
}
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
//清理超时的用户数据
if
(
context
.
getAttribute
(
"cacheUpdateTime"
)
==
null
)
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
if
(
System
.
currentTimeMillis
()
-
(
long
)
context
.
getAttribute
(
"cacheUpdateTime"
)
>
300000
)
{
ChatCacheController
.
updateChatCache4Delete
(
chatKey
,
context
);
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
}
//bestMatch.setAnswer(" \n" + return_str + "\n " + bestMatch.getAnswer());
}
else
{
bestMatch
=
new
Solution
(
0
,
" \n"
+
return_str
+
"\n "
+
state
,
"nextStep="
+
historyInfoPoint
.
get
(
"currentAction"
));
}
if
(
debugFlag
)
{
matcher
.
appendDebugInfo
(
bestMatch
,
context
);
}
matcher
.
infoTransfer
(
bestMatch
,
context
,
debugFlag
);
ansJ
=
MyFunc
.
toJson
(
bestMatch
);
}
else
{
ansJ
=
"找不到配置文件"
;
}
logWriter
.
writeln
();
logWriter
.
writeln
();
logWriter
.
record
(
"-----------------------------------------对话处理结束"
,
0
);
logWriter
.
writeln
();
logWriter
.
writeln
();
logWriter
.
close
();
System
.
out
.
println
(
ansJ
);
out
.
write
(
ansJ
.
getBytes
());
out
.
flush
();
}
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
System
.
out
.
println
(
"do get method"
);
}
}
src/main/java/com/qiwu/chatbotbackend/servlet/GetConfigServlet.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
@WebServlet
(
name
=
"GetConfigServlet"
,
urlPatterns
=
{
"/getConfig"
})
public
class
GetConfigServlet
extends
HttpServlet
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
request
.
setCharacterEncoding
(
"UTF-8"
);
String
userName
=
request
.
getParameter
(
"userName"
);
String
path
=
"config/"
+
userName
+
".txt"
;
File
file
=
new
File
(
path
);
OutputStream
out
=
response
.
getOutputStream
();
if
(
file
.
exists
())
{
FileReader
fr
=
new
FileReader
(
file
);
BufferedReader
br
=
new
BufferedReader
(
fr
);
String
line
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
line
=
line
+
"\n"
;
out
.
write
(
line
.
getBytes
());
}
fr
.
close
();
br
.
close
();
}
else
{
out
.
write
(
"查无此bot"
.
getBytes
());
}
out
.
flush
();
}
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
doPost
(
request
,
response
);
}
}
src/main/java/com/qiwu/chatbotbackend/servlet/ReloadChatCacheServlet.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
@WebServlet
(
name
=
"ReloadChatCacheServlet"
,
urlPatterns
=
{
"/reloadChatCache"
})
public
class
ReloadChatCacheServlet
extends
HttpServlet
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
}
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
}
}
src/main/java/com/qiwu/chatbotbackend/servlet/ReloadConfigServlet.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
com.qiwu.chatbotbackend.processing.UserInfoController
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
/**
* 发请求从本地文件夹重新加载某用户的配置文件
*/
@WebServlet
(
name
=
"ReloadConfigServlet"
,
urlPatterns
=
{
"/reload"
,
"/reload/"
})
public
class
ReloadConfigServlet
extends
HttpServlet
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
request
.
setCharacterEncoding
(
"UTF-8"
);
String
botAccount
=
request
.
getParameter
(
"botAccount"
);
boolean
flag
=
true
;
UserInfo
userinfo
=
new
UserInfo
(
botAccount
);
File
configFile
=
new
File
(
System
.
getProperty
(
"user.dir"
)
+
"/config/"
+
botAccount
+
".txt"
);
System
.
out
.
println
(
configFile
.
getAbsolutePath
());
ServletContext
context
=
this
.
getServletContext
();
if
(!
configFile
.
exists
())
{
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"text/plain"
);
PrintWriter
out
=
response
.
getWriter
();
out
.
println
(
"文件不存在: "
+
botAccount
);
}
else
{
FileReader
reader
=
new
FileReader
(
configFile
);
BufferedReader
br
=
new
BufferedReader
(
reader
);
try
{
userinfo
=
UserInfoController
.
buildUserInfo
(
br
,
userinfo
,
true
);
context
.
setAttribute
(
userinfo
.
botAccount
,
userinfo
);
}
catch
(
Exception
e
)
{
flag
=
false
;
System
.
out
.
println
(
userinfo
.
botAccount
+
".txt 有误"
);
e
.
printStackTrace
();
}
reader
.
close
();
br
.
close
();
if
(!
flag
)
{
//request.setAttribute("returnMessage","更新失败,以下行有误:</br>" + errorStr +"</br>"+ "<a href=\"update.html\">返回重新输入。</a>");
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"text/plain"
);
response
.
setStatus
(
111
);
PrintWriter
out
=
response
.
getWriter
();
out
.
println
(
"更新失败配置文件有误:"
+
botAccount
+
".txt\\\n"
);
}
else
{
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"text/plain"
);
PrintWriter
out
=
response
.
getWriter
();
out
.
println
(
"重新加载成功"
);
out
.
flush
();
out
.
close
();
//request.setAttribute("returnMessage","更新成功"+userinfo.configStr);
}
}
}
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
}
}
src/main/java/com/qiwu/chatbotbackend/servlet/SaveChatCacheServlet.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
com.qiwu.chatbotbackend.entity.ChatCache
;
import
com.qiwu.chatbotbackend.processing.ChatCacheController
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.util.Map
;
@WebServlet
(
name
=
"SaveChatCacheServlet"
,
urlPatterns
=
{
"/saveChatCache"
})
public
class
SaveChatCacheServlet
extends
HttpServlet
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
}
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
request
.
setCharacterEncoding
(
"UTF-8"
);
String
chatKey
=
request
.
getParameter
(
"chat_key"
),
message
=
""
;
OutputStream
out
=
response
.
getOutputStream
();
ServletContext
context
=
this
.
getServletContext
();
Map
<
String
,
ChatCache
>
chatCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
ChatCache
chatCache
=
chatCacheMap
.
get
(
chatKey
);
//message = ChatCacheController.saveChatCache(chatKey, context);
//out.write(message.getBytes());
out
.
flush
();
}
}
src/main/java/com/qiwu/chatbotbackend/servlet/UpdateServlet.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
com.qiwu.chatbotbackend.entity.Condition
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
com.qiwu.chatbotbackend.processing.MyFunc
;
import
com.qiwu.chatbotbackend.processing.UserInfoController
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
/**
* 用户通过页面更新或提交配置文件,后台解析配置文件信息后保存至本地文件夹中,并更新contextServlet中的userinfo信息。
*/
@WebServlet
(
name
=
"UpdateServlet"
,
urlPatterns
=
{
"/update"
})
public
class
UpdateServlet
extends
HttpServlet
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
//在此处理通过页面提交的配置文件,在servletContext中更新botAccount指定的userinfo,并将配置文件以botAccount.txt的命名方式保存至本地。
request
.
setCharacterEncoding
(
"UTF-8"
);
String
line
,
extraElements
[];
ArrayList
<
String
>
errorList
=
new
ArrayList
<
String
>();
ServletContext
context
=
this
.
getServletContext
();
String
botAccount
=
request
.
getParameter
(
"botAccount"
);
UserInfo
userinfo
=
new
UserInfo
(
botAccount
);
userinfo
.
conditionTable
=
new
HashMap
<
String
,
List
<
Condition
>>();
List
<
Condition
>
conditionList
=
null
;
HashSet
<
String
>
keyWordSet
=
null
;
BufferedReader
br
=
new
BufferedReader
(
new
StringReader
(
request
.
getParameter
(
"config_string"
)));
boolean
flag
=
true
;
String
errorStr
=
""
;
while
((
line
=
br
.
readLine
())
!=
null
)
{
System
.
out
.
println
(
line
);
if
(
line
.
trim
().
equals
(
""
))
continue
;
line
=
line
.
replace
(
"\n"
,
""
);
//在用户信息中添加额外信息,如设为active的action
if
(
line
.
indexOf
(
"-extraInfo-"
)
!=
-
1
)
{
extraElements
=
line
.
split
(
"\\|"
);
userinfo
.
extraInfo
.
put
(
extraElements
[
1
],
extraElements
[
2
]);
userinfo
.
configStr
+=
line
+
"\n"
;
continue
;
}
//line = MyFunc.convert2Utf8(line.trim());
userinfo
.
configStr
+=
line
+
"\n"
;
Condition
condition
=
new
Condition
();
try
{
condition
=
UserInfoController
.
buildCondition
(
condition
,
line
);
conditionList
=
userinfo
.
conditionTable
.
get
(
condition
.
indexName
);
if
(
conditionList
==
null
)
conditionList
=
new
ArrayList
<
Condition
>();
conditionList
.
add
(
condition
);
userinfo
.
conditionTable
.
put
(
condition
.
indexName
,
conditionList
);
/*
for(String name:condition.indexName){
userinfo.conditionTable.put()
}
*/
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"配置文件有误!"
);
flag
=
false
;
errorList
.
add
(
line
);
}
}
br
.
close
();
if
(!
flag
)
{
//request.setAttribute("returnMessage","更新失败,以下行有误:</br>" + errorStr +"</br>"+ "<a href=\"update.html\">返回重新输入。</a>");
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"text/plain"
);
PrintWriter
out
=
response
.
getWriter
();
String
returnStr
=
MyFunc
.
toJson
(
"更新失败,以下行有误:"
+
errorStr
+
"\\\n"
);
out
.
println
(
"更新失败,以下行有误: "
);
for
(
String
error
:
errorList
)
out
.
println
(
"---"
+
error
);
out
.
flush
();
out
.
close
();
System
.
out
.
println
(
"error"
);
}
else
{
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"text/plain"
);
PrintWriter
out
=
response
.
getWriter
();
out
.
println
(
"更新成功+ “ "
);
out
.
flush
();
out
.
close
();
System
.
out
.
println
(
"success"
);
//request.setAttribute("returnMessage","更新成功"+userinfo.configStr);
context
.
setAttribute
(
botAccount
,
userinfo
);
String
path
=
System
.
getProperty
(
"user.dir"
)
+
"/config/"
+
userinfo
.
botAccount
+
".txt"
;
File
file
=
new
File
(
path
);
File
dir
=
new
File
(
System
.
getProperty
(
"user.dir"
)
+
"/config"
);
if
(!
dir
.
exists
())
dir
.
mkdir
();
if
(!
file
.
exists
())
{
file
.
createNewFile
();
}
FileWriter
fw
=
new
FileWriter
(
file
);
BufferedWriter
bw
=
new
BufferedWriter
(
fw
);
bw
.
write
(
userinfo
.
configStr
);
bw
.
close
();
fw
.
close
();
}
}
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
}
}
src/main/java/com/qiwu/chatbotbackend/servlet/UpdateSingleConfigServlet.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
com.qiwu.chatbotbackend.processing.ConditionTableController
;
import
com.qiwu.chatbotbackend.processing.UserInfoController
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
@WebServlet
(
name
=
"UpdateSingleConfigServlet"
,
urlPatterns
=
{
"/update2"
})
public
class
UpdateSingleConfigServlet
extends
HttpServlet
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
request
.
setCharacterEncoding
(
"UTF-8"
);
ServletContext
context
=
this
.
getServletContext
();
String
userName
=
request
.
getParameter
(
"userName"
);
String
processType
=
request
.
getParameter
(
"type"
);
String
configId
=
request
.
getParameter
(
"configId"
);
String
data
=
request
.
getParameter
(
"configData"
);
System
.
out
.
println
(
"userName:"
+
userName
+
" "
+
"type:"
+
processType
+
" "
+
"configId:"
+
"configId:"
+
configId
+
" "
+
"configData:"
+
data
);
if
(
context
.
getAttribute
(
userName
)
!=
null
)
{
switch
(
processType
)
{
case
"insert_config"
:
ConditionTableController
.
insertConfig
(
userName
,
configId
,
data
,
context
);
break
;
case
"update_config"
:
ConditionTableController
.
deleteConfig
(
userName
,
configId
,
data
,
context
);
ConditionTableController
.
insertConfig
(
userName
,
configId
,
data
,
context
);
break
;
case
"delete_config"
:
ConditionTableController
.
deleteConfig
(
userName
,
configId
,
data
,
context
);
break
;
case
"insert_variable"
:
ConditionTableController
.
updateVariable
(
userName
,
configId
,
data
,
context
);
break
;
case
"delete_variable"
:
ConditionTableController
.
deleteVariable
(
userName
,
configId
,
data
,
context
);
break
;
case
"update_variable"
:
ConditionTableController
.
updateVariable
(
userName
,
configId
,
data
,
context
);
break
;
case
"extra_info"
:
ConditionTableController
.
updateExtraInfo
(
userName
,
data
,
context
);
break
;
case
"batch_update"
:
batchUpdate
(
userName
,
data
,
context
);
}
writeConfig
(
userName
,
context
);
response
.
setStatus
(
200
);
}
else
if
(
processType
.
equals
(
"batch_update"
))
{
batchUpdate
(
userName
,
data
,
context
);
writeConfig
(
userName
,
context
);
response
.
setStatus
(
200
);
}
else
{
response
.
setStatus
(
111
);
}
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"text/plain"
);
PrintWriter
out
=
response
.
getWriter
();
out
.
write
(
"success"
);
out
.
flush
();
out
.
close
();
}
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
}
public
String
writeConfig
(
String
userName
,
ServletContext
context
)
throws
IOException
{
String
returnMessage
=
""
;
UserInfo
userinfo
=
(
UserInfo
)
context
.
getAttribute
(
userName
);
returnMessage
=
ConditionTableController
.
writeConfigText
(
userName
,
userinfo
);
return
returnMessage
;
}
public
void
batchUpdate
(
String
userName
,
String
data
,
ServletContext
context
)
throws
IOException
{
BufferedReader
br
=
new
BufferedReader
(
new
StringReader
(
data
));
UserInfo
userinfo
=
new
UserInfo
(
userName
);
userinfo
=
UserInfoController
.
buildUserInfo
(
br
,
userinfo
,
true
);
context
.
setAttribute
(
userinfo
.
botAccount
,
userinfo
);
System
.
out
.
println
(
"batchupdate"
);
}
}
src/main/resources/application.properties
deleted
100644 → 0
View file @
f8d00711
server.port
=
8081
server.servlet.context-path
=
/bot
endpoints.shutdown.enabled
=
true
\ No newline at end of file
src/main/resources/dev/c3p0-config.xml
deleted
100644 → 0
View file @
f8d00711
<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<!--默认配置-->
<default-config>
<property
name=
"initialPoolSize"
>
10
</property>
<property
name=
"maxIdleTime"
>
30
</property>
<property
name=
"maxPoolSize"
>
50
</property>
<property
name=
"minPoolSize"
>
10
</property>
<property
name=
"maxStatements"
>
200
</property>
</default-config>
<!--配置连接池mysql-->
<named-config
name=
"mysql"
>
<property
name=
"driverClass"
>
com.mysql.jdbc.Driver
</property>
<property
name=
"jdbcUrl"
>
jdbc:mysql://192.168.1.81:3306/SimplifiedBot?useUnicode=true
&
characterEncoding=UTF8
</property>
<property
name=
"user"
>
root
</property>
<property
name=
"password"
>
admin
</property>
<property
name=
"initialPoolSize"
>
10
</property>
<property
name=
"maxIdleTime"
>
30
</property>
<property
name=
"maxPoolSize"
>
50
</property>
<property
name=
"minPoolSize"
>
10
</property>
<property
name=
"maxStatements"
>
200
</property>
</named-config>
<!--配置连接池2-->
......
<!--配置连接池3-->
......
<!--配置连接池4-->
......
</c3p0-config>
\ No newline at end of file
src/main/resources/dev/log4j.properties
deleted
100644 → 0
View file @
f8d00711
### 设置###
log4j.rootLogger
=
debug,stdout,D,E
### 输出信息到控制抬 ###
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.Threshold
=
INFO
log4j.appender.stdout.layout.ConversionPattern
=
[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
### 输出DEBUG 级别以上的日志文件设置 ###
log4j.appender.D
=
org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File
=
vincent_player_debug.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
### 输出ERROR 级别以上的日志文件设置 ###
log4j.appender.E
=
org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File
=
vincent_player_error.log
log4j.appender.E.Append
=
true
log4j.appender.E.Threshold
=
ERROR
log4j.appender.E.layout
=
org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern
=
%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
\ No newline at end of file
src/main/resources/pro/c3p0-config.xml
deleted
100644 → 0
View file @
f8d00711
<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
<!--默认配置-->
<default-config>
<property
name=
"initialPoolSize"
>
10
</property>
<property
name=
"maxIdleTime"
>
30
</property>
<property
name=
"maxPoolSize"
>
50
</property>
<property
name=
"minPoolSize"
>
10
</property>
<property
name=
"maxStatements"
>
200
</property>
</default-config>
<!--配置连接池mysql-->
<named-config
name=
"mysql"
>
<property
name=
"driverClass"
>
com.mysql.jdbc.Driver
</property>
<property
name=
"jdbcUrl"
>
jdbc:mysql://localhost:3306/SimplifiedBot?useUnicode=true
&
characterEncoding=UTF8
</property>
<property
name=
"user"
>
root
</property>
<property
name=
"password"
>
3g9^pWQs#ft7
</property>
<property
name=
"initialPoolSize"
>
10
</property>
<property
name=
"maxIdleTime"
>
30
</property>
<property
name=
"maxPoolSize"
>
50
</property>
<property
name=
"minPoolSize"
>
10
</property>
<property
name=
"maxStatements"
>
200
</property>
</named-config>
<!--配置连接池2-->
......
<!--配置连接池3-->
......
<!--配置连接池4-->
......
</c3p0-config>
\ No newline at end of file
src/main/resources/pro/log4j.properties
deleted
100644 → 0
View file @
f8d00711
### 设置###
log4j.rootLogger
=
debug,stdout,D,E
### 输出信息到控制抬 ###
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.Threshold
=
INFO
log4j.appender.stdout.layout.ConversionPattern
=
[%-5p] %d{yyyy-MM-dd HH:mm:ss,SSS} method:%l%n%m%n
### 输出DEBUG 级别以上的日志文件设置 ###
log4j.appender.D
=
org.apache.log4j.DailyRollingFileAppender
log4j.appender.D.File
=
vincent_player_debug.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
### 输出ERROR 级别以上的日志文件设置 ###
log4j.appender.E
=
org.apache.log4j.DailyRollingFileAppender
log4j.appender.E.File
=
vincent_player_error.log
log4j.appender.E.Append
=
true
log4j.appender.E.Threshold
=
ERROR
log4j.appender.E.layout
=
org.apache.log4j.PatternLayout
log4j.appender.E.layout.ConversionPattern
=
%-d{yyyy-MM-dd HH:mm:ss} [ %t:%r ] - [ %p ] %m%n
\ No newline at end of file
src/main/resources/static/js/jquery-3.3.1.min.js
deleted
100644 → 0
View file @
f8d00711
/*! jQuery v3.3.1 | (c) JS Foundation and other contributors | jquery.org/license */
!
function
(
e
,
t
){
"use strict"
;
"object"
==
typeof
module
&&
"object"
==
typeof
module
.
exports
?
module
.
exports
=
e
.
document
?
t
(
e
,
!
0
):
function
(
e
){
if
(
!
e
.
document
)
throw
new
Error
(
"jQuery requires a window with a document"
);
return
t
(
e
)}:
t
(
e
)}(
"undefined"
!=
typeof
window
?
window
:
this
,
function
(
e
,
t
){
"use strict"
;
var
n
=
[],
r
=
e
.
document
,
i
=
Object
.
getPrototypeOf
,
o
=
n
.
slice
,
a
=
n
.
concat
,
s
=
n
.
push
,
u
=
n
.
indexOf
,
l
=
{},
c
=
l
.
toString
,
f
=
l
.
hasOwnProperty
,
p
=
f
.
toString
,
d
=
p
.
call
(
Object
),
h
=
{},
g
=
function
e
(
t
){
return
"function"
==
typeof
t
&&
"number"
!=
typeof
t
.
nodeType
},
y
=
function
e
(
t
){
return
null
!=
t
&&
t
===
t
.
window
},
v
=
{
type
:
!
0
,
src
:
!
0
,
noModule
:
!
0
};
function
m
(
e
,
t
,
n
){
var
i
,
o
=
(
t
=
t
||
r
).
createElement
(
"script"
);
if
(
o
.
text
=
e
,
n
)
for
(
i
in
v
)
n
[
i
]
&&
(
o
[
i
]
=
n
[
i
]);
t
.
head
.
appendChild
(
o
).
parentNode
.
removeChild
(
o
)}
function
x
(
e
){
return
null
==
e
?
e
+
""
:
"object"
==
typeof
e
||
"function"
==
typeof
e
?
l
[
c
.
call
(
e
)]
||
"object"
:
typeof
e
}
var
b
=
"3.3.1"
,
w
=
function
(
e
,
t
){
return
new
w
.
fn
.
init
(
e
,
t
)},
T
=
/^
[\s\u
FEFF
\x
A0
]
+|
[\s\u
FEFF
\x
A0
]
+$/g
;
w
.
fn
=
w
.
prototype
=
{
jquery
:
"3.3.1"
,
constructor
:
w
,
length
:
0
,
toArray
:
function
(){
return
o
.
call
(
this
)},
get
:
function
(
e
){
return
null
==
e
?
o
.
call
(
this
):
e
<
0
?
this
[
e
+
this
.
length
]:
this
[
e
]},
pushStack
:
function
(
e
){
var
t
=
w
.
merge
(
this
.
constructor
(),
e
);
return
t
.
prevObject
=
this
,
t
},
each
:
function
(
e
){
return
w
.
each
(
this
,
e
)},
map
:
function
(
e
){
return
this
.
pushStack
(
w
.
map
(
this
,
function
(
t
,
n
){
return
e
.
call
(
t
,
n
,
t
)}))},
slice
:
function
(){
return
this
.
pushStack
(
o
.
apply
(
this
,
arguments
))},
first
:
function
(){
return
this
.
eq
(
0
)},
last
:
function
(){
return
this
.
eq
(
-
1
)},
eq
:
function
(
e
){
var
t
=
this
.
length
,
n
=+
e
+
(
e
<
0
?
t
:
0
);
return
this
.
pushStack
(
n
>=
0
&&
n
<
t
?[
this
[
n
]]:[])},
end
:
function
(){
return
this
.
prevObject
||
this
.
constructor
()},
push
:
s
,
sort
:
n
.
sort
,
splice
:
n
.
splice
},
w
.
extend
=
w
.
fn
.
extend
=
function
(){
var
e
,
t
,
n
,
r
,
i
,
o
,
a
=
arguments
[
0
]
||
{},
s
=
1
,
u
=
arguments
.
length
,
l
=!
1
;
for
(
"boolean"
==
typeof
a
&&
(
l
=
a
,
a
=
arguments
[
s
]
||
{},
s
++
),
"object"
==
typeof
a
||
g
(
a
)
||
(
a
=
{}),
s
===
u
&&
(
a
=
this
,
s
--
);
s
<
u
;
s
++
)
if
(
null
!=
(
e
=
arguments
[
s
]))
for
(
t
in
e
)
n
=
a
[
t
],
a
!==
(
r
=
e
[
t
])
&&
(
l
&&
r
&&
(
w
.
isPlainObject
(
r
)
||
(
i
=
Array
.
isArray
(
r
)))?(
i
?(
i
=!
1
,
o
=
n
&&
Array
.
isArray
(
n
)?
n
:[]):
o
=
n
&&
w
.
isPlainObject
(
n
)?
n
:{},
a
[
t
]
=
w
.
extend
(
l
,
o
,
r
)):
void
0
!==
r
&&
(
a
[
t
]
=
r
));
return
a
},
w
.
extend
({
expando
:
"jQuery"
+
(
"3.3.1"
+
Math
.
random
()).
replace
(
/
\D
/g
,
""
),
isReady
:
!
0
,
error
:
function
(
e
){
throw
new
Error
(
e
)},
noop
:
function
(){},
isPlainObject
:
function
(
e
){
var
t
,
n
;
return
!
(
!
e
||
"[object Object]"
!==
c
.
call
(
e
))
&&
(
!
(
t
=
i
(
e
))
||
"function"
==
typeof
(
n
=
f
.
call
(
t
,
"constructor"
)
&&
t
.
constructor
)
&&
p
.
call
(
n
)
===
d
)},
isEmptyObject
:
function
(
e
){
var
t
;
for
(
t
in
e
)
return
!
1
;
return
!
0
},
globalEval
:
function
(
e
){
m
(
e
)},
each
:
function
(
e
,
t
){
var
n
,
r
=
0
;
if
(
C
(
e
)){
for
(
n
=
e
.
length
;
r
<
n
;
r
++
)
if
(
!
1
===
t
.
call
(
e
[
r
],
r
,
e
[
r
]))
break
}
else
for
(
r
in
e
)
if
(
!
1
===
t
.
call
(
e
[
r
],
r
,
e
[
r
]))
break
;
return
e
},
trim
:
function
(
e
){
return
null
==
e
?
""
:(
e
+
""
).
replace
(
T
,
""
)},
makeArray
:
function
(
e
,
t
){
var
n
=
t
||
[];
return
null
!=
e
&&
(
C
(
Object
(
e
))?
w
.
merge
(
n
,
"string"
==
typeof
e
?[
e
]:
e
):
s
.
call
(
n
,
e
)),
n
},
inArray
:
function
(
e
,
t
,
n
){
return
null
==
t
?
-
1
:
u
.
call
(
t
,
e
,
n
)},
merge
:
function
(
e
,
t
){
for
(
var
n
=+
t
.
length
,
r
=
0
,
i
=
e
.
length
;
r
<
n
;
r
++
)
e
[
i
++
]
=
t
[
r
];
return
e
.
length
=
i
,
e
},
grep
:
function
(
e
,
t
,
n
){
for
(
var
r
,
i
=
[],
o
=
0
,
a
=
e
.
length
,
s
=!
n
;
o
<
a
;
o
++
)(
r
=!
t
(
e
[
o
],
o
))
!==
s
&&
i
.
push
(
e
[
o
]);
return
i
},
map
:
function
(
e
,
t
,
n
){
var
r
,
i
,
o
=
0
,
s
=
[];
if
(
C
(
e
))
for
(
r
=
e
.
length
;
o
<
r
;
o
++
)
null
!=
(
i
=
t
(
e
[
o
],
o
,
n
))
&&
s
.
push
(
i
);
else
for
(
o
in
e
)
null
!=
(
i
=
t
(
e
[
o
],
o
,
n
))
&&
s
.
push
(
i
);
return
a
.
apply
([],
s
)},
guid
:
1
,
support
:
h
}),
"function"
==
typeof
Symbol
&&
(
w
.
fn
[
Symbol
.
iterator
]
=
n
[
Symbol
.
iterator
]),
w
.
each
(
"Boolean Number String Function Array Date RegExp Object Error Symbol"
.
split
(
" "
),
function
(
e
,
t
){
l
[
"[object "
+
t
+
"]"
]
=
t
.
toLowerCase
()});
function
C
(
e
){
var
t
=!!
e
&&
"length"
in
e
&&
e
.
length
,
n
=
x
(
e
);
return
!
g
(
e
)
&&!
y
(
e
)
&&
(
"array"
===
n
||
0
===
t
||
"number"
==
typeof
t
&&
t
>
0
&&
t
-
1
in
e
)}
var
E
=
function
(
e
){
var
t
,
n
,
r
,
i
,
o
,
a
,
s
,
u
,
l
,
c
,
f
,
p
,
d
,
h
,
g
,
y
,
v
,
m
,
x
,
b
=
"sizzle"
+
1
*
new
Date
,
w
=
e
.
document
,
T
=
0
,
C
=
0
,
E
=
ae
(),
k
=
ae
(),
S
=
ae
(),
D
=
function
(
e
,
t
){
return
e
===
t
&&
(
f
=!
0
),
0
},
N
=
{}.
hasOwnProperty
,
A
=
[],
j
=
A
.
pop
,
q
=
A
.
push
,
L
=
A
.
push
,
H
=
A
.
slice
,
O
=
function
(
e
,
t
){
for
(
var
n
=
0
,
r
=
e
.
length
;
n
<
r
;
n
++
)
if
(
e
[
n
]
===
t
)
return
n
;
return
-
1
},
P
=
"checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped"
,
M
=
"[
\\
x20
\\
t
\\
r
\\
n
\\
f]"
,
R
=
"(?:
\\\\
.|[
\\
w-]|[^
\
0-
\\
xa0])+"
,
I
=
"
\\
["
+
M
+
"*("
+
R
+
")(?:"
+
M
+
"*([*^$|!~]?=)"
+
M
+
"*(?:'((?:
\\\\
.|[^
\\\\
'])*)'|
\"
((?:
\\\\
.|[^
\\\\
\"
])*)
\"
|("
+
R
+
"))|)"
+
M
+
"*
\\
]"
,
W
=
":("
+
R
+
")(?:
\\
((('((?:
\\\\
.|[^
\\\\
'])*)'|
\"
((?:
\\\\
.|[^
\\\\
\"
])*)
\"
)|((?:
\\\\
.|[^
\\\\
()[
\\
]]|"
+
I
+
")*)|.*)
\\
)|)"
,
$
=
new
RegExp
(
M
+
"+"
,
"g"
),
B
=
new
RegExp
(
"^"
+
M
+
"+|((?:^|[^
\\\\
])(?:
\\\\
.)*)"
+
M
+
"+$"
,
"g"
),
F
=
new
RegExp
(
"^"
+
M
+
"*,"
+
M
+
"*"
),
_
=
new
RegExp
(
"^"
+
M
+
"*([>+~]|"
+
M
+
")"
+
M
+
"*"
),
z
=
new
RegExp
(
"="
+
M
+
"*([^
\\
]'
\"
]*?)"
+
M
+
"*
\\
]"
,
"g"
),
X
=
new
RegExp
(
W
),
U
=
new
RegExp
(
"^"
+
R
+
"$"
),
V
=
{
ID
:
new
RegExp
(
"^#("
+
R
+
")"
),
CLASS
:
new
RegExp
(
"^
\\
.("
+
R
+
")"
),
TAG
:
new
RegExp
(
"^("
+
R
+
"|[*])"
),
ATTR
:
new
RegExp
(
"^"
+
I
),
PSEUDO
:
new
RegExp
(
"^"
+
W
),
CHILD
:
new
RegExp
(
"^:(only|first|last|nth|nth-last)-(child|of-type)(?:
\\
("
+
M
+
"*(even|odd|(([+-]|)(
\\
d*)n|)"
+
M
+
"*(?:([+-]|)"
+
M
+
"*(
\\
d+)|))"
+
M
+
"*
\\
)|)"
,
"i"
),
bool
:
new
RegExp
(
"^(?:"
+
P
+
")$"
,
"i"
),
needsContext
:
new
RegExp
(
"^"
+
M
+
"*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:
\\
("
+
M
+
"*((?:-
\\
d)?
\\
d*)"
+
M
+
"*
\\
)|)(?=[^-]|$)"
,
"i"
)},
G
=
/^
(?:
input|select|textarea|button
)
$/i
,
Y
=
/^h
\d
$/i
,
Q
=
/^
[^
{
]
+
\{\s
*
\[
native
\w
/
,
J
=
/^
(?:
#
([\w
-
]
+
)
|
(\w
+
)
|
\.([\w
-
]
+
))
$/
,
K
=
/
[
+~
]
/
,
Z
=
new
RegExp
(
"
\\\\
([
\\
da-f]{1,6}"
+
M
+
"?|("
+
M
+
")|.)"
,
"ig"
),
ee
=
function
(
e
,
t
,
n
){
var
r
=
"0x"
+
t
-
65536
;
return
r
!==
r
||
n
?
t
:
r
<
0
?
String
.
fromCharCode
(
r
+
65536
):
String
.
fromCharCode
(
r
>>
10
|
55296
,
1023
&
r
|
56320
)},
te
=
/
([\0
-
\x
1f
\x
7f
]
|^-
?\d)
|^-$|
[^\0
-
\x
1f
\x
7f-
\u
FFFF
\w
-
]
/g
,
ne
=
function
(
e
,
t
){
return
t
?
"
\
0"
===
e
?
"
\
ufffd"
:
e
.
slice
(
0
,
-
1
)
+
"
\
\"
+e.charCodeAt(e.length-1).toString(16)+"
":"
\\
"+e},re=function(){p()},ie=me(function(e){return!0===e.disabled&&("
form
"in e||"
label
"in e)},{dir:"
parentNode
",next:"
legend
"});try{L.apply(A=H.call(w.childNodes),w.childNodes),A[w.childNodes.length].nodeType}catch(e){L={apply:A.length?function(e,t){q.apply(e,H.call(t))}:function(e,t){var n=e.length,r=0;while(e[n++]=t[r++]);e.length=n-1}}}function oe(e,t,r,i){var o,s,l,c,f,h,v,m=t&&t.ownerDocument,T=t?t.nodeType:9;if(r=r||[],"
string
"!=typeof e||!e||1!==T&&9!==T&&11!==T)return r;if(!i&&((t?t.ownerDocument||t:w)!==d&&p(t),t=t||d,g)){if(11!==T&&(f=J.exec(e)))if(o=f[1]){if(9===T){if(!(l=t.getElementById(o)))return r;if(l.id===o)return r.push(l),r}else if(m&&(l=m.getElementById(o))&&x(t,l)&&l.id===o)return r.push(l),r}else{if(f[2])return L.apply(r,t.getElementsByTagName(e)),r;if((o=f[3])&&n.getElementsByClassName&&t.getElementsByClassName)return L.apply(r,t.getElementsByClassName(o)),r}if(n.qsa&&!S[e+"
"]&&(!y||!y.test(e))){if(1!==T)m=t,v=e;else if("
object
"!==t.nodeName.toLowerCase()){(c=t.getAttribute("
id
"))?c=c.replace(te,ne):t.setAttribute("
id
",c=b),s=(h=a(e)).length;while(s--)h[s]="
#
"+c+"
"+ve(h[s]);v=h.join("
,
"),m=K.test(e)&&ge(t.parentNode)||t}if(v)try{return L.apply(r,m.querySelectorAll(v)),r}catch(e){}finally{c===b&&t.removeAttribute("
id
")}}}return u(e.replace(B,"
$1
"),t,r,i)}function ae(){var e=[];function t(n,i){return e.push(n+"
")>r.cacheLength&&delete t[e.shift()],t[n+"
"]=i}return t}function se(e){return e[b]=!0,e}function ue(e){var t=d.createElement("
fieldset
");try{return!!e(t)}catch(e){return!1}finally{t.parentNode&&t.parentNode.removeChild(t),t=null}}function le(e,t){var n=e.split("
|
"),i=n.length;while(i--)r.attrHandle[n[i]]=t}function ce(e,t){var n=t&&e,r=n&&1===e.nodeType&&1===t.nodeType&&e.sourceIndex-t.sourceIndex;if(r)return r;if(n)while(n=n.nextSibling)if(n===t)return-1;return e?1:-1}function fe(e){return function(t){return"
input
"===t.nodeName.toLowerCase()&&t.type===e}}function pe(e){return function(t){var n=t.nodeName.toLowerCase();return("
input
"===n||"
button
"===n)&&t.type===e}}function de(e){return function(t){return"
form
"in t?t.parentNode&&!1===t.disabled?"
label
"in t?"
label
"in t.parentNode?t.parentNode.disabled===e:t.disabled===e:t.isDisabled===e||t.isDisabled!==!e&&ie(t)===e:t.disabled===e:"
label
"in t&&t.disabled===e}}function he(e){return se(function(t){return t=+t,se(function(n,r){var i,o=e([],n.length,t),a=o.length;while(a--)n[i=o[a]]&&(n[i]=!(r[i]=n[i]))})})}function ge(e){return e&&"
undefined
"!=typeof e.getElementsByTagName&&e}n=oe.support={},o=oe.isXML=function(e){var t=e&&(e.ownerDocument||e).documentElement;return!!t&&"
HTML
"!==t.nodeName},p=oe.setDocument=function(e){var t,i,a=e?e.ownerDocument||e:w;return a!==d&&9===a.nodeType&&a.documentElement?(d=a,h=d.documentElement,g=!o(d),w!==d&&(i=d.defaultView)&&i.top!==i&&(i.addEventListener?i.addEventListener("
unload
",re,!1):i.attachEvent&&i.attachEvent("
onunload
",re)),n.attributes=ue(function(e){return e.className="
i
",!e.getAttribute("
className
")}),n.getElementsByTagName=ue(function(e){return e.appendChild(d.createComment("")),!e.getElementsByTagName("
*
").length}),n.getElementsByClassName=Q.test(d.getElementsByClassName),n.getById=ue(function(e){return h.appendChild(e).id=b,!d.getElementsByName||!d.getElementsByName(b).length}),n.getById?(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){return e.getAttribute("
id
")===t}},r.find.ID=function(e,t){if("
undefined
"!=typeof t.getElementById&&g){var n=t.getElementById(e);return n?[n]:[]}}):(r.filter.ID=function(e){var t=e.replace(Z,ee);return function(e){var n="
undefined
"!=typeof e.getAttributeNode&&e.getAttributeNode("
id
");return n&&n.value===t}},r.find.ID=function(e,t){if("
undefined
"!=typeof t.getElementById&&g){var n,r,i,o=t.getElementById(e);if(o){if((n=o.getAttributeNode("
id
"))&&n.value===e)return[o];i=t.getElementsByName(e),r=0;while(o=i[r++])if((n=o.getAttributeNode("
id
"))&&n.value===e)return[o]}return[]}}),r.find.TAG=n.getElementsByTagName?function(e,t){return"
undefined
"!=typeof t.getElementsByTagName?t.getElementsByTagName(e):n.qsa?t.querySelectorAll(e):void 0}:function(e,t){var n,r=[],i=0,o=t.getElementsByTagName(e);if("
*
"===e){while(n=o[i++])1===n.nodeType&&r.push(n);return r}return o},r.find.CLASS=n.getElementsByClassName&&function(e,t){if("
undefined
"!=typeof t.getElementsByClassName&&g)return t.getElementsByClassName(e)},v=[],y=[],(n.qsa=Q.test(d.querySelectorAll))&&(ue(function(e){h.appendChild(e).innerHTML="
<
a
id
=
'"+b+"'
><
/a><select id='"+b+"-
\r\\
' msallowcapture=''><option selected=''></
option
><
/select>",e.querySelectorAll
(
"
[
msallowcapture^=''
]
"
)
.length&&y.push
(
"
[
*^$
]
="+M+"*
(?:
''|
\"\")
"
)
,e.querySelectorAll
(
"
[
selected
]
"
)
.length||y.push
(
"
\\[
"+M+"*(?:value|"+P+")"),e.querySelectorAll("[id~="+b+"-
]
"
)
.length||y.push
(
"~="
)
,e.querySelectorAll
(
":checked"
)
.length||y.push
(
":checked"
)
,e.querySelectorAll
(
"a#"+b+"+*"
)
.length||y.push
(
".#.+
[
+~
]
"
)
}
)
,ue
(
function
(
e
)
{e.innerHTML="<a href='' disabled='disabled'></
a
><
select
disabled
=
'disabled'
><
option
/><
/select>";var t=d.createElement
(
"input"
)
;t.setAttribute
(
"type","hidden"
)
,e.appendChild
(
t
)
.setAttribute
(
"name","D"
)
,e.querySelectorAll
(
"
[
name=d
]
"
)
.length&&y.push
(
"name"+M+"*
[
*^$|!~
]?
="
)
,2!==e.querySelectorAll
(
":enabled"
)
.length&&y.push
(
":enabled",":disabled"
)
,h.appendChild
(
e
)
.disabled=!0,2!==e.querySelectorAll
(
":disabled"
)
.length&&y.push
(
":enabled",":disabled"
)
,e.querySelectorAll
(
"*,:x"
)
,y.push
(
",.*:"
)
}
))
,
(
n.matchesSelector=Q.test
(
m=h.matches||h.webkitMatchesSelector||h.mozMatchesSelector||h.oMatchesSelector||h.msMatchesSelector
))
&&ue
(
function
(
e
)
{n.disconnectedMatch=m.call
(
e,"*"
)
,m.call
(
e,"
[
s!=''
]
:x"
)
,v.push
(
"!=",W
)
}
)
,y=y.length&&new RegExp
(
y.join
(
"|"
))
,v=v.length&&new RegExp
(
v.join
(
"|"
))
,t=Q.test
(
h.compareDocumentPosition
)
,x=t||Q.test
(
h.contains
)?
function
(
e,t
)
{var n=9===e.nodeType
?
e.documentElement:e,r=t&&t.parentNode;return e===r||!
(
!r||1!==r.nodeType||!
(
n.contains
?
n.contains
(
r
)
:e.compareDocumentPosition&&16&e.compareDocumentPosition
(
r
)))
}:function
(
e,t
)
{if
(
t
)
while
(
t=t.parentNode
)
if
(
t===e
)
return!0;return!1},D=t
?
function
(
e,t
)
{if
(
e===t
)
return f=!0,0;var r=!e.compareDocumentPosition-!t.compareDocumentPosition;return r||
(
1&
(
r=
(
e.ownerDocument||e
)
===
(
t.ownerDocument||t
)?
e.compareDocumentPosition
(
t
)
:1
)
||!n.sortDetached&&t.compareDocumentPosition
(
e
)
===r
?
e===d||e.ownerDocument===w&&x
(
w,e
)?
-1:t===d||t.ownerDocument===w&&x
(
w,t
)?
1:c
?
O
(
c,e
)
-O
(
c,t
)
:0:4&r
?
-1:1
)
}:function
(
e,t
)
{if
(
e===t
)
return f=!0,0;var n,r=0,i=e.parentNode,o=t.parentNode,a=
[
e
]
,s=
[
t
]
;if
(
!i||!o
)
return e===d
?
-1:t===d
?
1:i
?
-1:o
?
1:c
?
O
(
c,e
)
-O
(
c,t
)
:0;if
(
i===o
)
return ce
(
e,t
)
;n=e;while
(
n=n.parentNode
)
a.unshift
(
n
)
;n=t;while
(
n=n.parentNode
)
s.unshift
(
n
)
;while
(
a
[
r
]
===s
[
r
])
r++;return r
?
ce
(
a
[
r
]
,s
[
r
])
:a
[
r
]
===w
?
-1:s
[
r
]
===w
?
1:0},d
)
:d},oe.matches=function
(
e,t
)
{return oe
(
e,null,null,t
)
},oe.matchesSelector=function
(
e,t
)
{if
((
e.ownerDocument||e
)
!==d&&p
(
e
)
,t=t.replace
(
z,"='$1']"
)
,n.matchesSelector&&g&&!S
[
t+" "
]
&&
(
!v||!v.test
(
t
))
&&
(
!y||!y.test
(
t
)))
try{var r=m.call
(
e,t
)
;if
(
r||n.disconnectedMatch||e.document&&11!==e.document.nodeType
)
return r}catch
(
e
)
{}return oe
(
t,d,null,
[
e
])
.length>0},oe.contains=function
(
e,t
)
{return
(
e.ownerDocument||e
)
!==d&&p
(
e
)
,x
(
e,t
)
},oe.attr=function
(
e,t
)
{
(
e.ownerDocument||e
)
!==d&&p
(
e
)
;var i=r.attrHandle
[
t.toLowerCase()
]
,o=i&&N.call
(
r.attrHandle,t.toLowerCase
())?
i
(
e,t,!g
)
:void 0;return void 0!==o
?
o:n.attributes||!g
?
e.getAttribute
(
t
)
:
(
o=e.getAttributeNode
(
t
))
&&o.specified
?
o.value:null},oe.escape=function
(
e
)
{return
(
e+""
)
.replace
(
te,ne
)
},oe.error=function
(
e
)
{throw new Error
(
"Syntax error, unrecognized expression: "+e
)
},oe.uniqueSort=function
(
e
)
{var t,r=
[]
,i=0,o=0;if
(
f=!n.detectDuplicates,c=!n.sortStable&&e.slice
(
0
)
,e.sort
(
D
)
,f
)
{while
(
t=e
[
o++
])
t===e
[
o
]
&&
(
i=r.push
(
o
))
;while
(
i--
)
e.splice
(
r
[
i
]
,1
)
}return c=null,e},i=oe.getText=function
(
e
)
{var t,n="",r=0,o=e.nodeType;if
(
o
)
{if
(
1===o||9===o||11===o
)
{if
(
"string"==typeof e.textContent
)
return e.textContent;for
(
e=e.firstChild;e;e=e.nextSibling
)
n+=i
(
e
)
}else if
(
3===o||4===o
)
return e.nodeValue}else while
(
t=e
[
r++
])
n+=i
(
t
)
;return n},
(
r=oe.selectors={cacheLength:50,createPseudo:se,match:V,attrHandle:{},find:{},relative:{">":{dir:"parentNode",first:!0}," ":{dir:"parentNode"},"+":{dir:"previousSibling",first:!0},"~":{dir:"previousSibling"}},preFilter:{ATTR:function
(
e
)
{return e
[
1
]
=e
[
1
]
.replace
(
Z,ee
)
,e
[
3
]
=
(
e
[
3
]
||e
[
4
]
||e
[
5
]
||""
)
.replace
(
Z,ee
)
,"~="===e
[
2
]
&&
(
e
[
3
]
=" "+e
[
3
]
+" "
)
,e.slice
(
0,4
)
},CHILD:function
(
e
)
{return e
[
1
]
=e
[
1
]
.toLowerCase
()
,"nth"===e
[
1
]
.slice
(
0,3
)?(
e
[
3
]
||oe.error
(
e
[
0
])
,e
[
4
]
=+
(
e
[
4
]?
e
[
5
]
+
(
e
[
6
]
||1
)
:2*
(
"even"===e
[
3
]
||"odd"===e
[
3
]))
,e
[
5
]
=+
(
e
[
7
]
+e
[
8
]
||"odd"===e
[
3
]))
:e
[
3
]
&&oe.error
(
e
[
0
])
,e},PSEUDO:function
(
e
)
{var t,n=!e
[
6
]
&&e
[
2
]
;return V.CHILD.test
(
e
[
0
])?
null:
(
e
[
3
]?
e
[
2
]
=e
[
4
]
||e
[
5
]
||"":n&&X.test
(
n
)
&&
(
t=a
(
n,!0
))
&&
(
t=n.indexOf
(
"
)
",n.length-t
)
-n.length
)
&&
(
e
[
0
]
=e
[
0
]
.slice
(
0,t
)
,e
[
2
]
=n.slice
(
0,t
))
,e.slice
(
0,3
))
}},filter:{TAG:function
(
e
)
{var t=e.replace
(
Z,ee
)
.toLowerCase
()
;return"*"===e
?
function
()
{return!0}:function
(
e
)
{return e.nodeName&&e.nodeName.toLowerCase
()
===t}},CLASS:function
(
e
)
{var t=E
[
e+" "
]
;return t||
(
t=new RegExp
(
"
(
^|"+M+"
)
"+e+"
(
"+M+"|$
)
"
))
&&E
(
e,function
(
e
)
{return t.test
(
"string"==typeof e.className&&e.className||"undefined"!=typeof e.getAttribute&&e.getAttribute
(
"class"
)
||""
)
}
)
},ATTR:function
(
e,t,n
)
{return function
(
r
)
{var i=oe.attr
(
r,e
)
;return null==i
?
"!="===t:!t||
(
i+="","="===t
?
i===n:"!="===t
?
i!==n:"^="===t
?
n&&0===i.indexOf
(
n
)
:"*="===t
?
n&&i.indexOf
(
n
)
>-1:"$="===t
?
n&&i.slice
(
-n.length
)
===n:"~="===t
?(
" "+i.replace
(
$," "
)
+" "
)
.indexOf
(
n
)
>-1:"|="===t&&
(
i===n||i.slice
(
0,n.length+1
)
===n+"-"
))
}},CHILD:function
(
e,t,n,r,i
)
{var o="nth"!==e.slice
(
0,3
)
,a="last"!==e.slice
(
-4
)
,s="of-type"===t;return 1===r&&0===i
?
function
(
e
)
{return!!e.parentNode}:function
(
t,n,u
)
{var l,c,f,p,d,h,g=o!==a
?
"nextSibling":"previousSibling",y=t.parentNode,v=s&&t.nodeName.toLowerCase
()
,m=!u&&!s,x=!1;if
(
y
)
{if
(
o
)
{while
(
g
)
{p=t;while
(
p=p
[
g
])
if
(
s
?
p.nodeName.toLowerCase
()
===v:1===p.nodeType
)
return!1;h=g="only"===e&&!h&&"nextSibling"}return!0}if
(
h=
[
a?y.firstChild:y.lastChild
]
,a&&m
)
{x=
(
d=
(
l=
(
c=
(
f=
(
p=y
)[
b
]
||
(
p
[
b
]
={}
))[
p.uniqueID
]
||
(
f
[
p.uniqueID
]
={}
))[
e
]
||
[])[
0
]
===T&&l
[
1
])
&&l
[
2
]
,p=d&&y.childNodes
[
d
]
;while
(
p=++d&&p&&p
[
g
]
||
(
x=d=0
)
||h.pop
())
if
(
1===p.nodeType&&++x&&p===t
)
{c
[
e
]
=
[
T,d,x
]
;break}}else if
(
m&&
(
x=d=
(
l=
(
c=
(
f=
(
p=t
)[
b
]
||
(
p
[
b
]
={}
))[
p.uniqueID
]
||
(
f
[
p.uniqueID
]
={}
))[
e
]
||
[])[
0
]
===T&&l
[
1
])
,!1===x
)
while
(
p=++d&&p&&p
[
g
]
||
(
x=d=0
)
||h.pop
())
if
((
s
?
p.nodeName.toLowerCase
()
===v:1===p.nodeType
)
&&++x&&
(
m&&
((
c=
(
f=p
[
b
]
||
(
p
[
b
]
={}
))[
p.uniqueID
]
||
(
f
[
p.uniqueID
]
={}
))[
e
]
=
[
T,x
])
,p===t
))
break;return
(
x-=i
)
===r||x%r==0&&x/
r
>=
0
}}},
PSEUDO
:
function
(
e
,
t
){
var
n
,
i
=
r
.
pseudos
[
e
]
||
r
.
setFilters
[
e
.
toLowerCase
()]
||
oe
.
error
(
"unsupported pseudo: "
+
e
);
return
i
[
b
]?
i
(
t
):
i
.
length
>
1
?(
n
=
[
e
,
e
,
""
,
t
],
r
.
setFilters
.
hasOwnProperty
(
e
.
toLowerCase
())?
se
(
function
(
e
,
n
){
var
r
,
o
=
i
(
e
,
t
),
a
=
o
.
length
;
while
(
a
--
)
e
[
r
=
O
(
e
,
o
[
a
])]
=!
(
n
[
r
]
=
o
[
a
])}):
function
(
e
){
return
i
(
e
,
0
,
n
)}):
i
}},
pseudos
:{
not
:
se
(
function
(
e
){
var
t
=
[],
n
=
[],
r
=
s
(
e
.
replace
(
B
,
"$1"
));
return
r
[
b
]?
se
(
function
(
e
,
t
,
n
,
i
){
var
o
,
a
=
r
(
e
,
null
,
i
,[]),
s
=
e
.
length
;
while
(
s
--
)(
o
=
a
[
s
])
&&
(
e
[
s
]
=!
(
t
[
s
]
=
o
))}):
function
(
e
,
i
,
o
){
return
t
[
0
]
=
e
,
r
(
t
,
null
,
o
,
n
),
t
[
0
]
=
null
,
!
n
.
pop
()}}),
has
:
se
(
function
(
e
){
return
function
(
t
){
return
oe
(
e
,
t
).
length
>
0
}}),
contains
:
se
(
function
(
e
){
return
e
=
e
.
replace
(
Z
,
ee
),
function
(
t
){
return
(
t
.
textContent
||
t
.
innerText
||
i
(
t
)).
indexOf
(
e
)
>-
1
}}),
lang
:
se
(
function
(
e
){
return
U
.
test
(
e
||
""
)
||
oe
.
error
(
"unsupported lang: "
+
e
),
e
=
e
.
replace
(
Z
,
ee
).
toLowerCase
(),
function
(
t
){
var
n
;
do
{
if
(
n
=
g
?
t
.
lang
:
t
.
getAttribute
(
"xml:lang"
)
||
t
.
getAttribute
(
"lang"
))
return
(
n
=
n
.
toLowerCase
())
===
e
||
0
===
n
.
indexOf
(
e
+
"-"
)}
while
((
t
=
t
.
parentNode
)
&&
1
===
t
.
nodeType
);
return
!
1
}}),
target
:
function
(
t
){
var
n
=
e
.
location
&&
e
.
location
.
hash
;
return
n
&&
n
.
slice
(
1
)
===
t
.
id
},
root
:
function
(
e
){
return
e
===
h
},
focus
:
function
(
e
){
return
e
===
d
.
activeElement
&&
(
!
d
.
hasFocus
||
d
.
hasFocus
())
&&!!
(
e
.
type
||
e
.
href
||~
e
.
tabIndex
)},
enabled
:
de
(
!
1
),
disabled
:
de
(
!
0
),
checked
:
function
(
e
){
var
t
=
e
.
nodeName
.
toLowerCase
();
return
"input"
===
t
&&!!
e
.
checked
||
"option"
===
t
&&!!
e
.
selected
},
selected
:
function
(
e
){
return
e
.
parentNode
&&
e
.
parentNode
.
selectedIndex
,
!
0
===
e
.
selected
},
empty
:
function
(
e
){
for
(
e
=
e
.
firstChild
;
e
;
e
=
e
.
nextSibling
)
if
(
e
.
nodeType
<
6
)
return
!
1
;
return
!
0
},
parent
:
function
(
e
){
return
!
r
.
pseudos
.
empty
(
e
)},
header
:
function
(
e
){
return
Y
.
test
(
e
.
nodeName
)},
input
:
function
(
e
){
return
G
.
test
(
e
.
nodeName
)},
button
:
function
(
e
){
var
t
=
e
.
nodeName
.
toLowerCase
();
return
"input"
===
t
&&
"button"
===
e
.
type
||
"button"
===
t
},
text
:
function
(
e
){
var
t
;
return
"input"
===
e
.
nodeName
.
toLowerCase
()
&&
"text"
===
e
.
type
&&
(
null
==
(
t
=
e
.
getAttribute
(
"type"
))
||
"text"
===
t
.
toLowerCase
())},
first
:
he
(
function
(){
return
[
0
]}),
last
:
he
(
function
(
e
,
t
){
return
[
t
-
1
]}),
eq
:
he
(
function
(
e
,
t
,
n
){
return
[
n
<
0
?
n
+
t
:
n
]}),
even
:
he
(
function
(
e
,
t
){
for
(
var
n
=
0
;
n
<
t
;
n
+=
2
)
e
.
push
(
n
);
return
e
}),
odd
:
he
(
function
(
e
,
t
){
for
(
var
n
=
1
;
n
<
t
;
n
+=
2
)
e
.
push
(
n
);
return
e
}),
lt
:
he
(
function
(
e
,
t
,
n
){
for
(
var
r
=
n
<
0
?
n
+
t
:
n
;
--
r
>=
0
;)
e
.
push
(
r
);
return
e
}),
gt
:
he
(
function
(
e
,
t
,
n
){
for
(
var
r
=
n
<
0
?
n
+
t
:
n
;
++
r
<
t
;)
e
.
push
(
r
);
return
e
})}}).
pseudos
.
nth
=
r
.
pseudos
.
eq
;
for
(
t
in
{
radio
:
!
0
,
checkbox
:
!
0
,
file
:
!
0
,
password
:
!
0
,
image
:
!
0
})
r
.
pseudos
[
t
]
=
fe
(
t
);
for
(
t
in
{
submit
:
!
0
,
reset
:
!
0
})
r
.
pseudos
[
t
]
=
pe
(
t
);
function
ye
(){}
ye
.
prototype
=
r
.
filters
=
r
.
pseudos
,
r
.
setFilters
=
new
ye
,
a
=
oe
.
tokenize
=
function
(
e
,
t
){
var
n
,
i
,
o
,
a
,
s
,
u
,
l
,
c
=
k
[
e
+
" "
];
if
(
c
)
return
t
?
0
:
c
.
slice
(
0
);
s
=
e
,
u
=
[],
l
=
r
.
preFilter
;
while
(
s
){
n
&&!
(
i
=
F
.
exec
(
s
))
||
(
i
&&
(
s
=
s
.
slice
(
i
[
0
].
length
)
||
s
),
u
.
push
(
o
=
[])),
n
=!
1
,(
i
=
_
.
exec
(
s
))
&&
(
n
=
i
.
shift
(),
o
.
push
({
value
:
n
,
type
:
i
[
0
].
replace
(
B
,
" "
)}),
s
=
s
.
slice
(
n
.
length
));
for
(
a
in
r
.
filter
)
!
(
i
=
V
[
a
].
exec
(
s
))
||
l
[
a
]
&&!
(
i
=
l
[
a
](
i
))
||
(
n
=
i
.
shift
(),
o
.
push
({
value
:
n
,
type
:
a
,
matches
:
i
}),
s
=
s
.
slice
(
n
.
length
));
if
(
!
n
)
break
}
return
t
?
s
.
length
:
s
?
oe
.
error
(
e
):
k
(
e
,
u
).
slice
(
0
)};
function
ve
(
e
){
for
(
var
t
=
0
,
n
=
e
.
length
,
r
=
""
;
t
<
n
;
t
++
)
r
+=
e
[
t
].
value
;
return
r
}
function
me
(
e
,
t
,
n
){
var
r
=
t
.
dir
,
i
=
t
.
next
,
o
=
i
||
r
,
a
=
n
&&
"parentNode"
===
o
,
s
=
C
++
;
return
t
.
first
?
function
(
t
,
n
,
i
){
while
(
t
=
t
[
r
])
if
(
1
===
t
.
nodeType
||
a
)
return
e
(
t
,
n
,
i
);
return
!
1
}:
function
(
t
,
n
,
u
){
var
l
,
c
,
f
,
p
=
[
T
,
s
];
if
(
u
){
while
(
t
=
t
[
r
])
if
((
1
===
t
.
nodeType
||
a
)
&&
e
(
t
,
n
,
u
))
return
!
0
}
else
while
(
t
=
t
[
r
])
if
(
1
===
t
.
nodeType
||
a
)
if
(
f
=
t
[
b
]
||
(
t
[
b
]
=
{}),
c
=
f
[
t
.
uniqueID
]
||
(
f
[
t
.
uniqueID
]
=
{}),
i
&&
i
===
t
.
nodeName
.
toLowerCase
())
t
=
t
[
r
]
||
t
;
else
{
if
((
l
=
c
[
o
])
&&
l
[
0
]
===
T
&&
l
[
1
]
===
s
)
return
p
[
2
]
=
l
[
2
];
if
(
c
[
o
]
=
p
,
p
[
2
]
=
e
(
t
,
n
,
u
))
return
!
0
}
return
!
1
}}
function
xe
(
e
){
return
e
.
length
>
1
?
function
(
t
,
n
,
r
){
var
i
=
e
.
length
;
while
(
i
--
)
if
(
!
e
[
i
](
t
,
n
,
r
))
return
!
1
;
return
!
0
}:
e
[
0
]}
function
be
(
e
,
t
,
n
){
for
(
var
r
=
0
,
i
=
t
.
length
;
r
<
i
;
r
++
)
oe
(
e
,
t
[
r
],
n
);
return
n
}
function
we
(
e
,
t
,
n
,
r
,
i
){
for
(
var
o
,
a
=
[],
s
=
0
,
u
=
e
.
length
,
l
=
null
!=
t
;
s
<
u
;
s
++
)(
o
=
e
[
s
])
&&
(
n
&&!
n
(
o
,
r
,
i
)
||
(
a
.
push
(
o
),
l
&&
t
.
push
(
s
)));
return
a
}
function
Te
(
e
,
t
,
n
,
r
,
i
,
o
){
return
r
&&!
r
[
b
]
&&
(
r
=
Te
(
r
)),
i
&&!
i
[
b
]
&&
(
i
=
Te
(
i
,
o
)),
se
(
function
(
o
,
a
,
s
,
u
){
var
l
,
c
,
f
,
p
=
[],
d
=
[],
h
=
a
.
length
,
g
=
o
||
be
(
t
||
"*"
,
s
.
nodeType
?[
s
]:
s
,[]),
y
=!
e
||!
o
&&
t
?
g
:
we
(
g
,
p
,
e
,
s
,
u
),
v
=
n
?
i
||
(
o
?
e
:
h
||
r
)?[]:
a
:
y
;
if
(
n
&&
n
(
y
,
v
,
s
,
u
),
r
){
l
=
we
(
v
,
d
),
r
(
l
,[],
s
,
u
),
c
=
l
.
length
;
while
(
c
--
)(
f
=
l
[
c
])
&&
(
v
[
d
[
c
]]
=!
(
y
[
d
[
c
]]
=
f
))}
if
(
o
){
if
(
i
||
e
){
if
(
i
){
l
=
[],
c
=
v
.
length
;
while
(
c
--
)(
f
=
v
[
c
])
&&
l
.
push
(
y
[
c
]
=
f
);
i
(
null
,
v
=
[],
l
,
u
)}
c
=
v
.
length
;
while
(
c
--
)(
f
=
v
[
c
])
&&
(
l
=
i
?
O
(
o
,
f
):
p
[
c
])
>-
1
&&
(
o
[
l
]
=!
(
a
[
l
]
=
f
))}}
else
v
=
we
(
v
===
a
?
v
.
splice
(
h
,
v
.
length
):
v
),
i
?
i
(
null
,
a
,
v
,
u
):
L
.
apply
(
a
,
v
)})}
function
Ce
(
e
){
for
(
var
t
,
n
,
i
,
o
=
e
.
length
,
a
=
r
.
relative
[
e
[
0
].
type
],
s
=
a
||
r
.
relative
[
" "
],
u
=
a
?
1
:
0
,
c
=
me
(
function
(
e
){
return
e
===
t
},
s
,
!
0
),
f
=
me
(
function
(
e
){
return
O
(
t
,
e
)
>-
1
},
s
,
!
0
),
p
=
[
function
(
e
,
n
,
r
){
var
i
=!
a
&&
(
r
||
n
!==
l
)
||
((
t
=
n
).
nodeType
?
c
(
e
,
n
,
r
):
f
(
e
,
n
,
r
));
return
t
=
null
,
i
}];
u
<
o
;
u
++
)
if
(
n
=
r
.
relative
[
e
[
u
].
type
])
p
=
[
me
(
xe
(
p
),
n
)];
else
{
if
((
n
=
r
.
filter
[
e
[
u
].
type
].
apply
(
null
,
e
[
u
].
matches
))[
b
]){
for
(
i
=++
u
;
i
<
o
;
i
++
)
if
(
r
.
relative
[
e
[
i
].
type
])
break
;
return
Te
(
u
>
1
&&
xe
(
p
),
u
>
1
&&
ve
(
e
.
slice
(
0
,
u
-
1
).
concat
({
value
:
" "
===
e
[
u
-
2
].
type
?
"*"
:
""
})).
replace
(
B
,
"$1"
),
n
,
u
<
i
&&
Ce
(
e
.
slice
(
u
,
i
)),
i
<
o
&&
Ce
(
e
=
e
.
slice
(
i
)),
i
<
o
&&
ve
(
e
))}
p
.
push
(
n
)}
return
xe
(
p
)}
function
Ee
(
e
,
t
){
var
n
=
t
.
length
>
0
,
i
=
e
.
length
>
0
,
o
=
function
(
o
,
a
,
s
,
u
,
c
){
var
f
,
h
,
y
,
v
=
0
,
m
=
"0"
,
x
=
o
&&
[],
b
=
[],
w
=
l
,
C
=
o
||
i
&&
r
.
find
.
TAG
(
"*"
,
c
),
E
=
T
+=
null
==
w
?
1
:
Math
.
random
()
||
.
1
,
k
=
C
.
length
;
for
(
c
&&
(
l
=
a
===
d
||
a
||
c
);
m
!==
k
&&
null
!=
(
f
=
C
[
m
]);
m
++
){
if
(
i
&&
f
){
h
=
0
,
a
||
f
.
ownerDocument
===
d
||
(
p
(
f
),
s
=!
g
);
while
(
y
=
e
[
h
++
])
if
(
y
(
f
,
a
||
d
,
s
)){
u
.
push
(
f
);
break
}
c
&&
(
T
=
E
)}
n
&&
((
f
=!
y
&&
f
)
&&
v
--
,
o
&&
x
.
push
(
f
))}
if
(
v
+=
m
,
n
&&
m
!==
v
){
h
=
0
;
while
(
y
=
t
[
h
++
])
y
(
x
,
b
,
a
,
s
);
if
(
o
){
if
(
v
>
0
)
while
(
m
--
)
x
[
m
]
||
b
[
m
]
||
(
b
[
m
]
=
j
.
call
(
u
));
b
=
we
(
b
)}
L
.
apply
(
u
,
b
),
c
&&!
o
&&
b
.
length
>
0
&&
v
+
t
.
length
>
1
&&
oe
.
uniqueSort
(
u
)}
return
c
&&
(
T
=
E
,
l
=
w
),
x
};
return
n
?
se
(
o
):
o
}
return
s
=
oe
.
compile
=
function
(
e
,
t
){
var
n
,
r
=
[],
i
=
[],
o
=
S
[
e
+
" "
];
if
(
!
o
){
t
||
(
t
=
a
(
e
)),
n
=
t
.
length
;
while
(
n
--
)(
o
=
Ce
(
t
[
n
]))[
b
]?
r
.
push
(
o
):
i
.
push
(
o
);(
o
=
S
(
e
,
Ee
(
i
,
r
))).
selector
=
e
}
return
o
},
u
=
oe
.
select
=
function
(
e
,
t
,
n
,
i
){
var
o
,
u
,
l
,
c
,
f
,
p
=
"function"
==
typeof
e
&&
e
,
d
=!
i
&&
a
(
e
=
p
.
selector
||
e
);
if
(
n
=
n
||
[],
1
===
d
.
length
){
if
((
u
=
d
[
0
]
=
d
[
0
].
slice
(
0
)).
length
>
2
&&
"ID"
===
(
l
=
u
[
0
]).
type
&&
9
===
t
.
nodeType
&&
g
&&
r
.
relative
[
u
[
1
].
type
]){
if
(
!
(
t
=
(
r
.
find
.
ID
(
l
.
matches
[
0
].
replace
(
Z
,
ee
),
t
)
||
[])[
0
]))
return
n
;
p
&&
(
t
=
t
.
parentNode
),
e
=
e
.
slice
(
u
.
shift
().
value
.
length
)}
o
=
V
.
needsContext
.
test
(
e
)?
0
:
u
.
length
;
while
(
o
--
){
if
(
l
=
u
[
o
],
r
.
relative
[
c
=
l
.
type
])
break
;
if
((
f
=
r
.
find
[
c
])
&&
(
i
=
f
(
l
.
matches
[
0
].
replace
(
Z
,
ee
),
K
.
test
(
u
[
0
].
type
)
&&
ge
(
t
.
parentNode
)
||
t
))){
if
(
u
.
splice
(
o
,
1
),
!
(
e
=
i
.
length
&&
ve
(
u
)))
return
L
.
apply
(
n
,
i
),
n
;
break
}}}
return
(
p
||
s
(
e
,
d
))(
i
,
t
,
!
g
,
n
,
!
t
||
K
.
test
(
e
)
&&
ge
(
t
.
parentNode
)
||
t
),
n
},
n
.
sortStable
=
b
.
split
(
""
).
sort
(
D
).
join
(
""
)
===
b
,
n
.
detectDuplicates
=!!
f
,
p
(),
n
.
sortDetached
=
ue
(
function
(
e
){
return
1
&
e
.
compareDocumentPosition
(
d
.
createElement
(
"fieldset"
))}),
ue
(
function
(
e
){
return
e
.
innerHTML
=
"<a href='#'></a>"
,
"#"
===
e
.
firstChild
.
getAttribute
(
"href"
)})
||
le
(
"type|href|height|width"
,
function
(
e
,
t
,
n
){
if
(
!
n
)
return
e
.
getAttribute
(
t
,
"type"
===
t
.
toLowerCase
()?
1
:
2
)}),
n
.
attributes
&&
ue
(
function
(
e
){
return
e
.
innerHTML
=
"<input/>"
,
e
.
firstChild
.
setAttribute
(
"value"
,
""
),
""
===
e
.
firstChild
.
getAttribute
(
"value"
)})
||
le
(
"value"
,
function
(
e
,
t
,
n
){
if
(
!
n
&&
"input"
===
e
.
nodeName
.
toLowerCase
())
return
e
.
defaultValue
}),
ue
(
function
(
e
){
return
null
==
e
.
getAttribute
(
"disabled"
)})
||
le
(
P
,
function
(
e
,
t
,
n
){
var
r
;
if
(
!
n
)
return
!
0
===
e
[
t
]?
t
.
toLowerCase
():(
r
=
e
.
getAttributeNode
(
t
))
&&
r
.
specified
?
r
.
value
:
null
}),
oe
}(
e
);
w
.
find
=
E
,
w
.
expr
=
E
.
selectors
,
w
.
expr
[
":"
]
=
w
.
expr
.
pseudos
,
w
.
uniqueSort
=
w
.
unique
=
E
.
uniqueSort
,
w
.
text
=
E
.
getText
,
w
.
isXMLDoc
=
E
.
isXML
,
w
.
contains
=
E
.
contains
,
w
.
escapeSelector
=
E
.
escape
;
var
k
=
function
(
e
,
t
,
n
){
var
r
=
[],
i
=
void
0
!==
n
;
while
((
e
=
e
[
t
])
&&
9
!==
e
.
nodeType
)
if
(
1
===
e
.
nodeType
){
if
(
i
&&
w
(
e
).
is
(
n
))
break
;
r
.
push
(
e
)}
return
r
},
S
=
function
(
e
,
t
){
for
(
var
n
=
[];
e
;
e
=
e
.
nextSibling
)
1
===
e
.
nodeType
&&
e
!==
t
&&
n
.
push
(
e
);
return
n
},
D
=
w
.
expr
.
match
.
needsContext
;
function
N
(
e
,
t
){
return
e
.
nodeName
&&
e
.
nodeName
.
toLowerCase
()
===
t
.
toLowerCase
()}
var
A
=
/^<
([
a-z
][^\/\0
>:
\x
20
\t\r\n\f]
*
)[\x
20
\t\r\n\f]
*
\/?
>
(?:
<
\/\1
>|
)
$/i
;
function
j
(
e
,
t
,
n
){
return
g
(
t
)?
w
.
grep
(
e
,
function
(
e
,
r
){
return
!!
t
.
call
(
e
,
r
,
e
)
!==
n
}):
t
.
nodeType
?
w
.
grep
(
e
,
function
(
e
){
return
e
===
t
!==
n
}):
"string"
!=
typeof
t
?
w
.
grep
(
e
,
function
(
e
){
return
u
.
call
(
t
,
e
)
>-
1
!==
n
}):
w
.
filter
(
t
,
e
,
n
)}
w
.
filter
=
function
(
e
,
t
,
n
){
var
r
=
t
[
0
];
return
n
&&
(
e
=
":not("
+
e
+
")"
),
1
===
t
.
length
&&
1
===
r
.
nodeType
?
w
.
find
.
matchesSelector
(
r
,
e
)?[
r
]:[]:
w
.
find
.
matches
(
e
,
w
.
grep
(
t
,
function
(
e
){
return
1
===
e
.
nodeType
}))},
w
.
fn
.
extend
({
find
:
function
(
e
){
var
t
,
n
,
r
=
this
.
length
,
i
=
this
;
if
(
"string"
!=
typeof
e
)
return
this
.
pushStack
(
w
(
e
).
filter
(
function
(){
for
(
t
=
0
;
t
<
r
;
t
++
)
if
(
w
.
contains
(
i
[
t
],
this
))
return
!
0
}));
for
(
n
=
this
.
pushStack
([]),
t
=
0
;
t
<
r
;
t
++
)
w
.
find
(
e
,
i
[
t
],
n
);
return
r
>
1
?
w
.
uniqueSort
(
n
):
n
},
filter
:
function
(
e
){
return
this
.
pushStack
(
j
(
this
,
e
||
[],
!
1
))},
not
:
function
(
e
){
return
this
.
pushStack
(
j
(
this
,
e
||
[],
!
0
))},
is
:
function
(
e
){
return
!!
j
(
this
,
"string"
==
typeof
e
&&
D
.
test
(
e
)?
w
(
e
):
e
||
[],
!
1
).
length
}});
var
q
,
L
=
/^
(?:\s
*
(
<
[\w\W]
+>
)[^
>
]
*|#
([\w
-
]
+
))
$/
;(
w
.
fn
.
init
=
function
(
e
,
t
,
n
){
var
i
,
o
;
if
(
!
e
)
return
this
;
if
(
n
=
n
||
q
,
"string"
==
typeof
e
){
if
(
!
(
i
=
"<"
===
e
[
0
]
&&
">"
===
e
[
e
.
length
-
1
]
&&
e
.
length
>=
3
?[
null
,
e
,
null
]:
L
.
exec
(
e
))
||!
i
[
1
]
&&
t
)
return
!
t
||
t
.
jquery
?(
t
||
n
).
find
(
e
):
this
.
constructor
(
t
).
find
(
e
);
if
(
i
[
1
]){
if
(
t
=
t
instanceof
w
?
t
[
0
]:
t
,
w
.
merge
(
this
,
w
.
parseHTML
(
i
[
1
],
t
&&
t
.
nodeType
?
t
.
ownerDocument
||
t
:
r
,
!
0
)),
A
.
test
(
i
[
1
])
&&
w
.
isPlainObject
(
t
))
for
(
i
in
t
)
g
(
this
[
i
])?
this
[
i
](
t
[
i
]):
this
.
attr
(
i
,
t
[
i
]);
return
this
}
return
(
o
=
r
.
getElementById
(
i
[
2
]))
&&
(
this
[
0
]
=
o
,
this
.
length
=
1
),
this
}
return
e
.
nodeType
?(
this
[
0
]
=
e
,
this
.
length
=
1
,
this
):
g
(
e
)?
void
0
!==
n
.
ready
?
n
.
ready
(
e
):
e
(
w
):
w
.
makeArray
(
e
,
this
)}).
prototype
=
w
.
fn
,
q
=
w
(
r
);
var
H
=
/^
(?:
parents|prev
(?:
Until|All
))
/
,
O
=
{
children
:
!
0
,
contents
:
!
0
,
next
:
!
0
,
prev
:
!
0
};
w
.
fn
.
extend
({
has
:
function
(
e
){
var
t
=
w
(
e
,
this
),
n
=
t
.
length
;
return
this
.
filter
(
function
(){
for
(
var
e
=
0
;
e
<
n
;
e
++
)
if
(
w
.
contains
(
this
,
t
[
e
]))
return
!
0
})},
closest
:
function
(
e
,
t
){
var
n
,
r
=
0
,
i
=
this
.
length
,
o
=
[],
a
=
"string"
!=
typeof
e
&&
w
(
e
);
if
(
!
D
.
test
(
e
))
for
(;
r
<
i
;
r
++
)
for
(
n
=
this
[
r
];
n
&&
n
!==
t
;
n
=
n
.
parentNode
)
if
(
n
.
nodeType
<
11
&&
(
a
?
a
.
index
(
n
)
>-
1
:
1
===
n
.
nodeType
&&
w
.
find
.
matchesSelector
(
n
,
e
))){
o
.
push
(
n
);
break
}
return
this
.
pushStack
(
o
.
length
>
1
?
w
.
uniqueSort
(
o
):
o
)},
index
:
function
(
e
){
return
e
?
"string"
==
typeof
e
?
u
.
call
(
w
(
e
),
this
[
0
]):
u
.
call
(
this
,
e
.
jquery
?
e
[
0
]:
e
):
this
[
0
]
&&
this
[
0
].
parentNode
?
this
.
first
().
prevAll
().
length
:
-
1
},
add
:
function
(
e
,
t
){
return
this
.
pushStack
(
w
.
uniqueSort
(
w
.
merge
(
this
.
get
(),
w
(
e
,
t
))))},
addBack
:
function
(
e
){
return
this
.
add
(
null
==
e
?
this
.
prevObject
:
this
.
prevObject
.
filter
(
e
))}});
function
P
(
e
,
t
){
while
((
e
=
e
[
t
])
&&
1
!==
e
.
nodeType
);
return
e
}
w
.
each
({
parent
:
function
(
e
){
var
t
=
e
.
parentNode
;
return
t
&&
11
!==
t
.
nodeType
?
t
:
null
},
parents
:
function
(
e
){
return
k
(
e
,
"parentNode"
)},
parentsUntil
:
function
(
e
,
t
,
n
){
return
k
(
e
,
"parentNode"
,
n
)},
next
:
function
(
e
){
return
P
(
e
,
"nextSibling"
)},
prev
:
function
(
e
){
return
P
(
e
,
"previousSibling"
)},
nextAll
:
function
(
e
){
return
k
(
e
,
"nextSibling"
)},
prevAll
:
function
(
e
){
return
k
(
e
,
"previousSibling"
)},
nextUntil
:
function
(
e
,
t
,
n
){
return
k
(
e
,
"nextSibling"
,
n
)},
prevUntil
:
function
(
e
,
t
,
n
){
return
k
(
e
,
"previousSibling"
,
n
)},
siblings
:
function
(
e
){
return
S
((
e
.
parentNode
||
{}).
firstChild
,
e
)},
children
:
function
(
e
){
return
S
(
e
.
firstChild
)},
contents
:
function
(
e
){
return
N
(
e
,
"iframe"
)?
e
.
contentDocument
:(
N
(
e
,
"template"
)
&&
(
e
=
e
.
content
||
e
),
w
.
merge
([],
e
.
childNodes
))}},
function
(
e
,
t
){
w
.
fn
[
e
]
=
function
(
n
,
r
){
var
i
=
w
.
map
(
this
,
t
,
n
);
return
"Until"
!==
e
.
slice
(
-
5
)
&&
(
r
=
n
),
r
&&
"string"
==
typeof
r
&&
(
i
=
w
.
filter
(
r
,
i
)),
this
.
length
>
1
&&
(
O
[
e
]
||
w
.
uniqueSort
(
i
),
H
.
test
(
e
)
&&
i
.
reverse
()),
this
.
pushStack
(
i
)}});
var
M
=
/
[^\x
20
\t\r\n\f]
+/g
;
function
R
(
e
){
var
t
=
{};
return
w
.
each
(
e
.
match
(
M
)
||
[],
function
(
e
,
n
){
t
[
n
]
=!
0
}),
t
}
w
.
Callbacks
=
function
(
e
){
e
=
"string"
==
typeof
e
?
R
(
e
):
w
.
extend
({},
e
);
var
t
,
n
,
r
,
i
,
o
=
[],
a
=
[],
s
=-
1
,
u
=
function
(){
for
(
i
=
i
||
e
.
once
,
r
=
t
=!
0
;
a
.
length
;
s
=-
1
){
n
=
a
.
shift
();
while
(
++
s
<
o
.
length
)
!
1
===
o
[
s
].
apply
(
n
[
0
],
n
[
1
])
&&
e
.
stopOnFalse
&&
(
s
=
o
.
length
,
n
=!
1
)}
e
.
memory
||
(
n
=!
1
),
t
=!
1
,
i
&&
(
o
=
n
?[]:
""
)},
l
=
{
add
:
function
(){
return
o
&&
(
n
&&!
t
&&
(
s
=
o
.
length
-
1
,
a
.
push
(
n
)),
function
t
(
n
){
w
.
each
(
n
,
function
(
n
,
r
){
g
(
r
)?
e
.
unique
&&
l
.
has
(
r
)
||
o
.
push
(
r
):
r
&&
r
.
length
&&
"string"
!==
x
(
r
)
&&
t
(
r
)})}(
arguments
),
n
&&!
t
&&
u
()),
this
},
remove
:
function
(){
return
w
.
each
(
arguments
,
function
(
e
,
t
){
var
n
;
while
((
n
=
w
.
inArray
(
t
,
o
,
n
))
>-
1
)
o
.
splice
(
n
,
1
),
n
<=
s
&&
s
--
}),
this
},
has
:
function
(
e
){
return
e
?
w
.
inArray
(
e
,
o
)
>-
1
:
o
.
length
>
0
},
empty
:
function
(){
return
o
&&
(
o
=
[]),
this
},
disable
:
function
(){
return
i
=
a
=
[],
o
=
n
=
""
,
this
},
disabled
:
function
(){
return
!
o
},
lock
:
function
(){
return
i
=
a
=
[],
n
||
t
||
(
o
=
n
=
""
),
this
},
locked
:
function
(){
return
!!
i
},
fireWith
:
function
(
e
,
n
){
return
i
||
(
n
=
[
e
,(
n
=
n
||
[]).
slice
?
n
.
slice
():
n
],
a
.
push
(
n
),
t
||
u
()),
this
},
fire
:
function
(){
return
l
.
fireWith
(
this
,
arguments
),
this
},
fired
:
function
(){
return
!!
r
}};
return
l
};
function
I
(
e
){
return
e
}
function
W
(
e
){
throw
e
}
function
$
(
e
,
t
,
n
,
r
){
var
i
;
try
{
e
&&
g
(
i
=
e
.
promise
)?
i
.
call
(
e
).
done
(
t
).
fail
(
n
):
e
&&
g
(
i
=
e
.
then
)?
i
.
call
(
e
,
t
,
n
):
t
.
apply
(
void
0
,[
e
].
slice
(
r
))}
catch
(
e
){
n
.
apply
(
void
0
,[
e
])}}
w
.
extend
({
Deferred
:
function
(
t
){
var
n
=
[[
"notify"
,
"progress"
,
w
.
Callbacks
(
"memory"
),
w
.
Callbacks
(
"memory"
),
2
],[
"resolve"
,
"done"
,
w
.
Callbacks
(
"once memory"
),
w
.
Callbacks
(
"once memory"
),
0
,
"resolved"
],[
"reject"
,
"fail"
,
w
.
Callbacks
(
"once memory"
),
w
.
Callbacks
(
"once memory"
),
1
,
"rejected"
]],
r
=
"pending"
,
i
=
{
state
:
function
(){
return
r
},
always
:
function
(){
return
o
.
done
(
arguments
).
fail
(
arguments
),
this
},
"catch"
:
function
(
e
){
return
i
.
then
(
null
,
e
)},
pipe
:
function
(){
var
e
=
arguments
;
return
w
.
Deferred
(
function
(
t
){
w
.
each
(
n
,
function
(
n
,
r
){
var
i
=
g
(
e
[
r
[
4
]])
&&
e
[
r
[
4
]];
o
[
r
[
1
]](
function
(){
var
e
=
i
&&
i
.
apply
(
this
,
arguments
);
e
&&
g
(
e
.
promise
)?
e
.
promise
().
progress
(
t
.
notify
).
done
(
t
.
resolve
).
fail
(
t
.
reject
):
t
[
r
[
0
]
+
"With"
](
this
,
i
?[
e
]:
arguments
)})}),
e
=
null
}).
promise
()},
then
:
function
(
t
,
r
,
i
){
var
o
=
0
;
function
a
(
t
,
n
,
r
,
i
){
return
function
(){
var
s
=
this
,
u
=
arguments
,
l
=
function
(){
var
e
,
l
;
if
(
!
(
t
<
o
)){
if
((
e
=
r
.
apply
(
s
,
u
))
===
n
.
promise
())
throw
new
TypeError
(
"Thenable self-resolution"
);
l
=
e
&&
(
"object"
==
typeof
e
||
"function"
==
typeof
e
)
&&
e
.
then
,
g
(
l
)?
i
?
l
.
call
(
e
,
a
(
o
,
n
,
I
,
i
),
a
(
o
,
n
,
W
,
i
)):(
o
++
,
l
.
call
(
e
,
a
(
o
,
n
,
I
,
i
),
a
(
o
,
n
,
W
,
i
),
a
(
o
,
n
,
I
,
n
.
notifyWith
))):(
r
!==
I
&&
(
s
=
void
0
,
u
=
[
e
]),(
i
||
n
.
resolveWith
)(
s
,
u
))}},
c
=
i
?
l
:
function
(){
try
{
l
()}
catch
(
e
){
w
.
Deferred
.
exceptionHook
&&
w
.
Deferred
.
exceptionHook
(
e
,
c
.
stackTrace
),
t
+
1
>=
o
&&
(
r
!==
W
&&
(
s
=
void
0
,
u
=
[
e
]),
n
.
rejectWith
(
s
,
u
))}};
t
?
c
():(
w
.
Deferred
.
getStackHook
&&
(
c
.
stackTrace
=
w
.
Deferred
.
getStackHook
()),
e
.
setTimeout
(
c
))}}
return
w
.
Deferred
(
function
(
e
){
n
[
0
][
3
].
add
(
a
(
0
,
e
,
g
(
i
)?
i
:
I
,
e
.
notifyWith
)),
n
[
1
][
3
].
add
(
a
(
0
,
e
,
g
(
t
)?
t
:
I
)),
n
[
2
][
3
].
add
(
a
(
0
,
e
,
g
(
r
)?
r
:
W
))}).
promise
()},
promise
:
function
(
e
){
return
null
!=
e
?
w
.
extend
(
e
,
i
):
i
}},
o
=
{};
return
w
.
each
(
n
,
function
(
e
,
t
){
var
a
=
t
[
2
],
s
=
t
[
5
];
i
[
t
[
1
]]
=
a
.
add
,
s
&&
a
.
add
(
function
(){
r
=
s
},
n
[
3
-
e
][
2
].
disable
,
n
[
3
-
e
][
3
].
disable
,
n
[
0
][
2
].
lock
,
n
[
0
][
3
].
lock
),
a
.
add
(
t
[
3
].
fire
),
o
[
t
[
0
]]
=
function
(){
return
o
[
t
[
0
]
+
"With"
](
this
===
o
?
void
0
:
this
,
arguments
),
this
},
o
[
t
[
0
]
+
"With"
]
=
a
.
fireWith
}),
i
.
promise
(
o
),
t
&&
t
.
call
(
o
,
o
),
o
},
when
:
function
(
e
){
var
t
=
arguments
.
length
,
n
=
t
,
r
=
Array
(
n
),
i
=
o
.
call
(
arguments
),
a
=
w
.
Deferred
(),
s
=
function
(
e
){
return
function
(
n
){
r
[
e
]
=
this
,
i
[
e
]
=
arguments
.
length
>
1
?
o
.
call
(
arguments
):
n
,
--
t
||
a
.
resolveWith
(
r
,
i
)}};
if
(
t
<=
1
&&
(
$
(
e
,
a
.
done
(
s
(
n
)).
resolve
,
a
.
reject
,
!
t
),
"pending"
===
a
.
state
()
||
g
(
i
[
n
]
&&
i
[
n
].
then
)))
return
a
.
then
();
while
(
n
--
)
$
(
i
[
n
],
s
(
n
),
a
.
reject
);
return
a
.
promise
()}});
var
B
=
/^
(
Eval|Internal|Range|Reference|Syntax|Type|URI
)
Error$/
;
w
.
Deferred
.
exceptionHook
=
function
(
t
,
n
){
e
.
console
&&
e
.
console
.
warn
&&
t
&&
B
.
test
(
t
.
name
)
&&
e
.
console
.
warn
(
"jQuery.Deferred exception: "
+
t
.
message
,
t
.
stack
,
n
)},
w
.
readyException
=
function
(
t
){
e
.
setTimeout
(
function
(){
throw
t
})};
var
F
=
w
.
Deferred
();
w
.
fn
.
ready
=
function
(
e
){
return
F
.
then
(
e
)[
"catch"
](
function
(
e
){
w
.
readyException
(
e
)}),
this
},
w
.
extend
({
isReady
:
!
1
,
readyWait
:
1
,
ready
:
function
(
e
){(
!
0
===
e
?
--
w
.
readyWait
:
w
.
isReady
)
||
(
w
.
isReady
=!
0
,
!
0
!==
e
&&--
w
.
readyWait
>
0
||
F
.
resolveWith
(
r
,[
w
]))}}),
w
.
ready
.
then
=
F
.
then
;
function
_
(){
r
.
removeEventListener
(
"DOMContentLoaded"
,
_
),
e
.
removeEventListener
(
"load"
,
_
),
w
.
ready
()}
"complete"
===
r
.
readyState
||
"loading"
!==
r
.
readyState
&&!
r
.
documentElement
.
doScroll
?
e
.
setTimeout
(
w
.
ready
):(
r
.
addEventListener
(
"DOMContentLoaded"
,
_
),
e
.
addEventListener
(
"load"
,
_
));
var
z
=
function
(
e
,
t
,
n
,
r
,
i
,
o
,
a
){
var
s
=
0
,
u
=
e
.
length
,
l
=
null
==
n
;
if
(
"object"
===
x
(
n
)){
i
=!
0
;
for
(
s
in
n
)
z
(
e
,
t
,
s
,
n
[
s
],
!
0
,
o
,
a
)}
else
if
(
void
0
!==
r
&&
(
i
=!
0
,
g
(
r
)
||
(
a
=!
0
),
l
&&
(
a
?(
t
.
call
(
e
,
r
),
t
=
null
):(
l
=
t
,
t
=
function
(
e
,
t
,
n
){
return
l
.
call
(
w
(
e
),
n
)})),
t
))
for
(;
s
<
u
;
s
++
)
t
(
e
[
s
],
n
,
a
?
r
:
r
.
call
(
e
[
s
],
s
,
t
(
e
[
s
],
n
)));
return
i
?
e
:
l
?
t
.
call
(
e
):
u
?
t
(
e
[
0
],
n
):
o
},
X
=
/^-ms-/
,
U
=
/-
([
a-z
])
/g
;
function
V
(
e
,
t
){
return
t
.
toUpperCase
()}
function
G
(
e
){
return
e
.
replace
(
X
,
"ms-"
).
replace
(
U
,
V
)}
var
Y
=
function
(
e
){
return
1
===
e
.
nodeType
||
9
===
e
.
nodeType
||!+
e
.
nodeType
};
function
Q
(){
this
.
expando
=
w
.
expando
+
Q
.
uid
++
}
Q
.
uid
=
1
,
Q
.
prototype
=
{
cache
:
function
(
e
){
var
t
=
e
[
this
.
expando
];
return
t
||
(
t
=
{},
Y
(
e
)
&&
(
e
.
nodeType
?
e
[
this
.
expando
]
=
t
:
Object
.
defineProperty
(
e
,
this
.
expando
,{
value
:
t
,
configurable
:
!
0
}))),
t
},
set
:
function
(
e
,
t
,
n
){
var
r
,
i
=
this
.
cache
(
e
);
if
(
"string"
==
typeof
t
)
i
[
G
(
t
)]
=
n
;
else
for
(
r
in
t
)
i
[
G
(
r
)]
=
t
[
r
];
return
i
},
get
:
function
(
e
,
t
){
return
void
0
===
t
?
this
.
cache
(
e
):
e
[
this
.
expando
]
&&
e
[
this
.
expando
][
G
(
t
)]},
access
:
function
(
e
,
t
,
n
){
return
void
0
===
t
||
t
&&
"string"
==
typeof
t
&&
void
0
===
n
?
this
.
get
(
e
,
t
):(
this
.
set
(
e
,
t
,
n
),
void
0
!==
n
?
n
:
t
)},
remove
:
function
(
e
,
t
){
var
n
,
r
=
e
[
this
.
expando
];
if
(
void
0
!==
r
){
if
(
void
0
!==
t
){
n
=
(
t
=
Array
.
isArray
(
t
)?
t
.
map
(
G
):(
t
=
G
(
t
))
in
r
?[
t
]:
t
.
match
(
M
)
||
[]).
length
;
while
(
n
--
)
delete
r
[
t
[
n
]]}(
void
0
===
t
||
w
.
isEmptyObject
(
r
))
&&
(
e
.
nodeType
?
e
[
this
.
expando
]
=
void
0
:
delete
e
[
this
.
expando
])}},
hasData
:
function
(
e
){
var
t
=
e
[
this
.
expando
];
return
void
0
!==
t
&&!
w
.
isEmptyObject
(
t
)}};
var
J
=
new
Q
,
K
=
new
Q
,
Z
=
/^
(?:\{[\w\W]
*
\}
|
\[[\w\W]
*
\])
$/
,
ee
=
/
[
A-Z
]
/g
;
function
te
(
e
){
return
"true"
===
e
||
"false"
!==
e
&&
(
"null"
===
e
?
null
:
e
===+
e
+
""
?
+
e
:
Z
.
test
(
e
)?
JSON
.
parse
(
e
):
e
)}
function
ne
(
e
,
t
,
n
){
var
r
;
if
(
void
0
===
n
&&
1
===
e
.
nodeType
)
if
(
r
=
"data-"
+
t
.
replace
(
ee
,
"-$&"
).
toLowerCase
(),
"string"
==
typeof
(
n
=
e
.
getAttribute
(
r
))){
try
{
n
=
te
(
n
)}
catch
(
e
){}
K
.
set
(
e
,
t
,
n
)}
else
n
=
void
0
;
return
n
}
w
.
extend
({
hasData
:
function
(
e
){
return
K
.
hasData
(
e
)
||
J
.
hasData
(
e
)},
data
:
function
(
e
,
t
,
n
){
return
K
.
access
(
e
,
t
,
n
)},
removeData
:
function
(
e
,
t
){
K
.
remove
(
e
,
t
)},
_data
:
function
(
e
,
t
,
n
){
return
J
.
access
(
e
,
t
,
n
)},
_removeData
:
function
(
e
,
t
){
J
.
remove
(
e
,
t
)}}),
w
.
fn
.
extend
({
data
:
function
(
e
,
t
){
var
n
,
r
,
i
,
o
=
this
[
0
],
a
=
o
&&
o
.
attributes
;
if
(
void
0
===
e
){
if
(
this
.
length
&&
(
i
=
K
.
get
(
o
),
1
===
o
.
nodeType
&&!
J
.
get
(
o
,
"hasDataAttrs"
))){
n
=
a
.
length
;
while
(
n
--
)
a
[
n
]
&&
0
===
(
r
=
a
[
n
].
name
).
indexOf
(
"data-"
)
&&
(
r
=
G
(
r
.
slice
(
5
)),
ne
(
o
,
r
,
i
[
r
]));
J
.
set
(
o
,
"hasDataAttrs"
,
!
0
)}
return
i
}
return
"object"
==
typeof
e
?
this
.
each
(
function
(){
K
.
set
(
this
,
e
)}):
z
(
this
,
function
(
t
){
var
n
;
if
(
o
&&
void
0
===
t
){
if
(
void
0
!==
(
n
=
K
.
get
(
o
,
e
)))
return
n
;
if
(
void
0
!==
(
n
=
ne
(
o
,
e
)))
return
n
}
else
this
.
each
(
function
(){
K
.
set
(
this
,
e
,
t
)})},
null
,
t
,
arguments
.
length
>
1
,
null
,
!
0
)},
removeData
:
function
(
e
){
return
this
.
each
(
function
(){
K
.
remove
(
this
,
e
)})}}),
w
.
extend
({
queue
:
function
(
e
,
t
,
n
){
var
r
;
if
(
e
)
return
t
=
(
t
||
"fx"
)
+
"queue"
,
r
=
J
.
get
(
e
,
t
),
n
&&
(
!
r
||
Array
.
isArray
(
n
)?
r
=
J
.
access
(
e
,
t
,
w
.
makeArray
(
n
)):
r
.
push
(
n
)),
r
||
[]},
dequeue
:
function
(
e
,
t
){
t
=
t
||
"fx"
;
var
n
=
w
.
queue
(
e
,
t
),
r
=
n
.
length
,
i
=
n
.
shift
(),
o
=
w
.
_queueHooks
(
e
,
t
),
a
=
function
(){
w
.
dequeue
(
e
,
t
)};
"inprogress"
===
i
&&
(
i
=
n
.
shift
(),
r
--
),
i
&&
(
"fx"
===
t
&&
n
.
unshift
(
"inprogress"
),
delete
o
.
stop
,
i
.
call
(
e
,
a
,
o
)),
!
r
&&
o
&&
o
.
empty
.
fire
()},
_queueHooks
:
function
(
e
,
t
){
var
n
=
t
+
"queueHooks"
;
return
J
.
get
(
e
,
n
)
||
J
.
access
(
e
,
n
,{
empty
:
w
.
Callbacks
(
"once memory"
).
add
(
function
(){
J
.
remove
(
e
,[
t
+
"queue"
,
n
])})})}}),
w
.
fn
.
extend
({
queue
:
function
(
e
,
t
){
var
n
=
2
;
return
"string"
!=
typeof
e
&&
(
t
=
e
,
e
=
"fx"
,
n
--
),
arguments
.
length
<
n
?
w
.
queue
(
this
[
0
],
e
):
void
0
===
t
?
this
:
this
.
each
(
function
(){
var
n
=
w
.
queue
(
this
,
e
,
t
);
w
.
_queueHooks
(
this
,
e
),
"fx"
===
e
&&
"inprogress"
!==
n
[
0
]
&&
w
.
dequeue
(
this
,
e
)})},
dequeue
:
function
(
e
){
return
this
.
each
(
function
(){
w
.
dequeue
(
this
,
e
)})},
clearQueue
:
function
(
e
){
return
this
.
queue
(
e
||
"fx"
,[])},
promise
:
function
(
e
,
t
){
var
n
,
r
=
1
,
i
=
w
.
Deferred
(),
o
=
this
,
a
=
this
.
length
,
s
=
function
(){
--
r
||
i
.
resolveWith
(
o
,[
o
])};
"string"
!=
typeof
e
&&
(
t
=
e
,
e
=
void
0
),
e
=
e
||
"fx"
;
while
(
a
--
)(
n
=
J
.
get
(
o
[
a
],
e
+
"queueHooks"
))
&&
n
.
empty
&&
(
r
++
,
n
.
empty
.
add
(
s
));
return
s
(),
i
.
promise
(
t
)}});
var
re
=
/
[
+-
]?(?:\d
*
\.
|
)\d
+
(?:[
eE
][
+-
]?\d
+|
)
/
.
source
,
ie
=
new
RegExp
(
"^(?:([+-])=|)("
+
re
+
")([a-z%]*)$"
,
"i"
),
oe
=
[
"Top"
,
"Right"
,
"Bottom"
,
"Left"
],
ae
=
function
(
e
,
t
){
return
"none"
===
(
e
=
t
||
e
).
style
.
display
||
""
===
e
.
style
.
display
&&
w
.
contains
(
e
.
ownerDocument
,
e
)
&&
"none"
===
w
.
css
(
e
,
"display"
)},
se
=
function
(
e
,
t
,
n
,
r
){
var
i
,
o
,
a
=
{};
for
(
o
in
t
)
a
[
o
]
=
e
.
style
[
o
],
e
.
style
[
o
]
=
t
[
o
];
i
=
n
.
apply
(
e
,
r
||
[]);
for
(
o
in
t
)
e
.
style
[
o
]
=
a
[
o
];
return
i
};
function
ue
(
e
,
t
,
n
,
r
){
var
i
,
o
,
a
=
20
,
s
=
r
?
function
(){
return
r
.
cur
()}:
function
(){
return
w
.
css
(
e
,
t
,
""
)},
u
=
s
(),
l
=
n
&&
n
[
3
]
||
(
w
.
cssNumber
[
t
]?
""
:
"px"
),
c
=
(
w
.
cssNumber
[
t
]
||
"px"
!==
l
&&+
u
)
&&
ie
.
exec
(
w
.
css
(
e
,
t
));
if
(
c
&&
c
[
3
]
!==
l
){
u
/=
2
,
l
=
l
||
c
[
3
],
c
=+
u
||
1
;
while
(
a
--
)
w
.
style
(
e
,
t
,
c
+
l
),(
1
-
o
)
*
(
1
-
(
o
=
s
()
/
u
||
.
5
))
<=
0
&&
(
a
=
0
),
c
/=
o
;
c
*=
2
,
w
.
style
(
e
,
t
,
c
+
l
),
n
=
n
||
[]}
return
n
&&
(
c
=+
c
||+
u
||
0
,
i
=
n
[
1
]?
c
+
(
n
[
1
]
+
1
)
*
n
[
2
]:
+
n
[
2
],
r
&&
(
r
.
unit
=
l
,
r
.
start
=
c
,
r
.
end
=
i
)),
i
}
var
le
=
{};
function
ce
(
e
){
var
t
,
n
=
e
.
ownerDocument
,
r
=
e
.
nodeName
,
i
=
le
[
r
];
return
i
||
(
t
=
n
.
body
.
appendChild
(
n
.
createElement
(
r
)),
i
=
w
.
css
(
t
,
"display"
),
t
.
parentNode
.
removeChild
(
t
),
"none"
===
i
&&
(
i
=
"block"
),
le
[
r
]
=
i
,
i
)}
function
fe
(
e
,
t
){
for
(
var
n
,
r
,
i
=
[],
o
=
0
,
a
=
e
.
length
;
o
<
a
;
o
++
)(
r
=
e
[
o
]).
style
&&
(
n
=
r
.
style
.
display
,
t
?(
"none"
===
n
&&
(
i
[
o
]
=
J
.
get
(
r
,
"display"
)
||
null
,
i
[
o
]
||
(
r
.
style
.
display
=
""
)),
""
===
r
.
style
.
display
&&
ae
(
r
)
&&
(
i
[
o
]
=
ce
(
r
))):
"none"
!==
n
&&
(
i
[
o
]
=
"none"
,
J
.
set
(
r
,
"display"
,
n
)));
for
(
o
=
0
;
o
<
a
;
o
++
)
null
!=
i
[
o
]
&&
(
e
[
o
].
style
.
display
=
i
[
o
]);
return
e
}
w
.
fn
.
extend
({
show
:
function
(){
return
fe
(
this
,
!
0
)},
hide
:
function
(){
return
fe
(
this
)},
toggle
:
function
(
e
){
return
"boolean"
==
typeof
e
?
e
?
this
.
show
():
this
.
hide
():
this
.
each
(
function
(){
ae
(
this
)?
w
(
this
).
show
():
w
(
this
).
hide
()})}});
var
pe
=
/^
(?:
checkbox|radio
)
$/i
,
de
=
/<
([
a-z
][^\/\0
>
\x
20
\t\r\n\f]
+
)
/i
,
he
=
/^$|^module$|
\/(?:
java|ecma
)
script/i
,
ge
=
{
option
:[
1
,
"<select multiple='multiple'>"
,
"</select>"
],
thead
:[
1
,
"<table>"
,
"</table>"
],
col
:[
2
,
"<table><colgroup>"
,
"</colgroup></table>"
],
tr
:[
2
,
"<table><tbody>"
,
"</tbody></table>"
],
td
:[
3
,
"<table><tbody><tr>"
,
"</tr></tbody></table>"
],
_default
:[
0
,
""
,
""
]};
ge
.
optgroup
=
ge
.
option
,
ge
.
tbody
=
ge
.
tfoot
=
ge
.
colgroup
=
ge
.
caption
=
ge
.
thead
,
ge
.
th
=
ge
.
td
;
function
ye
(
e
,
t
){
var
n
;
return
n
=
"undefined"
!=
typeof
e
.
getElementsByTagName
?
e
.
getElementsByTagName
(
t
||
"*"
):
"undefined"
!=
typeof
e
.
querySelectorAll
?
e
.
querySelectorAll
(
t
||
"*"
):[],
void
0
===
t
||
t
&&
N
(
e
,
t
)?
w
.
merge
([
e
],
n
):
n
}
function
ve
(
e
,
t
){
for
(
var
n
=
0
,
r
=
e
.
length
;
n
<
r
;
n
++
)
J
.
set
(
e
[
n
],
"globalEval"
,
!
t
||
J
.
get
(
t
[
n
],
"globalEval"
))}
var
me
=
/<|&#
?\w
+;/
;
function
xe
(
e
,
t
,
n
,
r
,
i
){
for
(
var
o
,
a
,
s
,
u
,
l
,
c
,
f
=
t
.
createDocumentFragment
(),
p
=
[],
d
=
0
,
h
=
e
.
length
;
d
<
h
;
d
++
)
if
((
o
=
e
[
d
])
||
0
===
o
)
if
(
"object"
===
x
(
o
))
w
.
merge
(
p
,
o
.
nodeType
?[
o
]:
o
);
else
if
(
me
.
test
(
o
)){
a
=
a
||
f
.
appendChild
(
t
.
createElement
(
"div"
)),
s
=
(
de
.
exec
(
o
)
||
[
""
,
""
])[
1
].
toLowerCase
(),
u
=
ge
[
s
]
||
ge
.
_default
,
a
.
innerHTML
=
u
[
1
]
+
w
.
htmlPrefilter
(
o
)
+
u
[
2
],
c
=
u
[
0
];
while
(
c
--
)
a
=
a
.
lastChild
;
w
.
merge
(
p
,
a
.
childNodes
),(
a
=
f
.
firstChild
).
textContent
=
""
}
else
p
.
push
(
t
.
createTextNode
(
o
));
f
.
textContent
=
""
,
d
=
0
;
while
(
o
=
p
[
d
++
])
if
(
r
&&
w
.
inArray
(
o
,
r
)
>-
1
)
i
&&
i
.
push
(
o
);
else
if
(
l
=
w
.
contains
(
o
.
ownerDocument
,
o
),
a
=
ye
(
f
.
appendChild
(
o
),
"script"
),
l
&&
ve
(
a
),
n
){
c
=
0
;
while
(
o
=
a
[
c
++
])
he
.
test
(
o
.
type
||
""
)
&&
n
.
push
(
o
)}
return
f
}
!
function
(){
var
e
=
r
.
createDocumentFragment
().
appendChild
(
r
.
createElement
(
"div"
)),
t
=
r
.
createElement
(
"input"
);
t
.
setAttribute
(
"type"
,
"radio"
),
t
.
setAttribute
(
"checked"
,
"checked"
),
t
.
setAttribute
(
"name"
,
"t"
),
e
.
appendChild
(
t
),
h
.
checkClone
=
e
.
cloneNode
(
!
0
).
cloneNode
(
!
0
).
lastChild
.
checked
,
e
.
innerHTML
=
"<textarea>x</textarea>"
,
h
.
noCloneChecked
=!!
e
.
cloneNode
(
!
0
).
lastChild
.
defaultValue
}();
var
be
=
r
.
documentElement
,
we
=
/^key/
,
Te
=
/^
(?:
mouse|pointer|contextmenu|drag|drop
)
|click/
,
Ce
=
/^
([^
.
]
*
)(?:\.(
.+
)
|
)
/
;
function
Ee
(){
return
!
0
}
function
ke
(){
return
!
1
}
function
Se
(){
try
{
return
r
.
activeElement
}
catch
(
e
){}}
function
De
(
e
,
t
,
n
,
r
,
i
,
o
){
var
a
,
s
;
if
(
"object"
==
typeof
t
){
"string"
!=
typeof
n
&&
(
r
=
r
||
n
,
n
=
void
0
);
for
(
s
in
t
)
De
(
e
,
s
,
n
,
r
,
t
[
s
],
o
);
return
e
}
if
(
null
==
r
&&
null
==
i
?(
i
=
n
,
r
=
n
=
void
0
):
null
==
i
&&
(
"string"
==
typeof
n
?(
i
=
r
,
r
=
void
0
):(
i
=
r
,
r
=
n
,
n
=
void
0
)),
!
1
===
i
)
i
=
ke
;
else
if
(
!
i
)
return
e
;
return
1
===
o
&&
(
a
=
i
,(
i
=
function
(
e
){
return
w
().
off
(
e
),
a
.
apply
(
this
,
arguments
)}).
guid
=
a
.
guid
||
(
a
.
guid
=
w
.
guid
++
)),
e
.
each
(
function
(){
w
.
event
.
add
(
this
,
t
,
i
,
r
,
n
)})}
w
.
event
=
{
global
:{},
add
:
function
(
e
,
t
,
n
,
r
,
i
){
var
o
,
a
,
s
,
u
,
l
,
c
,
f
,
p
,
d
,
h
,
g
,
y
=
J
.
get
(
e
);
if
(
y
){
n
.
handler
&&
(
n
=
(
o
=
n
).
handler
,
i
=
o
.
selector
),
i
&&
w
.
find
.
matchesSelector
(
be
,
i
),
n
.
guid
||
(
n
.
guid
=
w
.
guid
++
),(
u
=
y
.
events
)
||
(
u
=
y
.
events
=
{}),(
a
=
y
.
handle
)
||
(
a
=
y
.
handle
=
function
(
t
){
return
"undefined"
!=
typeof
w
&&
w
.
event
.
triggered
!==
t
.
type
?
w
.
event
.
dispatch
.
apply
(
e
,
arguments
):
void
0
}),
l
=
(
t
=
(
t
||
""
).
match
(
M
)
||
[
""
]).
length
;
while
(
l
--
)
d
=
g
=
(
s
=
Ce
.
exec
(
t
[
l
])
||
[])[
1
],
h
=
(
s
[
2
]
||
""
).
split
(
"."
).
sort
(),
d
&&
(
f
=
w
.
event
.
special
[
d
]
||
{},
d
=
(
i
?
f
.
delegateType
:
f
.
bindType
)
||
d
,
f
=
w
.
event
.
special
[
d
]
||
{},
c
=
w
.
extend
({
type
:
d
,
origType
:
g
,
data
:
r
,
handler
:
n
,
guid
:
n
.
guid
,
selector
:
i
,
needsContext
:
i
&&
w
.
expr
.
match
.
needsContext
.
test
(
i
),
namespace
:
h
.
join
(
"."
)},
o
),(
p
=
u
[
d
])
||
((
p
=
u
[
d
]
=
[]).
delegateCount
=
0
,
f
.
setup
&&!
1
!==
f
.
setup
.
call
(
e
,
r
,
h
,
a
)
||
e
.
addEventListener
&&
e
.
addEventListener
(
d
,
a
)),
f
.
add
&&
(
f
.
add
.
call
(
e
,
c
),
c
.
handler
.
guid
||
(
c
.
handler
.
guid
=
n
.
guid
)),
i
?
p
.
splice
(
p
.
delegateCount
++
,
0
,
c
):
p
.
push
(
c
),
w
.
event
.
global
[
d
]
=!
0
)}},
remove
:
function
(
e
,
t
,
n
,
r
,
i
){
var
o
,
a
,
s
,
u
,
l
,
c
,
f
,
p
,
d
,
h
,
g
,
y
=
J
.
hasData
(
e
)
&&
J
.
get
(
e
);
if
(
y
&&
(
u
=
y
.
events
)){
l
=
(
t
=
(
t
||
""
).
match
(
M
)
||
[
""
]).
length
;
while
(
l
--
)
if
(
s
=
Ce
.
exec
(
t
[
l
])
||
[],
d
=
g
=
s
[
1
],
h
=
(
s
[
2
]
||
""
).
split
(
"."
).
sort
(),
d
){
f
=
w
.
event
.
special
[
d
]
||
{},
p
=
u
[
d
=
(
r
?
f
.
delegateType
:
f
.
bindType
)
||
d
]
||
[],
s
=
s
[
2
]
&&
new
RegExp
(
"(^|
\\
.)"
+
h
.
join
(
"
\\
.(?:.*
\\
.|)"
)
+
"(
\\
.|$)"
),
a
=
o
=
p
.
length
;
while
(
o
--
)
c
=
p
[
o
],
!
i
&&
g
!==
c
.
origType
||
n
&&
n
.
guid
!==
c
.
guid
||
s
&&!
s
.
test
(
c
.
namespace
)
||
r
&&
r
!==
c
.
selector
&&
(
"**"
!==
r
||!
c
.
selector
)
||
(
p
.
splice
(
o
,
1
),
c
.
selector
&&
p
.
delegateCount
--
,
f
.
remove
&&
f
.
remove
.
call
(
e
,
c
));
a
&&!
p
.
length
&&
(
f
.
teardown
&&!
1
!==
f
.
teardown
.
call
(
e
,
h
,
y
.
handle
)
||
w
.
removeEvent
(
e
,
d
,
y
.
handle
),
delete
u
[
d
])}
else
for
(
d
in
u
)
w
.
event
.
remove
(
e
,
d
+
t
[
l
],
n
,
r
,
!
0
);
w
.
isEmptyObject
(
u
)
&&
J
.
remove
(
e
,
"handle events"
)}},
dispatch
:
function
(
e
){
var
t
=
w
.
event
.
fix
(
e
),
n
,
r
,
i
,
o
,
a
,
s
,
u
=
new
Array
(
arguments
.
length
),
l
=
(
J
.
get
(
this
,
"events"
)
||
{})[
t
.
type
]
||
[],
c
=
w
.
event
.
special
[
t
.
type
]
||
{};
for
(
u
[
0
]
=
t
,
n
=
1
;
n
<
arguments
.
length
;
n
++
)
u
[
n
]
=
arguments
[
n
];
if
(
t
.
delegateTarget
=
this
,
!
c
.
preDispatch
||!
1
!==
c
.
preDispatch
.
call
(
this
,
t
)){
s
=
w
.
event
.
handlers
.
call
(
this
,
t
,
l
),
n
=
0
;
while
((
o
=
s
[
n
++
])
&&!
t
.
isPropagationStopped
()){
t
.
currentTarget
=
o
.
elem
,
r
=
0
;
while
((
a
=
o
.
handlers
[
r
++
])
&&!
t
.
isImmediatePropagationStopped
())
t
.
rnamespace
&&!
t
.
rnamespace
.
test
(
a
.
namespace
)
||
(
t
.
handleObj
=
a
,
t
.
data
=
a
.
data
,
void
0
!==
(
i
=
((
w
.
event
.
special
[
a
.
origType
]
||
{}).
handle
||
a
.
handler
).
apply
(
o
.
elem
,
u
))
&&!
1
===
(
t
.
result
=
i
)
&&
(
t
.
preventDefault
(),
t
.
stopPropagation
()))}
return
c
.
postDispatch
&&
c
.
postDispatch
.
call
(
this
,
t
),
t
.
result
}},
handlers
:
function
(
e
,
t
){
var
n
,
r
,
i
,
o
,
a
,
s
=
[],
u
=
t
.
delegateCount
,
l
=
e
.
target
;
if
(
u
&&
l
.
nodeType
&&!
(
"click"
===
e
.
type
&&
e
.
button
>=
1
))
for
(;
l
!==
this
;
l
=
l
.
parentNode
||
this
)
if
(
1
===
l
.
nodeType
&&
(
"click"
!==
e
.
type
||!
0
!==
l
.
disabled
)){
for
(
o
=
[],
a
=
{},
n
=
0
;
n
<
u
;
n
++
)
void
0
===
a
[
i
=
(
r
=
t
[
n
]).
selector
+
" "
]
&&
(
a
[
i
]
=
r
.
needsContext
?
w
(
i
,
this
).
index
(
l
)
>-
1
:
w
.
find
(
i
,
this
,
null
,[
l
]).
length
),
a
[
i
]
&&
o
.
push
(
r
);
o
.
length
&&
s
.
push
({
elem
:
l
,
handlers
:
o
})}
return
l
=
this
,
u
<
t
.
length
&&
s
.
push
({
elem
:
l
,
handlers
:
t
.
slice
(
u
)}),
s
},
addProp
:
function
(
e
,
t
){
Object
.
defineProperty
(
w
.
Event
.
prototype
,
e
,{
enumerable
:
!
0
,
configurable
:
!
0
,
get
:
g
(
t
)?
function
(){
if
(
this
.
originalEvent
)
return
t
(
this
.
originalEvent
)}:
function
(){
if
(
this
.
originalEvent
)
return
this
.
originalEvent
[
e
]},
set
:
function
(
t
){
Object
.
defineProperty
(
this
,
e
,{
enumerable
:
!
0
,
configurable
:
!
0
,
writable
:
!
0
,
value
:
t
})}})},
fix
:
function
(
e
){
return
e
[
w
.
expando
]?
e
:
new
w
.
Event
(
e
)},
special
:{
load
:{
noBubble
:
!
0
},
focus
:{
trigger
:
function
(){
if
(
this
!==
Se
()
&&
this
.
focus
)
return
this
.
focus
(),
!
1
},
delegateType
:
"focusin"
},
blur
:{
trigger
:
function
(){
if
(
this
===
Se
()
&&
this
.
blur
)
return
this
.
blur
(),
!
1
},
delegateType
:
"focusout"
},
click
:{
trigger
:
function
(){
if
(
"checkbox"
===
this
.
type
&&
this
.
click
&&
N
(
this
,
"input"
))
return
this
.
click
(),
!
1
},
_default
:
function
(
e
){
return
N
(
e
.
target
,
"a"
)}},
beforeunload
:{
postDispatch
:
function
(
e
){
void
0
!==
e
.
result
&&
e
.
originalEvent
&&
(
e
.
originalEvent
.
returnValue
=
e
.
result
)}}}},
w
.
removeEvent
=
function
(
e
,
t
,
n
){
e
.
removeEventListener
&&
e
.
removeEventListener
(
t
,
n
)},
w
.
Event
=
function
(
e
,
t
){
if
(
!
(
this
instanceof
w
.
Event
))
return
new
w
.
Event
(
e
,
t
);
e
&&
e
.
type
?(
this
.
originalEvent
=
e
,
this
.
type
=
e
.
type
,
this
.
isDefaultPrevented
=
e
.
defaultPrevented
||
void
0
===
e
.
defaultPrevented
&&!
1
===
e
.
returnValue
?
Ee
:
ke
,
this
.
target
=
e
.
target
&&
3
===
e
.
target
.
nodeType
?
e
.
target
.
parentNode
:
e
.
target
,
this
.
currentTarget
=
e
.
currentTarget
,
this
.
relatedTarget
=
e
.
relatedTarget
):
this
.
type
=
e
,
t
&&
w
.
extend
(
this
,
t
),
this
.
timeStamp
=
e
&&
e
.
timeStamp
||
Date
.
now
(),
this
[
w
.
expando
]
=!
0
},
w
.
Event
.
prototype
=
{
constructor
:
w
.
Event
,
isDefaultPrevented
:
ke
,
isPropagationStopped
:
ke
,
isImmediatePropagationStopped
:
ke
,
isSimulated
:
!
1
,
preventDefault
:
function
(){
var
e
=
this
.
originalEvent
;
this
.
isDefaultPrevented
=
Ee
,
e
&&!
this
.
isSimulated
&&
e
.
preventDefault
()},
stopPropagation
:
function
(){
var
e
=
this
.
originalEvent
;
this
.
isPropagationStopped
=
Ee
,
e
&&!
this
.
isSimulated
&&
e
.
stopPropagation
()},
stopImmediatePropagation
:
function
(){
var
e
=
this
.
originalEvent
;
this
.
isImmediatePropagationStopped
=
Ee
,
e
&&!
this
.
isSimulated
&&
e
.
stopImmediatePropagation
(),
this
.
stopPropagation
()}},
w
.
each
({
altKey
:
!
0
,
bubbles
:
!
0
,
cancelable
:
!
0
,
changedTouches
:
!
0
,
ctrlKey
:
!
0
,
detail
:
!
0
,
eventPhase
:
!
0
,
metaKey
:
!
0
,
pageX
:
!
0
,
pageY
:
!
0
,
shiftKey
:
!
0
,
view
:
!
0
,
"char"
:
!
0
,
charCode
:
!
0
,
key
:
!
0
,
keyCode
:
!
0
,
button
:
!
0
,
buttons
:
!
0
,
clientX
:
!
0
,
clientY
:
!
0
,
offsetX
:
!
0
,
offsetY
:
!
0
,
pointerId
:
!
0
,
pointerType
:
!
0
,
screenX
:
!
0
,
screenY
:
!
0
,
targetTouches
:
!
0
,
toElement
:
!
0
,
touches
:
!
0
,
which
:
function
(
e
){
var
t
=
e
.
button
;
return
null
==
e
.
which
&&
we
.
test
(
e
.
type
)?
null
!=
e
.
charCode
?
e
.
charCode
:
e
.
keyCode
:
!
e
.
which
&&
void
0
!==
t
&&
Te
.
test
(
e
.
type
)?
1
&
t
?
1
:
2
&
t
?
3
:
4
&
t
?
2
:
0
:
e
.
which
}},
w
.
event
.
addProp
),
w
.
each
({
mouseenter
:
"mouseover"
,
mouseleave
:
"mouseout"
,
pointerenter
:
"pointerover"
,
pointerleave
:
"pointerout"
},
function
(
e
,
t
){
w
.
event
.
special
[
e
]
=
{
delegateType
:
t
,
bindType
:
t
,
handle
:
function
(
e
){
var
n
,
r
=
this
,
i
=
e
.
relatedTarget
,
o
=
e
.
handleObj
;
return
i
&&
(
i
===
r
||
w
.
contains
(
r
,
i
))
||
(
e
.
type
=
o
.
origType
,
n
=
o
.
handler
.
apply
(
this
,
arguments
),
e
.
type
=
t
),
n
}}}),
w
.
fn
.
extend
({
on
:
function
(
e
,
t
,
n
,
r
){
return
De
(
this
,
e
,
t
,
n
,
r
)},
one
:
function
(
e
,
t
,
n
,
r
){
return
De
(
this
,
e
,
t
,
n
,
r
,
1
)},
off
:
function
(
e
,
t
,
n
){
var
r
,
i
;
if
(
e
&&
e
.
preventDefault
&&
e
.
handleObj
)
return
r
=
e
.
handleObj
,
w
(
e
.
delegateTarget
).
off
(
r
.
namespace
?
r
.
origType
+
"."
+
r
.
namespace
:
r
.
origType
,
r
.
selector
,
r
.
handler
),
this
;
if
(
"object"
==
typeof
e
){
for
(
i
in
e
)
this
.
off
(
i
,
t
,
e
[
i
]);
return
this
}
return
!
1
!==
t
&&
"function"
!=
typeof
t
||
(
n
=
t
,
t
=
void
0
),
!
1
===
n
&&
(
n
=
ke
),
this
.
each
(
function
(){
w
.
event
.
remove
(
this
,
e
,
n
,
t
)})}});
var
Ne
=
/<
(?!
area|br|col|embed|hr|img|input|link|meta|param
)(([
a-z
][^\/\0
>
\x
20
\t\r\n\f]
*
)[^
>
]
*
)\/
>/gi
,
Ae
=
/<script|<style|<link/i
,
je
=
/checked
\s
*
(?:[^
=
]
|=
\s
*.checked.
)
/i
,
qe
=
/^
\s
*<!
(?:\[
CDATA
\[
|--
)
|
(?:\]\]
|--
)
>
\s
*$/g
;
function
Le
(
e
,
t
){
return
N
(
e
,
"table"
)
&&
N
(
11
!==
t
.
nodeType
?
t
:
t
.
firstChild
,
"tr"
)?
w
(
e
).
children
(
"tbody"
)[
0
]
||
e
:
e
}
function
He
(
e
){
return
e
.
type
=
(
null
!==
e
.
getAttribute
(
"type"
))
+
"/"
+
e
.
type
,
e
}
function
Oe
(
e
){
return
"true/"
===
(
e
.
type
||
""
).
slice
(
0
,
5
)?
e
.
type
=
e
.
type
.
slice
(
5
):
e
.
removeAttribute
(
"type"
),
e
}
function
Pe
(
e
,
t
){
var
n
,
r
,
i
,
o
,
a
,
s
,
u
,
l
;
if
(
1
===
t
.
nodeType
){
if
(
J
.
hasData
(
e
)
&&
(
o
=
J
.
access
(
e
),
a
=
J
.
set
(
t
,
o
),
l
=
o
.
events
)){
delete
a
.
handle
,
a
.
events
=
{};
for
(
i
in
l
)
for
(
n
=
0
,
r
=
l
[
i
].
length
;
n
<
r
;
n
++
)
w
.
event
.
add
(
t
,
i
,
l
[
i
][
n
])}
K
.
hasData
(
e
)
&&
(
s
=
K
.
access
(
e
),
u
=
w
.
extend
({},
s
),
K
.
set
(
t
,
u
))}}
function
Me
(
e
,
t
){
var
n
=
t
.
nodeName
.
toLowerCase
();
"input"
===
n
&&
pe
.
test
(
e
.
type
)?
t
.
checked
=
e
.
checked
:
"input"
!==
n
&&
"textarea"
!==
n
||
(
t
.
defaultValue
=
e
.
defaultValue
)}
function
Re
(
e
,
t
,
n
,
r
){
t
=
a
.
apply
([],
t
);
var
i
,
o
,
s
,
u
,
l
,
c
,
f
=
0
,
p
=
e
.
length
,
d
=
p
-
1
,
y
=
t
[
0
],
v
=
g
(
y
);
if
(
v
||
p
>
1
&&
"string"
==
typeof
y
&&!
h
.
checkClone
&&
je
.
test
(
y
))
return
e
.
each
(
function
(
i
){
var
o
=
e
.
eq
(
i
);
v
&&
(
t
[
0
]
=
y
.
call
(
this
,
i
,
o
.
html
())),
Re
(
o
,
t
,
n
,
r
)});
if
(
p
&&
(
i
=
xe
(
t
,
e
[
0
].
ownerDocument
,
!
1
,
e
,
r
),
o
=
i
.
firstChild
,
1
===
i
.
childNodes
.
length
&&
(
i
=
o
),
o
||
r
)){
for
(
u
=
(
s
=
w
.
map
(
ye
(
i
,
"script"
),
He
)).
length
;
f
<
p
;
f
++
)
l
=
i
,
f
!==
d
&&
(
l
=
w
.
clone
(
l
,
!
0
,
!
0
),
u
&&
w
.
merge
(
s
,
ye
(
l
,
"script"
))),
n
.
call
(
e
[
f
],
l
,
f
);
if
(
u
)
for
(
c
=
s
[
s
.
length
-
1
].
ownerDocument
,
w
.
map
(
s
,
Oe
),
f
=
0
;
f
<
u
;
f
++
)
l
=
s
[
f
],
he
.
test
(
l
.
type
||
""
)
&&!
J
.
access
(
l
,
"globalEval"
)
&&
w
.
contains
(
c
,
l
)
&&
(
l
.
src
&&
"module"
!==
(
l
.
type
||
""
).
toLowerCase
()?
w
.
_evalUrl
&&
w
.
_evalUrl
(
l
.
src
):
m
(
l
.
textContent
.
replace
(
qe
,
""
),
c
,
l
))}
return
e
}
function
Ie
(
e
,
t
,
n
){
for
(
var
r
,
i
=
t
?
w
.
filter
(
t
,
e
):
e
,
o
=
0
;
null
!=
(
r
=
i
[
o
]);
o
++
)
n
||
1
!==
r
.
nodeType
||
w
.
cleanData
(
ye
(
r
)),
r
.
parentNode
&&
(
n
&&
w
.
contains
(
r
.
ownerDocument
,
r
)
&&
ve
(
ye
(
r
,
"script"
)),
r
.
parentNode
.
removeChild
(
r
));
return
e
}
w
.
extend
({
htmlPrefilter
:
function
(
e
){
return
e
.
replace
(
Ne
,
"<$1></$2>"
)},
clone
:
function
(
e
,
t
,
n
){
var
r
,
i
,
o
,
a
,
s
=
e
.
cloneNode
(
!
0
),
u
=
w
.
contains
(
e
.
ownerDocument
,
e
);
if
(
!
(
h
.
noCloneChecked
||
1
!==
e
.
nodeType
&&
11
!==
e
.
nodeType
||
w
.
isXMLDoc
(
e
)))
for
(
a
=
ye
(
s
),
r
=
0
,
i
=
(
o
=
ye
(
e
)).
length
;
r
<
i
;
r
++
)
Me
(
o
[
r
],
a
[
r
]);
if
(
t
)
if
(
n
)
for
(
o
=
o
||
ye
(
e
),
a
=
a
||
ye
(
s
),
r
=
0
,
i
=
o
.
length
;
r
<
i
;
r
++
)
Pe
(
o
[
r
],
a
[
r
]);
else
Pe
(
e
,
s
);
return
(
a
=
ye
(
s
,
"script"
)).
length
>
0
&&
ve
(
a
,
!
u
&&
ye
(
e
,
"script"
)),
s
},
cleanData
:
function
(
e
){
for
(
var
t
,
n
,
r
,
i
=
w
.
event
.
special
,
o
=
0
;
void
0
!==
(
n
=
e
[
o
]);
o
++
)
if
(
Y
(
n
)){
if
(
t
=
n
[
J
.
expando
]){
if
(
t
.
events
)
for
(
r
in
t
.
events
)
i
[
r
]?
w
.
event
.
remove
(
n
,
r
):
w
.
removeEvent
(
n
,
r
,
t
.
handle
);
n
[
J
.
expando
]
=
void
0
}
n
[
K
.
expando
]
&&
(
n
[
K
.
expando
]
=
void
0
)}}}),
w
.
fn
.
extend
({
detach
:
function
(
e
){
return
Ie
(
this
,
e
,
!
0
)},
remove
:
function
(
e
){
return
Ie
(
this
,
e
)},
text
:
function
(
e
){
return
z
(
this
,
function
(
e
){
return
void
0
===
e
?
w
.
text
(
this
):
this
.
empty
().
each
(
function
(){
1
!==
this
.
nodeType
&&
11
!==
this
.
nodeType
&&
9
!==
this
.
nodeType
||
(
this
.
textContent
=
e
)})},
null
,
e
,
arguments
.
length
)},
append
:
function
(){
return
Re
(
this
,
arguments
,
function
(
e
){
1
!==
this
.
nodeType
&&
11
!==
this
.
nodeType
&&
9
!==
this
.
nodeType
||
Le
(
this
,
e
).
appendChild
(
e
)})},
prepend
:
function
(){
return
Re
(
this
,
arguments
,
function
(
e
){
if
(
1
===
this
.
nodeType
||
11
===
this
.
nodeType
||
9
===
this
.
nodeType
){
var
t
=
Le
(
this
,
e
);
t
.
insertBefore
(
e
,
t
.
firstChild
)}})},
before
:
function
(){
return
Re
(
this
,
arguments
,
function
(
e
){
this
.
parentNode
&&
this
.
parentNode
.
insertBefore
(
e
,
this
)})},
after
:
function
(){
return
Re
(
this
,
arguments
,
function
(
e
){
this
.
parentNode
&&
this
.
parentNode
.
insertBefore
(
e
,
this
.
nextSibling
)})},
empty
:
function
(){
for
(
var
e
,
t
=
0
;
null
!=
(
e
=
this
[
t
]);
t
++
)
1
===
e
.
nodeType
&&
(
w
.
cleanData
(
ye
(
e
,
!
1
)),
e
.
textContent
=
""
);
return
this
},
clone
:
function
(
e
,
t
){
return
e
=
null
!=
e
&&
e
,
t
=
null
==
t
?
e
:
t
,
this
.
map
(
function
(){
return
w
.
clone
(
this
,
e
,
t
)})},
html
:
function
(
e
){
return
z
(
this
,
function
(
e
){
var
t
=
this
[
0
]
||
{},
n
=
0
,
r
=
this
.
length
;
if
(
void
0
===
e
&&
1
===
t
.
nodeType
)
return
t
.
innerHTML
;
if
(
"string"
==
typeof
e
&&!
Ae
.
test
(
e
)
&&!
ge
[(
de
.
exec
(
e
)
||
[
""
,
""
])[
1
].
toLowerCase
()]){
e
=
w
.
htmlPrefilter
(
e
);
try
{
for
(;
n
<
r
;
n
++
)
1
===
(
t
=
this
[
n
]
||
{}).
nodeType
&&
(
w
.
cleanData
(
ye
(
t
,
!
1
)),
t
.
innerHTML
=
e
);
t
=
0
}
catch
(
e
){}}
t
&&
this
.
empty
().
append
(
e
)},
null
,
e
,
arguments
.
length
)},
replaceWith
:
function
(){
var
e
=
[];
return
Re
(
this
,
arguments
,
function
(
t
){
var
n
=
this
.
parentNode
;
w
.
inArray
(
this
,
e
)
<
0
&&
(
w
.
cleanData
(
ye
(
this
)),
n
&&
n
.
replaceChild
(
t
,
this
))},
e
)}}),
w
.
each
({
appendTo
:
"append"
,
prependTo
:
"prepend"
,
insertBefore
:
"before"
,
insertAfter
:
"after"
,
replaceAll
:
"replaceWith"
},
function
(
e
,
t
){
w
.
fn
[
e
]
=
function
(
e
){
for
(
var
n
,
r
=
[],
i
=
w
(
e
),
o
=
i
.
length
-
1
,
a
=
0
;
a
<=
o
;
a
++
)
n
=
a
===
o
?
this
:
this
.
clone
(
!
0
),
w
(
i
[
a
])[
t
](
n
),
s
.
apply
(
r
,
n
.
get
());
return
this
.
pushStack
(
r
)}});
var
We
=
new
RegExp
(
"^("
+
re
+
")(?!px)[a-z%]+$"
,
"i"
),
$e
=
function
(
t
){
var
n
=
t
.
ownerDocument
.
defaultView
;
return
n
&&
n
.
opener
||
(
n
=
e
),
n
.
getComputedStyle
(
t
)},
Be
=
new
RegExp
(
oe
.
join
(
"|"
),
"i"
);
!
function
(){
function
t
(){
if
(
c
){
l
.
style
.
cssText
=
"position:absolute;left:-11111px;width:60px;margin-top:1px;padding:0;border:0"
,
c
.
style
.
cssText
=
"position:relative;display:block;box-sizing:border-box;overflow:scroll;margin:auto;border:1px;padding:1px;width:60%;top:1%"
,
be
.
appendChild
(
l
).
appendChild
(
c
);
var
t
=
e
.
getComputedStyle
(
c
);
i
=
"1%"
!==
t
.
top
,
u
=
12
===
n
(
t
.
marginLeft
),
c
.
style
.
right
=
"60%"
,
s
=
36
===
n
(
t
.
right
),
o
=
36
===
n
(
t
.
width
),
c
.
style
.
position
=
"absolute"
,
a
=
36
===
c
.
offsetWidth
||
"absolute"
,
be
.
removeChild
(
l
),
c
=
null
}}
function
n
(
e
){
return
Math
.
round
(
parseFloat
(
e
))}
var
i
,
o
,
a
,
s
,
u
,
l
=
r
.
createElement
(
"div"
),
c
=
r
.
createElement
(
"div"
);
c
.
style
&&
(
c
.
style
.
backgroundClip
=
"content-box"
,
c
.
cloneNode
(
!
0
).
style
.
backgroundClip
=
""
,
h
.
clearCloneStyle
=
"content-box"
===
c
.
style
.
backgroundClip
,
w
.
extend
(
h
,{
boxSizingReliable
:
function
(){
return
t
(),
o
},
pixelBoxStyles
:
function
(){
return
t
(),
s
},
pixelPosition
:
function
(){
return
t
(),
i
},
reliableMarginLeft
:
function
(){
return
t
(),
u
},
scrollboxSize
:
function
(){
return
t
(),
a
}}))}();
function
Fe
(
e
,
t
,
n
){
var
r
,
i
,
o
,
a
,
s
=
e
.
style
;
return
(
n
=
n
||
$e
(
e
))
&&
(
""
!==
(
a
=
n
.
getPropertyValue
(
t
)
||
n
[
t
])
||
w
.
contains
(
e
.
ownerDocument
,
e
)
||
(
a
=
w
.
style
(
e
,
t
)),
!
h
.
pixelBoxStyles
()
&&
We
.
test
(
a
)
&&
Be
.
test
(
t
)
&&
(
r
=
s
.
width
,
i
=
s
.
minWidth
,
o
=
s
.
maxWidth
,
s
.
minWidth
=
s
.
maxWidth
=
s
.
width
=
a
,
a
=
n
.
width
,
s
.
width
=
r
,
s
.
minWidth
=
i
,
s
.
maxWidth
=
o
)),
void
0
!==
a
?
a
+
""
:
a
}
function
_e
(
e
,
t
){
return
{
get
:
function
(){
if
(
!
e
())
return
(
this
.
get
=
t
).
apply
(
this
,
arguments
);
delete
this
.
get
}}}
var
ze
=
/^
(
none|table
(?!
-c
[
ea
])
.+
)
/
,
Xe
=
/^--/
,
Ue
=
{
position
:
"absolute"
,
visibility
:
"hidden"
,
display
:
"block"
},
Ve
=
{
letterSpacing
:
"0"
,
fontWeight
:
"400"
},
Ge
=
[
"Webkit"
,
"Moz"
,
"ms"
],
Ye
=
r
.
createElement
(
"div"
).
style
;
function
Qe
(
e
){
if
(
e
in
Ye
)
return
e
;
var
t
=
e
[
0
].
toUpperCase
()
+
e
.
slice
(
1
),
n
=
Ge
.
length
;
while
(
n
--
)
if
((
e
=
Ge
[
n
]
+
t
)
in
Ye
)
return
e
}
function
Je
(
e
){
var
t
=
w
.
cssProps
[
e
];
return
t
||
(
t
=
w
.
cssProps
[
e
]
=
Qe
(
e
)
||
e
),
t
}
function
Ke
(
e
,
t
,
n
){
var
r
=
ie
.
exec
(
t
);
return
r
?
Math
.
max
(
0
,
r
[
2
]
-
(
n
||
0
))
+
(
r
[
3
]
||
"px"
):
t
}
function
Ze
(
e
,
t
,
n
,
r
,
i
,
o
){
var
a
=
"width"
===
t
?
1
:
0
,
s
=
0
,
u
=
0
;
if
(
n
===
(
r
?
"border"
:
"content"
))
return
0
;
for
(;
a
<
4
;
a
+=
2
)
"margin"
===
n
&&
(
u
+=
w
.
css
(
e
,
n
+
oe
[
a
],
!
0
,
i
)),
r
?(
"content"
===
n
&&
(
u
-=
w
.
css
(
e
,
"padding"
+
oe
[
a
],
!
0
,
i
)),
"margin"
!==
n
&&
(
u
-=
w
.
css
(
e
,
"border"
+
oe
[
a
]
+
"Width"
,
!
0
,
i
))):(
u
+=
w
.
css
(
e
,
"padding"
+
oe
[
a
],
!
0
,
i
),
"padding"
!==
n
?
u
+=
w
.
css
(
e
,
"border"
+
oe
[
a
]
+
"Width"
,
!
0
,
i
):
s
+=
w
.
css
(
e
,
"border"
+
oe
[
a
]
+
"Width"
,
!
0
,
i
));
return
!
r
&&
o
>=
0
&&
(
u
+=
Math
.
max
(
0
,
Math
.
ceil
(
e
[
"offset"
+
t
[
0
].
toUpperCase
()
+
t
.
slice
(
1
)]
-
o
-
u
-
s
-
.
5
))),
u
}
function
et
(
e
,
t
,
n
){
var
r
=
$e
(
e
),
i
=
Fe
(
e
,
t
,
r
),
o
=
"border-box"
===
w
.
css
(
e
,
"boxSizing"
,
!
1
,
r
),
a
=
o
;
if
(
We
.
test
(
i
)){
if
(
!
n
)
return
i
;
i
=
"auto"
}
return
a
=
a
&&
(
h
.
boxSizingReliable
()
||
i
===
e
.
style
[
t
]),(
"auto"
===
i
||!
parseFloat
(
i
)
&&
"inline"
===
w
.
css
(
e
,
"display"
,
!
1
,
r
))
&&
(
i
=
e
[
"offset"
+
t
[
0
].
toUpperCase
()
+
t
.
slice
(
1
)],
a
=!
0
),(
i
=
parseFloat
(
i
)
||
0
)
+
Ze
(
e
,
t
,
n
||
(
o
?
"border"
:
"content"
),
a
,
r
,
i
)
+
"px"
}
w
.
extend
({
cssHooks
:{
opacity
:{
get
:
function
(
e
,
t
){
if
(
t
){
var
n
=
Fe
(
e
,
"opacity"
);
return
""
===
n
?
"1"
:
n
}}}},
cssNumber
:{
animationIterationCount
:
!
0
,
columnCount
:
!
0
,
fillOpacity
:
!
0
,
flexGrow
:
!
0
,
flexShrink
:
!
0
,
fontWeight
:
!
0
,
lineHeight
:
!
0
,
opacity
:
!
0
,
order
:
!
0
,
orphans
:
!
0
,
widows
:
!
0
,
zIndex
:
!
0
,
zoom
:
!
0
},
cssProps
:{},
style
:
function
(
e
,
t
,
n
,
r
){
if
(
e
&&
3
!==
e
.
nodeType
&&
8
!==
e
.
nodeType
&&
e
.
style
){
var
i
,
o
,
a
,
s
=
G
(
t
),
u
=
Xe
.
test
(
t
),
l
=
e
.
style
;
if
(
u
||
(
t
=
Je
(
s
)),
a
=
w
.
cssHooks
[
t
]
||
w
.
cssHooks
[
s
],
void
0
===
n
)
return
a
&&
"get"
in
a
&&
void
0
!==
(
i
=
a
.
get
(
e
,
!
1
,
r
))?
i
:
l
[
t
];
"string"
==
(
o
=
typeof
n
)
&&
(
i
=
ie
.
exec
(
n
))
&&
i
[
1
]
&&
(
n
=
ue
(
e
,
t
,
i
),
o
=
"number"
),
null
!=
n
&&
n
===
n
&&
(
"number"
===
o
&&
(
n
+=
i
&&
i
[
3
]
||
(
w
.
cssNumber
[
s
]?
""
:
"px"
)),
h
.
clearCloneStyle
||
""
!==
n
||
0
!==
t
.
indexOf
(
"background"
)
||
(
l
[
t
]
=
"inherit"
),
a
&&
"set"
in
a
&&
void
0
===
(
n
=
a
.
set
(
e
,
n
,
r
))
||
(
u
?
l
.
setProperty
(
t
,
n
):
l
[
t
]
=
n
))}},
css
:
function
(
e
,
t
,
n
,
r
){
var
i
,
o
,
a
,
s
=
G
(
t
);
return
Xe
.
test
(
t
)
||
(
t
=
Je
(
s
)),(
a
=
w
.
cssHooks
[
t
]
||
w
.
cssHooks
[
s
])
&&
"get"
in
a
&&
(
i
=
a
.
get
(
e
,
!
0
,
n
)),
void
0
===
i
&&
(
i
=
Fe
(
e
,
t
,
r
)),
"normal"
===
i
&&
t
in
Ve
&&
(
i
=
Ve
[
t
]),
""
===
n
||
n
?(
o
=
parseFloat
(
i
),
!
0
===
n
||
isFinite
(
o
)?
o
||
0
:
i
):
i
}}),
w
.
each
([
"height"
,
"width"
],
function
(
e
,
t
){
w
.
cssHooks
[
t
]
=
{
get
:
function
(
e
,
n
,
r
){
if
(
n
)
return
!
ze
.
test
(
w
.
css
(
e
,
"display"
))
||
e
.
getClientRects
().
length
&&
e
.
getBoundingClientRect
().
width
?
et
(
e
,
t
,
r
):
se
(
e
,
Ue
,
function
(){
return
et
(
e
,
t
,
r
)})},
set
:
function
(
e
,
n
,
r
){
var
i
,
o
=
$e
(
e
),
a
=
"border-box"
===
w
.
css
(
e
,
"boxSizing"
,
!
1
,
o
),
s
=
r
&&
Ze
(
e
,
t
,
r
,
a
,
o
);
return
a
&&
h
.
scrollboxSize
()
===
o
.
position
&&
(
s
-=
Math
.
ceil
(
e
[
"offset"
+
t
[
0
].
toUpperCase
()
+
t
.
slice
(
1
)]
-
parseFloat
(
o
[
t
])
-
Ze
(
e
,
t
,
"border"
,
!
1
,
o
)
-
.
5
)),
s
&&
(
i
=
ie
.
exec
(
n
))
&&
"px"
!==
(
i
[
3
]
||
"px"
)
&&
(
e
.
style
[
t
]
=
n
,
n
=
w
.
css
(
e
,
t
)),
Ke
(
e
,
n
,
s
)}}}),
w
.
cssHooks
.
marginLeft
=
_e
(
h
.
reliableMarginLeft
,
function
(
e
,
t
){
if
(
t
)
return
(
parseFloat
(
Fe
(
e
,
"marginLeft"
))
||
e
.
getBoundingClientRect
().
left
-
se
(
e
,{
marginLeft
:
0
},
function
(){
return
e
.
getBoundingClientRect
().
left
}))
+
"px"
}),
w
.
each
({
margin
:
""
,
padding
:
""
,
border
:
"Width"
},
function
(
e
,
t
){
w
.
cssHooks
[
e
+
t
]
=
{
expand
:
function
(
n
){
for
(
var
r
=
0
,
i
=
{},
o
=
"string"
==
typeof
n
?
n
.
split
(
" "
):[
n
];
r
<
4
;
r
++
)
i
[
e
+
oe
[
r
]
+
t
]
=
o
[
r
]
||
o
[
r
-
2
]
||
o
[
0
];
return
i
}},
"margin"
!==
e
&&
(
w
.
cssHooks
[
e
+
t
].
set
=
Ke
)}),
w
.
fn
.
extend
({
css
:
function
(
e
,
t
){
return
z
(
this
,
function
(
e
,
t
,
n
){
var
r
,
i
,
o
=
{},
a
=
0
;
if
(
Array
.
isArray
(
t
)){
for
(
r
=
$e
(
e
),
i
=
t
.
length
;
a
<
i
;
a
++
)
o
[
t
[
a
]]
=
w
.
css
(
e
,
t
[
a
],
!
1
,
r
);
return
o
}
return
void
0
!==
n
?
w
.
style
(
e
,
t
,
n
):
w
.
css
(
e
,
t
)},
e
,
t
,
arguments
.
length
>
1
)}});
function
tt
(
e
,
t
,
n
,
r
,
i
){
return
new
tt
.
prototype
.
init
(
e
,
t
,
n
,
r
,
i
)}
w
.
Tween
=
tt
,
tt
.
prototype
=
{
constructor
:
tt
,
init
:
function
(
e
,
t
,
n
,
r
,
i
,
o
){
this
.
elem
=
e
,
this
.
prop
=
n
,
this
.
easing
=
i
||
w
.
easing
.
_default
,
this
.
options
=
t
,
this
.
start
=
this
.
now
=
this
.
cur
(),
this
.
end
=
r
,
this
.
unit
=
o
||
(
w
.
cssNumber
[
n
]?
""
:
"px"
)},
cur
:
function
(){
var
e
=
tt
.
propHooks
[
this
.
prop
];
return
e
&&
e
.
get
?
e
.
get
(
this
):
tt
.
propHooks
.
_default
.
get
(
this
)},
run
:
function
(
e
){
var
t
,
n
=
tt
.
propHooks
[
this
.
prop
];
return
this
.
options
.
duration
?
this
.
pos
=
t
=
w
.
easing
[
this
.
easing
](
e
,
this
.
options
.
duration
*
e
,
0
,
1
,
this
.
options
.
duration
):
this
.
pos
=
t
=
e
,
this
.
now
=
(
this
.
end
-
this
.
start
)
*
t
+
this
.
start
,
this
.
options
.
step
&&
this
.
options
.
step
.
call
(
this
.
elem
,
this
.
now
,
this
),
n
&&
n
.
set
?
n
.
set
(
this
):
tt
.
propHooks
.
_default
.
set
(
this
),
this
}},
tt
.
prototype
.
init
.
prototype
=
tt
.
prototype
,
tt
.
propHooks
=
{
_default
:{
get
:
function
(
e
){
var
t
;
return
1
!==
e
.
elem
.
nodeType
||
null
!=
e
.
elem
[
e
.
prop
]
&&
null
==
e
.
elem
.
style
[
e
.
prop
]?
e
.
elem
[
e
.
prop
]:(
t
=
w
.
css
(
e
.
elem
,
e
.
prop
,
""
))
&&
"auto"
!==
t
?
t
:
0
},
set
:
function
(
e
){
w
.
fx
.
step
[
e
.
prop
]?
w
.
fx
.
step
[
e
.
prop
](
e
):
1
!==
e
.
elem
.
nodeType
||
null
==
e
.
elem
.
style
[
w
.
cssProps
[
e
.
prop
]]
&&!
w
.
cssHooks
[
e
.
prop
]?
e
.
elem
[
e
.
prop
]
=
e
.
now
:
w
.
style
(
e
.
elem
,
e
.
prop
,
e
.
now
+
e
.
unit
)}}},
tt
.
propHooks
.
scrollTop
=
tt
.
propHooks
.
scrollLeft
=
{
set
:
function
(
e
){
e
.
elem
.
nodeType
&&
e
.
elem
.
parentNode
&&
(
e
.
elem
[
e
.
prop
]
=
e
.
now
)}},
w
.
easing
=
{
linear
:
function
(
e
){
return
e
},
swing
:
function
(
e
){
return
.
5
-
Math
.
cos
(
e
*
Math
.
PI
)
/
2
},
_default
:
"swing"
},
w
.
fx
=
tt
.
prototype
.
init
,
w
.
fx
.
step
=
{};
var
nt
,
rt
,
it
=
/^
(?:
toggle|show|hide
)
$/
,
ot
=
/queueHooks$/
;
function
at
(){
rt
&&
(
!
1
===
r
.
hidden
&&
e
.
requestAnimationFrame
?
e
.
requestAnimationFrame
(
at
):
e
.
setTimeout
(
at
,
w
.
fx
.
interval
),
w
.
fx
.
tick
())}
function
st
(){
return
e
.
setTimeout
(
function
(){
nt
=
void
0
}),
nt
=
Date
.
now
()}
function
ut
(
e
,
t
){
var
n
,
r
=
0
,
i
=
{
height
:
e
};
for
(
t
=
t
?
1
:
0
;
r
<
4
;
r
+=
2
-
t
)
i
[
"margin"
+
(
n
=
oe
[
r
])]
=
i
[
"padding"
+
n
]
=
e
;
return
t
&&
(
i
.
opacity
=
i
.
width
=
e
),
i
}
function
lt
(
e
,
t
,
n
){
for
(
var
r
,
i
=
(
pt
.
tweeners
[
t
]
||
[]).
concat
(
pt
.
tweeners
[
"*"
]),
o
=
0
,
a
=
i
.
length
;
o
<
a
;
o
++
)
if
(
r
=
i
[
o
].
call
(
n
,
t
,
e
))
return
r
}
function
ct
(
e
,
t
,
n
){
var
r
,
i
,
o
,
a
,
s
,
u
,
l
,
c
,
f
=
"width"
in
t
||
"height"
in
t
,
p
=
this
,
d
=
{},
h
=
e
.
style
,
g
=
e
.
nodeType
&&
ae
(
e
),
y
=
J
.
get
(
e
,
"fxshow"
);
n
.
queue
||
(
null
==
(
a
=
w
.
_queueHooks
(
e
,
"fx"
)).
unqueued
&&
(
a
.
unqueued
=
0
,
s
=
a
.
empty
.
fire
,
a
.
empty
.
fire
=
function
(){
a
.
unqueued
||
s
()}),
a
.
unqueued
++
,
p
.
always
(
function
(){
p
.
always
(
function
(){
a
.
unqueued
--
,
w
.
queue
(
e
,
"fx"
).
length
||
a
.
empty
.
fire
()})}));
for
(
r
in
t
)
if
(
i
=
t
[
r
],
it
.
test
(
i
)){
if
(
delete
t
[
r
],
o
=
o
||
"toggle"
===
i
,
i
===
(
g
?
"hide"
:
"show"
)){
if
(
"show"
!==
i
||!
y
||
void
0
===
y
[
r
])
continue
;
g
=!
0
}
d
[
r
]
=
y
&&
y
[
r
]
||
w
.
style
(
e
,
r
)}
if
((
u
=!
w
.
isEmptyObject
(
t
))
||!
w
.
isEmptyObject
(
d
)){
f
&&
1
===
e
.
nodeType
&&
(
n
.
overflow
=
[
h
.
overflow
,
h
.
overflowX
,
h
.
overflowY
],
null
==
(
l
=
y
&&
y
.
display
)
&&
(
l
=
J
.
get
(
e
,
"display"
)),
"none"
===
(
c
=
w
.
css
(
e
,
"display"
))
&&
(
l
?
c
=
l
:(
fe
([
e
],
!
0
),
l
=
e
.
style
.
display
||
l
,
c
=
w
.
css
(
e
,
"display"
),
fe
([
e
]))),(
"inline"
===
c
||
"inline-block"
===
c
&&
null
!=
l
)
&&
"none"
===
w
.
css
(
e
,
"float"
)
&&
(
u
||
(
p
.
done
(
function
(){
h
.
display
=
l
}),
null
==
l
&&
(
c
=
h
.
display
,
l
=
"none"
===
c
?
""
:
c
)),
h
.
display
=
"inline-block"
)),
n
.
overflow
&&
(
h
.
overflow
=
"hidden"
,
p
.
always
(
function
(){
h
.
overflow
=
n
.
overflow
[
0
],
h
.
overflowX
=
n
.
overflow
[
1
],
h
.
overflowY
=
n
.
overflow
[
2
]})),
u
=!
1
;
for
(
r
in
d
)
u
||
(
y
?
"hidden"
in
y
&&
(
g
=
y
.
hidden
):
y
=
J
.
access
(
e
,
"fxshow"
,{
display
:
l
}),
o
&&
(
y
.
hidden
=!
g
),
g
&&
fe
([
e
],
!
0
),
p
.
done
(
function
(){
g
||
fe
([
e
]),
J
.
remove
(
e
,
"fxshow"
);
for
(
r
in
d
)
w
.
style
(
e
,
r
,
d
[
r
])})),
u
=
lt
(
g
?
y
[
r
]:
0
,
r
,
p
),
r
in
y
||
(
y
[
r
]
=
u
.
start
,
g
&&
(
u
.
end
=
u
.
start
,
u
.
start
=
0
))}}
function
ft
(
e
,
t
){
var
n
,
r
,
i
,
o
,
a
;
for
(
n
in
e
)
if
(
r
=
G
(
n
),
i
=
t
[
r
],
o
=
e
[
n
],
Array
.
isArray
(
o
)
&&
(
i
=
o
[
1
],
o
=
e
[
n
]
=
o
[
0
]),
n
!==
r
&&
(
e
[
r
]
=
o
,
delete
e
[
n
]),(
a
=
w
.
cssHooks
[
r
])
&&
"expand"
in
a
){
o
=
a
.
expand
(
o
),
delete
e
[
r
];
for
(
n
in
o
)
n
in
e
||
(
e
[
n
]
=
o
[
n
],
t
[
n
]
=
i
)}
else
t
[
r
]
=
i
}
function
pt
(
e
,
t
,
n
){
var
r
,
i
,
o
=
0
,
a
=
pt
.
prefilters
.
length
,
s
=
w
.
Deferred
().
always
(
function
(){
delete
u
.
elem
}),
u
=
function
(){
if
(
i
)
return
!
1
;
for
(
var
t
=
nt
||
st
(),
n
=
Math
.
max
(
0
,
l
.
startTime
+
l
.
duration
-
t
),
r
=
1
-
(
n
/
l
.
duration
||
0
),
o
=
0
,
a
=
l
.
tweens
.
length
;
o
<
a
;
o
++
)
l
.
tweens
[
o
].
run
(
r
);
return
s
.
notifyWith
(
e
,[
l
,
r
,
n
]),
r
<
1
&&
a
?
n
:(
a
||
s
.
notifyWith
(
e
,[
l
,
1
,
0
]),
s
.
resolveWith
(
e
,[
l
]),
!
1
)},
l
=
s
.
promise
({
elem
:
e
,
props
:
w
.
extend
({},
t
),
opts
:
w
.
extend
(
!
0
,{
specialEasing
:{},
easing
:
w
.
easing
.
_default
},
n
),
originalProperties
:
t
,
originalOptions
:
n
,
startTime
:
nt
||
st
(),
duration
:
n
.
duration
,
tweens
:[],
createTween
:
function
(
t
,
n
){
var
r
=
w
.
Tween
(
e
,
l
.
opts
,
t
,
n
,
l
.
opts
.
specialEasing
[
t
]
||
l
.
opts
.
easing
);
return
l
.
tweens
.
push
(
r
),
r
},
stop
:
function
(
t
){
var
n
=
0
,
r
=
t
?
l
.
tweens
.
length
:
0
;
if
(
i
)
return
this
;
for
(
i
=!
0
;
n
<
r
;
n
++
)
l
.
tweens
[
n
].
run
(
1
);
return
t
?(
s
.
notifyWith
(
e
,[
l
,
1
,
0
]),
s
.
resolveWith
(
e
,[
l
,
t
])):
s
.
rejectWith
(
e
,[
l
,
t
]),
this
}}),
c
=
l
.
props
;
for
(
ft
(
c
,
l
.
opts
.
specialEasing
);
o
<
a
;
o
++
)
if
(
r
=
pt
.
prefilters
[
o
].
call
(
l
,
e
,
c
,
l
.
opts
))
return
g
(
r
.
stop
)
&&
(
w
.
_queueHooks
(
l
.
elem
,
l
.
opts
.
queue
).
stop
=
r
.
stop
.
bind
(
r
)),
r
;
return
w
.
map
(
c
,
lt
,
l
),
g
(
l
.
opts
.
start
)
&&
l
.
opts
.
start
.
call
(
e
,
l
),
l
.
progress
(
l
.
opts
.
progress
).
done
(
l
.
opts
.
done
,
l
.
opts
.
complete
).
fail
(
l
.
opts
.
fail
).
always
(
l
.
opts
.
always
),
w
.
fx
.
timer
(
w
.
extend
(
u
,{
elem
:
e
,
anim
:
l
,
queue
:
l
.
opts
.
queue
})),
l
}
w
.
Animation
=
w
.
extend
(
pt
,{
tweeners
:{
"*"
:[
function
(
e
,
t
){
var
n
=
this
.
createTween
(
e
,
t
);
return
ue
(
n
.
elem
,
e
,
ie
.
exec
(
t
),
n
),
n
}]},
tweener
:
function
(
e
,
t
){
g
(
e
)?(
t
=
e
,
e
=
[
"*"
]):
e
=
e
.
match
(
M
);
for
(
var
n
,
r
=
0
,
i
=
e
.
length
;
r
<
i
;
r
++
)
n
=
e
[
r
],
pt
.
tweeners
[
n
]
=
pt
.
tweeners
[
n
]
||
[],
pt
.
tweeners
[
n
].
unshift
(
t
)},
prefilters
:[
ct
],
prefilter
:
function
(
e
,
t
){
t
?
pt
.
prefilters
.
unshift
(
e
):
pt
.
prefilters
.
push
(
e
)}}),
w
.
speed
=
function
(
e
,
t
,
n
){
var
r
=
e
&&
"object"
==
typeof
e
?
w
.
extend
({},
e
):{
complete
:
n
||!
n
&&
t
||
g
(
e
)
&&
e
,
duration
:
e
,
easing
:
n
&&
t
||
t
&&!
g
(
t
)
&&
t
};
return
w
.
fx
.
off
?
r
.
duration
=
0
:
"number"
!=
typeof
r
.
duration
&&
(
r
.
duration
in
w
.
fx
.
speeds
?
r
.
duration
=
w
.
fx
.
speeds
[
r
.
duration
]:
r
.
duration
=
w
.
fx
.
speeds
.
_default
),
null
!=
r
.
queue
&&!
0
!==
r
.
queue
||
(
r
.
queue
=
"fx"
),
r
.
old
=
r
.
complete
,
r
.
complete
=
function
(){
g
(
r
.
old
)
&&
r
.
old
.
call
(
this
),
r
.
queue
&&
w
.
dequeue
(
this
,
r
.
queue
)},
r
},
w
.
fn
.
extend
({
fadeTo
:
function
(
e
,
t
,
n
,
r
){
return
this
.
filter
(
ae
).
css
(
"opacity"
,
0
).
show
().
end
().
animate
({
opacity
:
t
},
e
,
n
,
r
)},
animate
:
function
(
e
,
t
,
n
,
r
){
var
i
=
w
.
isEmptyObject
(
e
),
o
=
w
.
speed
(
t
,
n
,
r
),
a
=
function
(){
var
t
=
pt
(
this
,
w
.
extend
({},
e
),
o
);(
i
||
J
.
get
(
this
,
"finish"
))
&&
t
.
stop
(
!
0
)};
return
a
.
finish
=
a
,
i
||!
1
===
o
.
queue
?
this
.
each
(
a
):
this
.
queue
(
o
.
queue
,
a
)},
stop
:
function
(
e
,
t
,
n
){
var
r
=
function
(
e
){
var
t
=
e
.
stop
;
delete
e
.
stop
,
t
(
n
)};
return
"string"
!=
typeof
e
&&
(
n
=
t
,
t
=
e
,
e
=
void
0
),
t
&&!
1
!==
e
&&
this
.
queue
(
e
||
"fx"
,[]),
this
.
each
(
function
(){
var
t
=!
0
,
i
=
null
!=
e
&&
e
+
"queueHooks"
,
o
=
w
.
timers
,
a
=
J
.
get
(
this
);
if
(
i
)
a
[
i
]
&&
a
[
i
].
stop
&&
r
(
a
[
i
]);
else
for
(
i
in
a
)
a
[
i
]
&&
a
[
i
].
stop
&&
ot
.
test
(
i
)
&&
r
(
a
[
i
]);
for
(
i
=
o
.
length
;
i
--
;)
o
[
i
].
elem
!==
this
||
null
!=
e
&&
o
[
i
].
queue
!==
e
||
(
o
[
i
].
anim
.
stop
(
n
),
t
=!
1
,
o
.
splice
(
i
,
1
));
!
t
&&
n
||
w
.
dequeue
(
this
,
e
)})},
finish
:
function
(
e
){
return
!
1
!==
e
&&
(
e
=
e
||
"fx"
),
this
.
each
(
function
(){
var
t
,
n
=
J
.
get
(
this
),
r
=
n
[
e
+
"queue"
],
i
=
n
[
e
+
"queueHooks"
],
o
=
w
.
timers
,
a
=
r
?
r
.
length
:
0
;
for
(
n
.
finish
=!
0
,
w
.
queue
(
this
,
e
,[]),
i
&&
i
.
stop
&&
i
.
stop
.
call
(
this
,
!
0
),
t
=
o
.
length
;
t
--
;)
o
[
t
].
elem
===
this
&&
o
[
t
].
queue
===
e
&&
(
o
[
t
].
anim
.
stop
(
!
0
),
o
.
splice
(
t
,
1
));
for
(
t
=
0
;
t
<
a
;
t
++
)
r
[
t
]
&&
r
[
t
].
finish
&&
r
[
t
].
finish
.
call
(
this
);
delete
n
.
finish
})}}),
w
.
each
([
"toggle"
,
"show"
,
"hide"
],
function
(
e
,
t
){
var
n
=
w
.
fn
[
t
];
w
.
fn
[
t
]
=
function
(
e
,
r
,
i
){
return
null
==
e
||
"boolean"
==
typeof
e
?
n
.
apply
(
this
,
arguments
):
this
.
animate
(
ut
(
t
,
!
0
),
e
,
r
,
i
)}}),
w
.
each
({
slideDown
:
ut
(
"show"
),
slideUp
:
ut
(
"hide"
),
slideToggle
:
ut
(
"toggle"
),
fadeIn
:{
opacity
:
"show"
},
fadeOut
:{
opacity
:
"hide"
},
fadeToggle
:{
opacity
:
"toggle"
}},
function
(
e
,
t
){
w
.
fn
[
e
]
=
function
(
e
,
n
,
r
){
return
this
.
animate
(
t
,
e
,
n
,
r
)}}),
w
.
timers
=
[],
w
.
fx
.
tick
=
function
(){
var
e
,
t
=
0
,
n
=
w
.
timers
;
for
(
nt
=
Date
.
now
();
t
<
n
.
length
;
t
++
)(
e
=
n
[
t
])()
||
n
[
t
]
!==
e
||
n
.
splice
(
t
--
,
1
);
n
.
length
||
w
.
fx
.
stop
(),
nt
=
void
0
},
w
.
fx
.
timer
=
function
(
e
){
w
.
timers
.
push
(
e
),
w
.
fx
.
start
()},
w
.
fx
.
interval
=
13
,
w
.
fx
.
start
=
function
(){
rt
||
(
rt
=!
0
,
at
())},
w
.
fx
.
stop
=
function
(){
rt
=
null
},
w
.
fx
.
speeds
=
{
slow
:
600
,
fast
:
200
,
_default
:
400
},
w
.
fn
.
delay
=
function
(
t
,
n
){
return
t
=
w
.
fx
?
w
.
fx
.
speeds
[
t
]
||
t
:
t
,
n
=
n
||
"fx"
,
this
.
queue
(
n
,
function
(
n
,
r
){
var
i
=
e
.
setTimeout
(
n
,
t
);
r
.
stop
=
function
(){
e
.
clearTimeout
(
i
)}})},
function
(){
var
e
=
r
.
createElement
(
"input"
),
t
=
r
.
createElement
(
"select"
).
appendChild
(
r
.
createElement
(
"option"
));
e
.
type
=
"checkbox"
,
h
.
checkOn
=
""
!==
e
.
value
,
h
.
optSelected
=
t
.
selected
,(
e
=
r
.
createElement
(
"input"
)).
value
=
"t"
,
e
.
type
=
"radio"
,
h
.
radioValue
=
"t"
===
e
.
value
}();
var
dt
,
ht
=
w
.
expr
.
attrHandle
;
w
.
fn
.
extend
({
attr
:
function
(
e
,
t
){
return
z
(
this
,
w
.
attr
,
e
,
t
,
arguments
.
length
>
1
)},
removeAttr
:
function
(
e
){
return
this
.
each
(
function
(){
w
.
removeAttr
(
this
,
e
)})}}),
w
.
extend
({
attr
:
function
(
e
,
t
,
n
){
var
r
,
i
,
o
=
e
.
nodeType
;
if
(
3
!==
o
&&
8
!==
o
&&
2
!==
o
)
return
"undefined"
==
typeof
e
.
getAttribute
?
w
.
prop
(
e
,
t
,
n
):(
1
===
o
&&
w
.
isXMLDoc
(
e
)
||
(
i
=
w
.
attrHooks
[
t
.
toLowerCase
()]
||
(
w
.
expr
.
match
.
bool
.
test
(
t
)?
dt
:
void
0
)),
void
0
!==
n
?
null
===
n
?
void
w
.
removeAttr
(
e
,
t
):
i
&&
"set"
in
i
&&
void
0
!==
(
r
=
i
.
set
(
e
,
n
,
t
))?
r
:(
e
.
setAttribute
(
t
,
n
+
""
),
n
):
i
&&
"get"
in
i
&&
null
!==
(
r
=
i
.
get
(
e
,
t
))?
r
:
null
==
(
r
=
w
.
find
.
attr
(
e
,
t
))?
void
0
:
r
)},
attrHooks
:{
type
:{
set
:
function
(
e
,
t
){
if
(
!
h
.
radioValue
&&
"radio"
===
t
&&
N
(
e
,
"input"
)){
var
n
=
e
.
value
;
return
e
.
setAttribute
(
"type"
,
t
),
n
&&
(
e
.
value
=
n
),
t
}}}},
removeAttr
:
function
(
e
,
t
){
var
n
,
r
=
0
,
i
=
t
&&
t
.
match
(
M
);
if
(
i
&&
1
===
e
.
nodeType
)
while
(
n
=
i
[
r
++
])
e
.
removeAttribute
(
n
)}}),
dt
=
{
set
:
function
(
e
,
t
,
n
){
return
!
1
===
t
?
w
.
removeAttr
(
e
,
n
):
e
.
setAttribute
(
n
,
n
),
n
}},
w
.
each
(
w
.
expr
.
match
.
bool
.
source
.
match
(
/
\w
+/g
),
function
(
e
,
t
){
var
n
=
ht
[
t
]
||
w
.
find
.
attr
;
ht
[
t
]
=
function
(
e
,
t
,
r
){
var
i
,
o
,
a
=
t
.
toLowerCase
();
return
r
||
(
o
=
ht
[
a
],
ht
[
a
]
=
i
,
i
=
null
!=
n
(
e
,
t
,
r
)?
a
:
null
,
ht
[
a
]
=
o
),
i
}});
var
gt
=
/^
(?:
input|select|textarea|button
)
$/i
,
yt
=
/^
(?:
a|area
)
$/i
;
w
.
fn
.
extend
({
prop
:
function
(
e
,
t
){
return
z
(
this
,
w
.
prop
,
e
,
t
,
arguments
.
length
>
1
)},
removeProp
:
function
(
e
){
return
this
.
each
(
function
(){
delete
this
[
w
.
propFix
[
e
]
||
e
]})}}),
w
.
extend
({
prop
:
function
(
e
,
t
,
n
){
var
r
,
i
,
o
=
e
.
nodeType
;
if
(
3
!==
o
&&
8
!==
o
&&
2
!==
o
)
return
1
===
o
&&
w
.
isXMLDoc
(
e
)
||
(
t
=
w
.
propFix
[
t
]
||
t
,
i
=
w
.
propHooks
[
t
]),
void
0
!==
n
?
i
&&
"set"
in
i
&&
void
0
!==
(
r
=
i
.
set
(
e
,
n
,
t
))?
r
:
e
[
t
]
=
n
:
i
&&
"get"
in
i
&&
null
!==
(
r
=
i
.
get
(
e
,
t
))?
r
:
e
[
t
]},
propHooks
:{
tabIndex
:{
get
:
function
(
e
){
var
t
=
w
.
find
.
attr
(
e
,
"tabindex"
);
return
t
?
parseInt
(
t
,
10
):
gt
.
test
(
e
.
nodeName
)
||
yt
.
test
(
e
.
nodeName
)
&&
e
.
href
?
0
:
-
1
}}},
propFix
:{
"for"
:
"htmlFor"
,
"class"
:
"className"
}}),
h
.
optSelected
||
(
w
.
propHooks
.
selected
=
{
get
:
function
(
e
){
var
t
=
e
.
parentNode
;
return
t
&&
t
.
parentNode
&&
t
.
parentNode
.
selectedIndex
,
null
},
set
:
function
(
e
){
var
t
=
e
.
parentNode
;
t
&&
(
t
.
selectedIndex
,
t
.
parentNode
&&
t
.
parentNode
.
selectedIndex
)}}),
w
.
each
([
"tabIndex"
,
"readOnly"
,
"maxLength"
,
"cellSpacing"
,
"cellPadding"
,
"rowSpan"
,
"colSpan"
,
"useMap"
,
"frameBorder"
,
"contentEditable"
],
function
(){
w
.
propFix
[
this
.
toLowerCase
()]
=
this
});
function
vt
(
e
){
return
(
e
.
match
(
M
)
||
[]).
join
(
" "
)}
function
mt
(
e
){
return
e
.
getAttribute
&&
e
.
getAttribute
(
"class"
)
||
""
}
function
xt
(
e
){
return
Array
.
isArray
(
e
)?
e
:
"string"
==
typeof
e
?
e
.
match
(
M
)
||
[]:[]}
w
.
fn
.
extend
({
addClass
:
function
(
e
){
var
t
,
n
,
r
,
i
,
o
,
a
,
s
,
u
=
0
;
if
(
g
(
e
))
return
this
.
each
(
function
(
t
){
w
(
this
).
addClass
(
e
.
call
(
this
,
t
,
mt
(
this
)))});
if
((
t
=
xt
(
e
)).
length
)
while
(
n
=
this
[
u
++
])
if
(
i
=
mt
(
n
),
r
=
1
===
n
.
nodeType
&&
" "
+
vt
(
i
)
+
" "
){
a
=
0
;
while
(
o
=
t
[
a
++
])
r
.
indexOf
(
" "
+
o
+
" "
)
<
0
&&
(
r
+=
o
+
" "
);
i
!==
(
s
=
vt
(
r
))
&&
n
.
setAttribute
(
"class"
,
s
)}
return
this
},
removeClass
:
function
(
e
){
var
t
,
n
,
r
,
i
,
o
,
a
,
s
,
u
=
0
;
if
(
g
(
e
))
return
this
.
each
(
function
(
t
){
w
(
this
).
removeClass
(
e
.
call
(
this
,
t
,
mt
(
this
)))});
if
(
!
arguments
.
length
)
return
this
.
attr
(
"class"
,
""
);
if
((
t
=
xt
(
e
)).
length
)
while
(
n
=
this
[
u
++
])
if
(
i
=
mt
(
n
),
r
=
1
===
n
.
nodeType
&&
" "
+
vt
(
i
)
+
" "
){
a
=
0
;
while
(
o
=
t
[
a
++
])
while
(
r
.
indexOf
(
" "
+
o
+
" "
)
>-
1
)
r
=
r
.
replace
(
" "
+
o
+
" "
,
" "
);
i
!==
(
s
=
vt
(
r
))
&&
n
.
setAttribute
(
"class"
,
s
)}
return
this
},
toggleClass
:
function
(
e
,
t
){
var
n
=
typeof
e
,
r
=
"string"
===
n
||
Array
.
isArray
(
e
);
return
"boolean"
==
typeof
t
&&
r
?
t
?
this
.
addClass
(
e
):
this
.
removeClass
(
e
):
g
(
e
)?
this
.
each
(
function
(
n
){
w
(
this
).
toggleClass
(
e
.
call
(
this
,
n
,
mt
(
this
),
t
),
t
)}):
this
.
each
(
function
(){
var
t
,
i
,
o
,
a
;
if
(
r
){
i
=
0
,
o
=
w
(
this
),
a
=
xt
(
e
);
while
(
t
=
a
[
i
++
])
o
.
hasClass
(
t
)?
o
.
removeClass
(
t
):
o
.
addClass
(
t
)}
else
void
0
!==
e
&&
"boolean"
!==
n
||
((
t
=
mt
(
this
))
&&
J
.
set
(
this
,
"__className__"
,
t
),
this
.
setAttribute
&&
this
.
setAttribute
(
"class"
,
t
||!
1
===
e
?
""
:
J
.
get
(
this
,
"__className__"
)
||
""
))})},
hasClass
:
function
(
e
){
var
t
,
n
,
r
=
0
;
t
=
" "
+
e
+
" "
;
while
(
n
=
this
[
r
++
])
if
(
1
===
n
.
nodeType
&&
(
" "
+
vt
(
mt
(
n
))
+
" "
).
indexOf
(
t
)
>-
1
)
return
!
0
;
return
!
1
}});
var
bt
=
/
\r
/g
;
w
.
fn
.
extend
({
val
:
function
(
e
){
var
t
,
n
,
r
,
i
=
this
[
0
];{
if
(
arguments
.
length
)
return
r
=
g
(
e
),
this
.
each
(
function
(
n
){
var
i
;
1
===
this
.
nodeType
&&
(
null
==
(
i
=
r
?
e
.
call
(
this
,
n
,
w
(
this
).
val
()):
e
)?
i
=
""
:
"number"
==
typeof
i
?
i
+=
""
:
Array
.
isArray
(
i
)
&&
(
i
=
w
.
map
(
i
,
function
(
e
){
return
null
==
e
?
""
:
e
+
""
})),(
t
=
w
.
valHooks
[
this
.
type
]
||
w
.
valHooks
[
this
.
nodeName
.
toLowerCase
()])
&&
"set"
in
t
&&
void
0
!==
t
.
set
(
this
,
i
,
"value"
)
||
(
this
.
value
=
i
))});
if
(
i
)
return
(
t
=
w
.
valHooks
[
i
.
type
]
||
w
.
valHooks
[
i
.
nodeName
.
toLowerCase
()])
&&
"get"
in
t
&&
void
0
!==
(
n
=
t
.
get
(
i
,
"value"
))?
n
:
"string"
==
typeof
(
n
=
i
.
value
)?
n
.
replace
(
bt
,
""
):
null
==
n
?
""
:
n
}}}),
w
.
extend
({
valHooks
:{
option
:{
get
:
function
(
e
){
var
t
=
w
.
find
.
attr
(
e
,
"value"
);
return
null
!=
t
?
t
:
vt
(
w
.
text
(
e
))}},
select
:{
get
:
function
(
e
){
var
t
,
n
,
r
,
i
=
e
.
options
,
o
=
e
.
selectedIndex
,
a
=
"select-one"
===
e
.
type
,
s
=
a
?
null
:[],
u
=
a
?
o
+
1
:
i
.
length
;
for
(
r
=
o
<
0
?
u
:
a
?
o
:
0
;
r
<
u
;
r
++
)
if
(((
n
=
i
[
r
]).
selected
||
r
===
o
)
&&!
n
.
disabled
&&
(
!
n
.
parentNode
.
disabled
||!
N
(
n
.
parentNode
,
"optgroup"
))){
if
(
t
=
w
(
n
).
val
(),
a
)
return
t
;
s
.
push
(
t
)}
return
s
},
set
:
function
(
e
,
t
){
var
n
,
r
,
i
=
e
.
options
,
o
=
w
.
makeArray
(
t
),
a
=
i
.
length
;
while
(
a
--
)((
r
=
i
[
a
]).
selected
=
w
.
inArray
(
w
.
valHooks
.
option
.
get
(
r
),
o
)
>-
1
)
&&
(
n
=!
0
);
return
n
||
(
e
.
selectedIndex
=-
1
),
o
}}}}),
w
.
each
([
"radio"
,
"checkbox"
],
function
(){
w
.
valHooks
[
this
]
=
{
set
:
function
(
e
,
t
){
if
(
Array
.
isArray
(
t
))
return
e
.
checked
=
w
.
inArray
(
w
(
e
).
val
(),
t
)
>-
1
}},
h
.
checkOn
||
(
w
.
valHooks
[
this
].
get
=
function
(
e
){
return
null
===
e
.
getAttribute
(
"value"
)?
"on"
:
e
.
value
})}),
h
.
focusin
=
"onfocusin"
in
e
;
var
wt
=
/^
(?:
focusinfocus|focusoutblur
)
$/
,
Tt
=
function
(
e
){
e
.
stopPropagation
()};
w
.
extend
(
w
.
event
,{
trigger
:
function
(
t
,
n
,
i
,
o
){
var
a
,
s
,
u
,
l
,
c
,
p
,
d
,
h
,
v
=
[
i
||
r
],
m
=
f
.
call
(
t
,
"type"
)?
t
.
type
:
t
,
x
=
f
.
call
(
t
,
"namespace"
)?
t
.
namespace
.
split
(
"."
):[];
if
(
s
=
h
=
u
=
i
=
i
||
r
,
3
!==
i
.
nodeType
&&
8
!==
i
.
nodeType
&&!
wt
.
test
(
m
+
w
.
event
.
triggered
)
&&
(
m
.
indexOf
(
"."
)
>-
1
&&
(
m
=
(
x
=
m
.
split
(
"."
)).
shift
(),
x
.
sort
()),
c
=
m
.
indexOf
(
":"
)
<
0
&&
"on"
+
m
,
t
=
t
[
w
.
expando
]?
t
:
new
w
.
Event
(
m
,
"object"
==
typeof
t
&&
t
),
t
.
isTrigger
=
o
?
2
:
3
,
t
.
namespace
=
x
.
join
(
"."
),
t
.
rnamespace
=
t
.
namespace
?
new
RegExp
(
"(^|
\\
.)"
+
x
.
join
(
"
\\
.(?:.*
\\
.|)"
)
+
"(
\\
.|$)"
):
null
,
t
.
result
=
void
0
,
t
.
target
||
(
t
.
target
=
i
),
n
=
null
==
n
?[
t
]:
w
.
makeArray
(
n
,[
t
]),
d
=
w
.
event
.
special
[
m
]
||
{},
o
||!
d
.
trigger
||!
1
!==
d
.
trigger
.
apply
(
i
,
n
))){
if
(
!
o
&&!
d
.
noBubble
&&!
y
(
i
)){
for
(
l
=
d
.
delegateType
||
m
,
wt
.
test
(
l
+
m
)
||
(
s
=
s
.
parentNode
);
s
;
s
=
s
.
parentNode
)
v
.
push
(
s
),
u
=
s
;
u
===
(
i
.
ownerDocument
||
r
)
&&
v
.
push
(
u
.
defaultView
||
u
.
parentWindow
||
e
)}
a
=
0
;
while
((
s
=
v
[
a
++
])
&&!
t
.
isPropagationStopped
())
h
=
s
,
t
.
type
=
a
>
1
?
l
:
d
.
bindType
||
m
,(
p
=
(
J
.
get
(
s
,
"events"
)
||
{})[
t
.
type
]
&&
J
.
get
(
s
,
"handle"
))
&&
p
.
apply
(
s
,
n
),(
p
=
c
&&
s
[
c
])
&&
p
.
apply
&&
Y
(
s
)
&&
(
t
.
result
=
p
.
apply
(
s
,
n
),
!
1
===
t
.
result
&&
t
.
preventDefault
());
return
t
.
type
=
m
,
o
||
t
.
isDefaultPrevented
()
||
d
.
_default
&&!
1
!==
d
.
_default
.
apply
(
v
.
pop
(),
n
)
||!
Y
(
i
)
||
c
&&
g
(
i
[
m
])
&&!
y
(
i
)
&&
((
u
=
i
[
c
])
&&
(
i
[
c
]
=
null
),
w
.
event
.
triggered
=
m
,
t
.
isPropagationStopped
()
&&
h
.
addEventListener
(
m
,
Tt
),
i
[
m
](),
t
.
isPropagationStopped
()
&&
h
.
removeEventListener
(
m
,
Tt
),
w
.
event
.
triggered
=
void
0
,
u
&&
(
i
[
c
]
=
u
)),
t
.
result
}},
simulate
:
function
(
e
,
t
,
n
){
var
r
=
w
.
extend
(
new
w
.
Event
,
n
,{
type
:
e
,
isSimulated
:
!
0
});
w
.
event
.
trigger
(
r
,
null
,
t
)}}),
w
.
fn
.
extend
({
trigger
:
function
(
e
,
t
){
return
this
.
each
(
function
(){
w
.
event
.
trigger
(
e
,
t
,
this
)})},
triggerHandler
:
function
(
e
,
t
){
var
n
=
this
[
0
];
if
(
n
)
return
w
.
event
.
trigger
(
e
,
t
,
n
,
!
0
)}}),
h
.
focusin
||
w
.
each
({
focus
:
"focusin"
,
blur
:
"focusout"
},
function
(
e
,
t
){
var
n
=
function
(
e
){
w
.
event
.
simulate
(
t
,
e
.
target
,
w
.
event
.
fix
(
e
))};
w
.
event
.
special
[
t
]
=
{
setup
:
function
(){
var
r
=
this
.
ownerDocument
||
this
,
i
=
J
.
access
(
r
,
t
);
i
||
r
.
addEventListener
(
e
,
n
,
!
0
),
J
.
access
(
r
,
t
,(
i
||
0
)
+
1
)},
teardown
:
function
(){
var
r
=
this
.
ownerDocument
||
this
,
i
=
J
.
access
(
r
,
t
)
-
1
;
i
?
J
.
access
(
r
,
t
,
i
):(
r
.
removeEventListener
(
e
,
n
,
!
0
),
J
.
remove
(
r
,
t
))}}});
var
Ct
=
e
.
location
,
Et
=
Date
.
now
(),
kt
=
/
\?
/
;
w
.
parseXML
=
function
(
t
){
var
n
;
if
(
!
t
||
"string"
!=
typeof
t
)
return
null
;
try
{
n
=
(
new
e
.
DOMParser
).
parseFromString
(
t
,
"text/xml"
)}
catch
(
e
){
n
=
void
0
}
return
n
&&!
n
.
getElementsByTagName
(
"parsererror"
).
length
||
w
.
error
(
"Invalid XML: "
+
t
),
n
};
var
St
=
/
\[\]
$/
,
Dt
=
/
\r?\n
/g
,
Nt
=
/^
(?:
submit|button|image|reset|file
)
$/i
,
At
=
/^
(?:
input|select|textarea|keygen
)
/i
;
function
jt
(
e
,
t
,
n
,
r
){
var
i
;
if
(
Array
.
isArray
(
t
))
w
.
each
(
t
,
function
(
t
,
i
){
n
||
St
.
test
(
e
)?
r
(
e
,
i
):
jt
(
e
+
"["
+
(
"object"
==
typeof
i
&&
null
!=
i
?
t
:
""
)
+
"]"
,
i
,
n
,
r
)});
else
if
(
n
||
"object"
!==
x
(
t
))
r
(
e
,
t
);
else
for
(
i
in
t
)
jt
(
e
+
"["
+
i
+
"]"
,
t
[
i
],
n
,
r
)}
w
.
param
=
function
(
e
,
t
){
var
n
,
r
=
[],
i
=
function
(
e
,
t
){
var
n
=
g
(
t
)?
t
():
t
;
r
[
r
.
length
]
=
encodeURIComponent
(
e
)
+
"="
+
encodeURIComponent
(
null
==
n
?
""
:
n
)};
if
(
Array
.
isArray
(
e
)
||
e
.
jquery
&&!
w
.
isPlainObject
(
e
))
w
.
each
(
e
,
function
(){
i
(
this
.
name
,
this
.
value
)});
else
for
(
n
in
e
)
jt
(
n
,
e
[
n
],
t
,
i
);
return
r
.
join
(
"&"
)},
w
.
fn
.
extend
({
serialize
:
function
(){
return
w
.
param
(
this
.
serializeArray
())},
serializeArray
:
function
(){
return
this
.
map
(
function
(){
var
e
=
w
.
prop
(
this
,
"elements"
);
return
e
?
w
.
makeArray
(
e
):
this
}).
filter
(
function
(){
var
e
=
this
.
type
;
return
this
.
name
&&!
w
(
this
).
is
(
":disabled"
)
&&
At
.
test
(
this
.
nodeName
)
&&!
Nt
.
test
(
e
)
&&
(
this
.
checked
||!
pe
.
test
(
e
))}).
map
(
function
(
e
,
t
){
var
n
=
w
(
this
).
val
();
return
null
==
n
?
null
:
Array
.
isArray
(
n
)?
w
.
map
(
n
,
function
(
e
){
return
{
name
:
t
.
name
,
value
:
e
.
replace
(
Dt
,
"
\
r
\
n"
)}}):{
name
:
t
.
name
,
value
:
n
.
replace
(
Dt
,
"
\
r
\
n"
)}}).
get
()}});
var
qt
=
/%20/g
,
Lt
=
/#.*$/
,
Ht
=
/
([
?&
])
_=
[^
&
]
*/
,
Ot
=
/^
(
.*
?)
:
[
\t]
*
([^\r\n]
*
)
$/gm
,
Pt
=
/^
(?:
about|app|app-storage|.+-extension|file|res|widget
)
:$/
,
Mt
=
/^
(?:
GET|HEAD
)
$/
,
Rt
=
/^
\/\/
/
,
It
=
{},
Wt
=
{},
$t
=
"*/"
.
concat
(
"*"
),
Bt
=
r
.
createElement
(
"a"
);
Bt
.
href
=
Ct
.
href
;
function
Ft
(
e
){
return
function
(
t
,
n
){
"string"
!=
typeof
t
&&
(
n
=
t
,
t
=
"*"
);
var
r
,
i
=
0
,
o
=
t
.
toLowerCase
().
match
(
M
)
||
[];
if
(
g
(
n
))
while
(
r
=
o
[
i
++
])
"+"
===
r
[
0
]?(
r
=
r
.
slice
(
1
)
||
"*"
,(
e
[
r
]
=
e
[
r
]
||
[]).
unshift
(
n
)):(
e
[
r
]
=
e
[
r
]
||
[]).
push
(
n
)}}
function
_t
(
e
,
t
,
n
,
r
){
var
i
=
{},
o
=
e
===
Wt
;
function
a
(
s
){
var
u
;
return
i
[
s
]
=!
0
,
w
.
each
(
e
[
s
]
||
[],
function
(
e
,
s
){
var
l
=
s
(
t
,
n
,
r
);
return
"string"
!=
typeof
l
||
o
||
i
[
l
]?
o
?
!
(
u
=
l
):
void
0
:(
t
.
dataTypes
.
unshift
(
l
),
a
(
l
),
!
1
)}),
u
}
return
a
(
t
.
dataTypes
[
0
])
||!
i
[
"*"
]
&&
a
(
"*"
)}
function
zt
(
e
,
t
){
var
n
,
r
,
i
=
w
.
ajaxSettings
.
flatOptions
||
{};
for
(
n
in
t
)
void
0
!==
t
[
n
]
&&
((
i
[
n
]?
e
:
r
||
(
r
=
{}))[
n
]
=
t
[
n
]);
return
r
&&
w
.
extend
(
!
0
,
e
,
r
),
e
}
function
Xt
(
e
,
t
,
n
){
var
r
,
i
,
o
,
a
,
s
=
e
.
contents
,
u
=
e
.
dataTypes
;
while
(
"*"
===
u
[
0
])
u
.
shift
(),
void
0
===
r
&&
(
r
=
e
.
mimeType
||
t
.
getResponseHeader
(
"Content-Type"
));
if
(
r
)
for
(
i
in
s
)
if
(
s
[
i
]
&&
s
[
i
].
test
(
r
)){
u
.
unshift
(
i
);
break
}
if
(
u
[
0
]
in
n
)
o
=
u
[
0
];
else
{
for
(
i
in
n
){
if
(
!
u
[
0
]
||
e
.
converters
[
i
+
" "
+
u
[
0
]]){
o
=
i
;
break
}
a
||
(
a
=
i
)}
o
=
o
||
a
}
if
(
o
)
return
o
!==
u
[
0
]
&&
u
.
unshift
(
o
),
n
[
o
]}
function
Ut
(
e
,
t
,
n
,
r
){
var
i
,
o
,
a
,
s
,
u
,
l
=
{},
c
=
e
.
dataTypes
.
slice
();
if
(
c
[
1
])
for
(
a
in
e
.
converters
)
l
[
a
.
toLowerCase
()]
=
e
.
converters
[
a
];
o
=
c
.
shift
();
while
(
o
)
if
(
e
.
responseFields
[
o
]
&&
(
n
[
e
.
responseFields
[
o
]]
=
t
),
!
u
&&
r
&&
e
.
dataFilter
&&
(
t
=
e
.
dataFilter
(
t
,
e
.
dataType
)),
u
=
o
,
o
=
c
.
shift
())
if
(
"*"
===
o
)
o
=
u
;
else
if
(
"*"
!==
u
&&
u
!==
o
){
if
(
!
(
a
=
l
[
u
+
" "
+
o
]
||
l
[
"* "
+
o
]))
for
(
i
in
l
)
if
((
s
=
i
.
split
(
" "
))[
1
]
===
o
&&
(
a
=
l
[
u
+
" "
+
s
[
0
]]
||
l
[
"* "
+
s
[
0
]])){
!
0
===
a
?
a
=
l
[
i
]:
!
0
!==
l
[
i
]
&&
(
o
=
s
[
0
],
c
.
unshift
(
s
[
1
]));
break
}
if
(
!
0
!==
a
)
if
(
a
&&
e
[
"throws"
])
t
=
a
(
t
);
else
try
{
t
=
a
(
t
)}
catch
(
e
){
return
{
state
:
"parsererror"
,
error
:
a
?
e
:
"No conversion from "
+
u
+
" to "
+
o
}}}
return
{
state
:
"success"
,
data
:
t
}}
w
.
extend
({
active
:
0
,
lastModified
:{},
etag
:{},
ajaxSettings
:{
url
:
Ct
.
href
,
type
:
"GET"
,
isLocal
:
Pt
.
test
(
Ct
.
protocol
),
global
:
!
0
,
processData
:
!
0
,
async
:
!
0
,
contentType
:
"application/x-www-form-urlencoded; charset=UTF-8"
,
accepts
:{
"*"
:
$t
,
text
:
"text/plain"
,
html
:
"text/html"
,
xml
:
"application/xml, text/xml"
,
json
:
"application/json, text/javascript"
},
contents
:{
xml
:
/
\b
xml
\b
/
,
html
:
/
\b
html/
,
json
:
/
\b
json
\b
/
},
responseFields
:{
xml
:
"responseXML"
,
text
:
"responseText"
,
json
:
"responseJSON"
},
converters
:{
"* text"
:
String
,
"text html"
:
!
0
,
"text json"
:
JSON
.
parse
,
"text xml"
:
w
.
parseXML
},
flatOptions
:{
url
:
!
0
,
context
:
!
0
}},
ajaxSetup
:
function
(
e
,
t
){
return
t
?
zt
(
zt
(
e
,
w
.
ajaxSettings
),
t
):
zt
(
w
.
ajaxSettings
,
e
)},
ajaxPrefilter
:
Ft
(
It
),
ajaxTransport
:
Ft
(
Wt
),
ajax
:
function
(
t
,
n
){
"object"
==
typeof
t
&&
(
n
=
t
,
t
=
void
0
),
n
=
n
||
{};
var
i
,
o
,
a
,
s
,
u
,
l
,
c
,
f
,
p
,
d
,
h
=
w
.
ajaxSetup
({},
n
),
g
=
h
.
context
||
h
,
y
=
h
.
context
&&
(
g
.
nodeType
||
g
.
jquery
)?
w
(
g
):
w
.
event
,
v
=
w
.
Deferred
(),
m
=
w
.
Callbacks
(
"once memory"
),
x
=
h
.
statusCode
||
{},
b
=
{},
T
=
{},
C
=
"canceled"
,
E
=
{
readyState
:
0
,
getResponseHeader
:
function
(
e
){
var
t
;
if
(
c
){
if
(
!
s
){
s
=
{};
while
(
t
=
Ot
.
exec
(
a
))
s
[
t
[
1
].
toLowerCase
()]
=
t
[
2
]}
t
=
s
[
e
.
toLowerCase
()]}
return
null
==
t
?
null
:
t
},
getAllResponseHeaders
:
function
(){
return
c
?
a
:
null
},
setRequestHeader
:
function
(
e
,
t
){
return
null
==
c
&&
(
e
=
T
[
e
.
toLowerCase
()]
=
T
[
e
.
toLowerCase
()]
||
e
,
b
[
e
]
=
t
),
this
},
overrideMimeType
:
function
(
e
){
return
null
==
c
&&
(
h
.
mimeType
=
e
),
this
},
statusCode
:
function
(
e
){
var
t
;
if
(
e
)
if
(
c
)
E
.
always
(
e
[
E
.
status
]);
else
for
(
t
in
e
)
x
[
t
]
=
[
x
[
t
],
e
[
t
]];
return
this
},
abort
:
function
(
e
){
var
t
=
e
||
C
;
return
i
&&
i
.
abort
(
t
),
k
(
0
,
t
),
this
}};
if
(
v
.
promise
(
E
),
h
.
url
=
((
t
||
h
.
url
||
Ct
.
href
)
+
""
).
replace
(
Rt
,
Ct
.
protocol
+
"//"
),
h
.
type
=
n
.
method
||
n
.
type
||
h
.
method
||
h
.
type
,
h
.
dataTypes
=
(
h
.
dataType
||
"*"
).
toLowerCase
().
match
(
M
)
||
[
""
],
null
==
h
.
crossDomain
){
l
=
r
.
createElement
(
"a"
);
try
{
l
.
href
=
h
.
url
,
l
.
href
=
l
.
href
,
h
.
crossDomain
=
Bt
.
protocol
+
"//"
+
Bt
.
host
!=
l
.
protocol
+
"//"
+
l
.
host
}
catch
(
e
){
h
.
crossDomain
=!
0
}}
if
(
h
.
data
&&
h
.
processData
&&
"string"
!=
typeof
h
.
data
&&
(
h
.
data
=
w
.
param
(
h
.
data
,
h
.
traditional
)),
_t
(
It
,
h
,
n
,
E
),
c
)
return
E
;(
f
=
w
.
event
&&
h
.
global
)
&&
0
==
w
.
active
++&&
w
.
event
.
trigger
(
"ajaxStart"
),
h
.
type
=
h
.
type
.
toUpperCase
(),
h
.
hasContent
=!
Mt
.
test
(
h
.
type
),
o
=
h
.
url
.
replace
(
Lt
,
""
),
h
.
hasContent
?
h
.
data
&&
h
.
processData
&&
0
===
(
h
.
contentType
||
""
).
indexOf
(
"application/x-www-form-urlencoded"
)
&&
(
h
.
data
=
h
.
data
.
replace
(
qt
,
"+"
)):(
d
=
h
.
url
.
slice
(
o
.
length
),
h
.
data
&&
(
h
.
processData
||
"string"
==
typeof
h
.
data
)
&&
(
o
+=
(
kt
.
test
(
o
)?
"&"
:
"?"
)
+
h
.
data
,
delete
h
.
data
),
!
1
===
h
.
cache
&&
(
o
=
o
.
replace
(
Ht
,
"$1"
),
d
=
(
kt
.
test
(
o
)?
"&"
:
"?"
)
+
"_="
+
Et
+++
d
),
h
.
url
=
o
+
d
),
h
.
ifModified
&&
(
w
.
lastModified
[
o
]
&&
E
.
setRequestHeader
(
"If-Modified-Since"
,
w
.
lastModified
[
o
]),
w
.
etag
[
o
]
&&
E
.
setRequestHeader
(
"If-None-Match"
,
w
.
etag
[
o
])),(
h
.
data
&&
h
.
hasContent
&&!
1
!==
h
.
contentType
||
n
.
contentType
)
&&
E
.
setRequestHeader
(
"Content-Type"
,
h
.
contentType
),
E
.
setRequestHeader
(
"Accept"
,
h
.
dataTypes
[
0
]
&&
h
.
accepts
[
h
.
dataTypes
[
0
]]?
h
.
accepts
[
h
.
dataTypes
[
0
]]
+
(
"*"
!==
h
.
dataTypes
[
0
]?
", "
+
$t
+
"; q=0.01"
:
""
):
h
.
accepts
[
"*"
]);
for
(
p
in
h
.
headers
)
E
.
setRequestHeader
(
p
,
h
.
headers
[
p
]);
if
(
h
.
beforeSend
&&
(
!
1
===
h
.
beforeSend
.
call
(
g
,
E
,
h
)
||
c
))
return
E
.
abort
();
if
(
C
=
"abort"
,
m
.
add
(
h
.
complete
),
E
.
done
(
h
.
success
),
E
.
fail
(
h
.
error
),
i
=
_t
(
Wt
,
h
,
n
,
E
)){
if
(
E
.
readyState
=
1
,
f
&&
y
.
trigger
(
"ajaxSend"
,[
E
,
h
]),
c
)
return
E
;
h
.
async
&&
h
.
timeout
>
0
&&
(
u
=
e
.
setTimeout
(
function
(){
E
.
abort
(
"timeout"
)},
h
.
timeout
));
try
{
c
=!
1
,
i
.
send
(
b
,
k
)}
catch
(
e
){
if
(
c
)
throw
e
;
k
(
-
1
,
e
)}}
else
k
(
-
1
,
"No Transport"
);
function
k
(
t
,
n
,
r
,
s
){
var
l
,
p
,
d
,
b
,
T
,
C
=
n
;
c
||
(
c
=!
0
,
u
&&
e
.
clearTimeout
(
u
),
i
=
void
0
,
a
=
s
||
""
,
E
.
readyState
=
t
>
0
?
4
:
0
,
l
=
t
>=
200
&&
t
<
300
||
304
===
t
,
r
&&
(
b
=
Xt
(
h
,
E
,
r
)),
b
=
Ut
(
h
,
b
,
E
,
l
),
l
?(
h
.
ifModified
&&
((
T
=
E
.
getResponseHeader
(
"Last-Modified"
))
&&
(
w
.
lastModified
[
o
]
=
T
),(
T
=
E
.
getResponseHeader
(
"etag"
))
&&
(
w
.
etag
[
o
]
=
T
)),
204
===
t
||
"HEAD"
===
h
.
type
?
C
=
"nocontent"
:
304
===
t
?
C
=
"notmodified"
:(
C
=
b
.
state
,
p
=
b
.
data
,
l
=!
(
d
=
b
.
error
))):(
d
=
C
,
!
t
&&
C
||
(
C
=
"error"
,
t
<
0
&&
(
t
=
0
))),
E
.
status
=
t
,
E
.
statusText
=
(
n
||
C
)
+
""
,
l
?
v
.
resolveWith
(
g
,[
p
,
C
,
E
]):
v
.
rejectWith
(
g
,[
E
,
C
,
d
]),
E
.
statusCode
(
x
),
x
=
void
0
,
f
&&
y
.
trigger
(
l
?
"ajaxSuccess"
:
"ajaxError"
,[
E
,
h
,
l
?
p
:
d
]),
m
.
fireWith
(
g
,[
E
,
C
]),
f
&&
(
y
.
trigger
(
"ajaxComplete"
,[
E
,
h
]),
--
w
.
active
||
w
.
event
.
trigger
(
"ajaxStop"
)))}
return
E
},
getJSON
:
function
(
e
,
t
,
n
){
return
w
.
get
(
e
,
t
,
n
,
"json"
)},
getScript
:
function
(
e
,
t
){
return
w
.
get
(
e
,
void
0
,
t
,
"script"
)}}),
w
.
each
([
"get"
,
"post"
],
function
(
e
,
t
){
w
[
t
]
=
function
(
e
,
n
,
r
,
i
){
return
g
(
n
)
&&
(
i
=
i
||
r
,
r
=
n
,
n
=
void
0
),
w
.
ajax
(
w
.
extend
({
url
:
e
,
type
:
t
,
dataType
:
i
,
data
:
n
,
success
:
r
},
w
.
isPlainObject
(
e
)
&&
e
))}}),
w
.
_evalUrl
=
function
(
e
){
return
w
.
ajax
({
url
:
e
,
type
:
"GET"
,
dataType
:
"script"
,
cache
:
!
0
,
async
:
!
1
,
global
:
!
1
,
"throws"
:
!
0
})},
w
.
fn
.
extend
({
wrapAll
:
function
(
e
){
var
t
;
return
this
[
0
]
&&
(
g
(
e
)
&&
(
e
=
e
.
call
(
this
[
0
])),
t
=
w
(
e
,
this
[
0
].
ownerDocument
).
eq
(
0
).
clone
(
!
0
),
this
[
0
].
parentNode
&&
t
.
insertBefore
(
this
[
0
]),
t
.
map
(
function
(){
var
e
=
this
;
while
(
e
.
firstElementChild
)
e
=
e
.
firstElementChild
;
return
e
}).
append
(
this
)),
this
},
wrapInner
:
function
(
e
){
return
g
(
e
)?
this
.
each
(
function
(
t
){
w
(
this
).
wrapInner
(
e
.
call
(
this
,
t
))}):
this
.
each
(
function
(){
var
t
=
w
(
this
),
n
=
t
.
contents
();
n
.
length
?
n
.
wrapAll
(
e
):
t
.
append
(
e
)})},
wrap
:
function
(
e
){
var
t
=
g
(
e
);
return
this
.
each
(
function
(
n
){
w
(
this
).
wrapAll
(
t
?
e
.
call
(
this
,
n
):
e
)})},
unwrap
:
function
(
e
){
return
this
.
parent
(
e
).
not
(
"body"
).
each
(
function
(){
w
(
this
).
replaceWith
(
this
.
childNodes
)}),
this
}}),
w
.
expr
.
pseudos
.
hidden
=
function
(
e
){
return
!
w
.
expr
.
pseudos
.
visible
(
e
)},
w
.
expr
.
pseudos
.
visible
=
function
(
e
){
return
!!
(
e
.
offsetWidth
||
e
.
offsetHeight
||
e
.
getClientRects
().
length
)},
w
.
ajaxSettings
.
xhr
=
function
(){
try
{
return
new
e
.
XMLHttpRequest
}
catch
(
e
){}};
var
Vt
=
{
0
:
200
,
1223
:
204
},
Gt
=
w
.
ajaxSettings
.
xhr
();
h
.
cors
=!!
Gt
&&
"withCredentials"
in
Gt
,
h
.
ajax
=
Gt
=!!
Gt
,
w
.
ajaxTransport
(
function
(
t
){
var
n
,
r
;
if
(
h
.
cors
||
Gt
&&!
t
.
crossDomain
)
return
{
send
:
function
(
i
,
o
){
var
a
,
s
=
t
.
xhr
();
if
(
s
.
open
(
t
.
type
,
t
.
url
,
t
.
async
,
t
.
username
,
t
.
password
),
t
.
xhrFields
)
for
(
a
in
t
.
xhrFields
)
s
[
a
]
=
t
.
xhrFields
[
a
];
t
.
mimeType
&&
s
.
overrideMimeType
&&
s
.
overrideMimeType
(
t
.
mimeType
),
t
.
crossDomain
||
i
[
"X-Requested-With"
]
||
(
i
[
"X-Requested-With"
]
=
"XMLHttpRequest"
);
for
(
a
in
i
)
s
.
setRequestHeader
(
a
,
i
[
a
]);
n
=
function
(
e
){
return
function
(){
n
&&
(
n
=
r
=
s
.
onload
=
s
.
onerror
=
s
.
onabort
=
s
.
ontimeout
=
s
.
onreadystatechange
=
null
,
"abort"
===
e
?
s
.
abort
():
"error"
===
e
?
"number"
!=
typeof
s
.
status
?
o
(
0
,
"error"
):
o
(
s
.
status
,
s
.
statusText
):
o
(
Vt
[
s
.
status
]
||
s
.
status
,
s
.
statusText
,
"text"
!==
(
s
.
responseType
||
"text"
)
||
"string"
!=
typeof
s
.
responseText
?{
binary
:
s
.
response
}:{
text
:
s
.
responseText
},
s
.
getAllResponseHeaders
()))}},
s
.
onload
=
n
(),
r
=
s
.
onerror
=
s
.
ontimeout
=
n
(
"error"
),
void
0
!==
s
.
onabort
?
s
.
onabort
=
r
:
s
.
onreadystatechange
=
function
(){
4
===
s
.
readyState
&&
e
.
setTimeout
(
function
(){
n
&&
r
()})},
n
=
n
(
"abort"
);
try
{
s
.
send
(
t
.
hasContent
&&
t
.
data
||
null
)}
catch
(
e
){
if
(
n
)
throw
e
}},
abort
:
function
(){
n
&&
n
()}}}),
w
.
ajaxPrefilter
(
function
(
e
){
e
.
crossDomain
&&
(
e
.
contents
.
script
=!
1
)}),
w
.
ajaxSetup
({
accepts
:{
script
:
"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"
},
contents
:{
script
:
/
\b(?:
java|ecma
)
script
\b
/
},
converters
:{
"text script"
:
function
(
e
){
return
w
.
globalEval
(
e
),
e
}}}),
w
.
ajaxPrefilter
(
"script"
,
function
(
e
){
void
0
===
e
.
cache
&&
(
e
.
cache
=!
1
),
e
.
crossDomain
&&
(
e
.
type
=
"GET"
)}),
w
.
ajaxTransport
(
"script"
,
function
(
e
){
if
(
e
.
crossDomain
){
var
t
,
n
;
return
{
send
:
function
(
i
,
o
){
t
=
w
(
"<script>"
).
prop
({
charset
:
e
.
scriptCharset
,
src
:
e
.
url
}).
on
(
"load error"
,
n
=
function
(
e
){
t
.
remove
(),
n
=
null
,
e
&&
o
(
"error"
===
e
.
type
?
404
:
200
,
e
.
type
)}),
r
.
head
.
appendChild
(
t
[
0
])},
abort
:
function
(){
n
&&
n
()}}}});
var
Yt
=
[],
Qt
=
/
(
=
)\?(?=
&|$
)
|
\?\?
/
;
w
.
ajaxSetup
({
jsonp
:
"callback"
,
jsonpCallback
:
function
(){
var
e
=
Yt
.
pop
()
||
w
.
expando
+
"_"
+
Et
++
;
return
this
[
e
]
=!
0
,
e
}}),
w
.
ajaxPrefilter
(
"json jsonp"
,
function
(
t
,
n
,
r
){
var
i
,
o
,
a
,
s
=!
1
!==
t
.
jsonp
&&
(
Qt
.
test
(
t
.
url
)?
"url"
:
"string"
==
typeof
t
.
data
&&
0
===
(
t
.
contentType
||
""
).
indexOf
(
"application/x-www-form-urlencoded"
)
&&
Qt
.
test
(
t
.
data
)
&&
"data"
);
if
(
s
||
"jsonp"
===
t
.
dataTypes
[
0
])
return
i
=
t
.
jsonpCallback
=
g
(
t
.
jsonpCallback
)?
t
.
jsonpCallback
():
t
.
jsonpCallback
,
s
?
t
[
s
]
=
t
[
s
].
replace
(
Qt
,
"$1"
+
i
):
!
1
!==
t
.
jsonp
&&
(
t
.
url
+=
(
kt
.
test
(
t
.
url
)?
"&"
:
"?"
)
+
t
.
jsonp
+
"="
+
i
),
t
.
converters
[
"script json"
]
=
function
(){
return
a
||
w
.
error
(
i
+
" was not called"
),
a
[
0
]},
t
.
dataTypes
[
0
]
=
"json"
,
o
=
e
[
i
],
e
[
i
]
=
function
(){
a
=
arguments
},
r
.
always
(
function
(){
void
0
===
o
?
w
(
e
).
removeProp
(
i
):
e
[
i
]
=
o
,
t
[
i
]
&&
(
t
.
jsonpCallback
=
n
.
jsonpCallback
,
Yt
.
push
(
i
)),
a
&&
g
(
o
)
&&
o
(
a
[
0
]),
a
=
o
=
void
0
}),
"script"
}),
h
.
createHTMLDocument
=
function
(){
var
e
=
r
.
implementation
.
createHTMLDocument
(
""
).
body
;
return
e
.
innerHTML
=
"<form></form><form></form>"
,
2
===
e
.
childNodes
.
length
}(),
w
.
parseHTML
=
function
(
e
,
t
,
n
){
if
(
"string"
!=
typeof
e
)
return
[];
"boolean"
==
typeof
t
&&
(
n
=
t
,
t
=!
1
);
var
i
,
o
,
a
;
return
t
||
(
h
.
createHTMLDocument
?((
i
=
(
t
=
r
.
implementation
.
createHTMLDocument
(
""
)).
createElement
(
"base"
)).
href
=
r
.
location
.
href
,
t
.
head
.
appendChild
(
i
)):
t
=
r
),
o
=
A
.
exec
(
e
),
a
=!
n
&&
[],
o
?[
t
.
createElement
(
o
[
1
])]:(
o
=
xe
([
e
],
t
,
a
),
a
&&
a
.
length
&&
w
(
a
).
remove
(),
w
.
merge
([],
o
.
childNodes
))},
w
.
fn
.
load
=
function
(
e
,
t
,
n
){
var
r
,
i
,
o
,
a
=
this
,
s
=
e
.
indexOf
(
" "
);
return
s
>-
1
&&
(
r
=
vt
(
e
.
slice
(
s
)),
e
=
e
.
slice
(
0
,
s
)),
g
(
t
)?(
n
=
t
,
t
=
void
0
):
t
&&
"object"
==
typeof
t
&&
(
i
=
"POST"
),
a
.
length
>
0
&&
w
.
ajax
({
url
:
e
,
type
:
i
||
"GET"
,
dataType
:
"html"
,
data
:
t
}).
done
(
function
(
e
){
o
=
arguments
,
a
.
html
(
r
?
w
(
"<div>"
).
append
(
w
.
parseHTML
(
e
)).
find
(
r
):
e
)}).
always
(
n
&&
function
(
e
,
t
){
a
.
each
(
function
(){
n
.
apply
(
this
,
o
||
[
e
.
responseText
,
t
,
e
])})}),
this
},
w
.
each
([
"ajaxStart"
,
"ajaxStop"
,
"ajaxComplete"
,
"ajaxError"
,
"ajaxSuccess"
,
"ajaxSend"
],
function
(
e
,
t
){
w
.
fn
[
t
]
=
function
(
e
){
return
this
.
on
(
t
,
e
)}}),
w
.
expr
.
pseudos
.
animated
=
function
(
e
){
return
w
.
grep
(
w
.
timers
,
function
(
t
){
return
e
===
t
.
elem
}).
length
},
w
.
offset
=
{
setOffset
:
function
(
e
,
t
,
n
){
var
r
,
i
,
o
,
a
,
s
,
u
,
l
,
c
=
w
.
css
(
e
,
"position"
),
f
=
w
(
e
),
p
=
{};
"static"
===
c
&&
(
e
.
style
.
position
=
"relative"
),
s
=
f
.
offset
(),
o
=
w
.
css
(
e
,
"top"
),
u
=
w
.
css
(
e
,
"left"
),(
l
=
(
"absolute"
===
c
||
"fixed"
===
c
)
&&
(
o
+
u
).
indexOf
(
"auto"
)
>-
1
)?(
a
=
(
r
=
f
.
position
()).
top
,
i
=
r
.
left
):(
a
=
parseFloat
(
o
)
||
0
,
i
=
parseFloat
(
u
)
||
0
),
g
(
t
)
&&
(
t
=
t
.
call
(
e
,
n
,
w
.
extend
({},
s
))),
null
!=
t
.
top
&&
(
p
.
top
=
t
.
top
-
s
.
top
+
a
),
null
!=
t
.
left
&&
(
p
.
left
=
t
.
left
-
s
.
left
+
i
),
"using"
in
t
?
t
.
using
.
call
(
e
,
p
):
f
.
css
(
p
)}},
w
.
fn
.
extend
({
offset
:
function
(
e
){
if
(
arguments
.
length
)
return
void
0
===
e
?
this
:
this
.
each
(
function
(
t
){
w
.
offset
.
setOffset
(
this
,
e
,
t
)});
var
t
,
n
,
r
=
this
[
0
];
if
(
r
)
return
r
.
getClientRects
().
length
?(
t
=
r
.
getBoundingClientRect
(),
n
=
r
.
ownerDocument
.
defaultView
,{
top
:
t
.
top
+
n
.
pageYOffset
,
left
:
t
.
left
+
n
.
pageXOffset
}):{
top
:
0
,
left
:
0
}},
position
:
function
(){
if
(
this
[
0
]){
var
e
,
t
,
n
,
r
=
this
[
0
],
i
=
{
top
:
0
,
left
:
0
};
if
(
"fixed"
===
w
.
css
(
r
,
"position"
))
t
=
r
.
getBoundingClientRect
();
else
{
t
=
this
.
offset
(),
n
=
r
.
ownerDocument
,
e
=
r
.
offsetParent
||
n
.
documentElement
;
while
(
e
&&
(
e
===
n
.
body
||
e
===
n
.
documentElement
)
&&
"static"
===
w
.
css
(
e
,
"position"
))
e
=
e
.
parentNode
;
e
&&
e
!==
r
&&
1
===
e
.
nodeType
&&
((
i
=
w
(
e
).
offset
()).
top
+=
w
.
css
(
e
,
"borderTopWidth"
,
!
0
),
i
.
left
+=
w
.
css
(
e
,
"borderLeftWidth"
,
!
0
))}
return
{
top
:
t
.
top
-
i
.
top
-
w
.
css
(
r
,
"marginTop"
,
!
0
),
left
:
t
.
left
-
i
.
left
-
w
.
css
(
r
,
"marginLeft"
,
!
0
)}}},
offsetParent
:
function
(){
return
this
.
map
(
function
(){
var
e
=
this
.
offsetParent
;
while
(
e
&&
"static"
===
w
.
css
(
e
,
"position"
))
e
=
e
.
offsetParent
;
return
e
||
be
})}}),
w
.
each
({
scrollLeft
:
"pageXOffset"
,
scrollTop
:
"pageYOffset"
},
function
(
e
,
t
){
var
n
=
"pageYOffset"
===
t
;
w
.
fn
[
e
]
=
function
(
r
){
return
z
(
this
,
function
(
e
,
r
,
i
){
var
o
;
if
(
y
(
e
)?
o
=
e
:
9
===
e
.
nodeType
&&
(
o
=
e
.
defaultView
),
void
0
===
i
)
return
o
?
o
[
t
]:
e
[
r
];
o
?
o
.
scrollTo
(
n
?
o
.
pageXOffset
:
i
,
n
?
i
:
o
.
pageYOffset
):
e
[
r
]
=
i
},
e
,
r
,
arguments
.
length
)}}),
w
.
each
([
"top"
,
"left"
],
function
(
e
,
t
){
w
.
cssHooks
[
t
]
=
_e
(
h
.
pixelPosition
,
function
(
e
,
n
){
if
(
n
)
return
n
=
Fe
(
e
,
t
),
We
.
test
(
n
)?
w
(
e
).
position
()[
t
]
+
"px"
:
n
})}),
w
.
each
({
Height
:
"height"
,
Width
:
"width"
},
function
(
e
,
t
){
w
.
each
({
padding
:
"inner"
+
e
,
content
:
t
,
""
:
"outer"
+
e
},
function
(
n
,
r
){
w
.
fn
[
r
]
=
function
(
i
,
o
){
var
a
=
arguments
.
length
&&
(
n
||
"boolean"
!=
typeof
i
),
s
=
n
||
(
!
0
===
i
||!
0
===
o
?
"margin"
:
"border"
);
return
z
(
this
,
function
(
t
,
n
,
i
){
var
o
;
return
y
(
t
)?
0
===
r
.
indexOf
(
"outer"
)?
t
[
"inner"
+
e
]:
t
.
document
.
documentElement
[
"client"
+
e
]:
9
===
t
.
nodeType
?(
o
=
t
.
documentElement
,
Math
.
max
(
t
.
body
[
"scroll"
+
e
],
o
[
"scroll"
+
e
],
t
.
body
[
"offset"
+
e
],
o
[
"offset"
+
e
],
o
[
"client"
+
e
])):
void
0
===
i
?
w
.
css
(
t
,
n
,
s
):
w
.
style
(
t
,
n
,
i
,
s
)},
t
,
a
?
i
:
void
0
,
a
)}})}),
w
.
each
(
"blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu"
.
split
(
" "
),
function
(
e
,
t
){
w
.
fn
[
t
]
=
function
(
e
,
n
){
return
arguments
.
length
>
0
?
this
.
on
(
t
,
null
,
e
,
n
):
this
.
trigger
(
t
)}}),
w
.
fn
.
extend
({
hover
:
function
(
e
,
t
){
return
this
.
mouseenter
(
e
).
mouseleave
(
t
||
e
)}}),
w
.
fn
.
extend
({
bind
:
function
(
e
,
t
,
n
){
return
this
.
on
(
e
,
null
,
t
,
n
)},
unbind
:
function
(
e
,
t
){
return
this
.
off
(
e
,
null
,
t
)},
delegate
:
function
(
e
,
t
,
n
,
r
){
return
this
.
on
(
t
,
e
,
n
,
r
)},
undelegate
:
function
(
e
,
t
,
n
){
return
1
===
arguments
.
length
?
this
.
off
(
e
,
"**"
):
this
.
off
(
t
,
e
||
"**"
,
n
)}}),
w
.
proxy
=
function
(
e
,
t
){
var
n
,
r
,
i
;
if
(
"string"
==
typeof
t
&&
(
n
=
e
[
t
],
t
=
e
,
e
=
n
),
g
(
e
))
return
r
=
o
.
call
(
arguments
,
2
),
i
=
function
(){
return
e
.
apply
(
t
||
this
,
r
.
concat
(
o
.
call
(
arguments
)))},
i
.
guid
=
e
.
guid
=
e
.
guid
||
w
.
guid
++
,
i
},
w
.
holdReady
=
function
(
e
){
e
?
w
.
readyWait
++
:
w
.
ready
(
!
0
)},
w
.
isArray
=
Array
.
isArray
,
w
.
parseJSON
=
JSON
.
parse
,
w
.
nodeName
=
N
,
w
.
isFunction
=
g
,
w
.
isWindow
=
y
,
w
.
camelCase
=
G
,
w
.
type
=
x
,
w
.
now
=
Date
.
now
,
w
.
isNumeric
=
function
(
e
){
var
t
=
w
.
type
(
e
);
return
(
"number"
===
t
||
"string"
===
t
)
&&!
isNaN
(
e
-
parseFloat
(
e
))},
"function"
==
typeof
define
&&
define
.
amd
&&
define
(
"jquery"
,[],
function
(){
return
w
});
var
Jt
=
e
.
jQuery
,
Kt
=
e
.
$
;
return
w
.
noConflict
=
function
(
t
){
return
e
.
$
===
w
&&
(
e
.
$
=
Kt
),
t
&&
e
.
jQuery
===
w
&&
(
e
.
jQuery
=
Jt
),
w
},
t
||
(
e
.
jQuery
=
e
.
$
=
w
),
w
});
src/main/resources/static/update.html
deleted
100644 → 0
View file @
f8d00711
<!DOCTYPE HTML>
<html>
<head>
<title>
配置文件 v2.2.4
</title>
<script
src=
"./js/jquery-3.3.1.min.js"
></script>
<meta
charset=
UTF-8
>
</head>
<body>
<div
style=
"background-color:#ccc;-moz-border-radius: 5px;-webkit-border-radius: 5px;border:1px solid #000;padding:10px;margin-top:100px;width:800px;height:500px;text-align:center;margin:50px auto;"
>
<form
id=
"frm"
onsubmit=
"return false"
action=
"##"
method=
"post"
>
<p>
用户名:
<input
name=
"userName"
type=
"text"
id=
"txtUserName"
tabindex=
"1"
value=
""
/></p>
<p>
内 容:
<textarea
style=
"width:700px;height:320px;word-break:break-all"
name=
"config_string"
type=
"password"
id=
"config_string"
tabindex=
"2"
value=
""
></textarea></p>
<p><input
type=
"button"
value=
"查询"
onclick=
"update()"
>
<input
type=
"reset"
value=
"重置"
></p>
<p><input
type=
"button"
value=
"批量更新"
onclick=
"batch_update()"
>
<input
type=
"reset"
value=
"重置"
></p>
</form>
</div>
<div
style=
"background-color:#ccc;-moz-border-radius: 5px;-webkit-border-radius: 5px;border:1px solid #000;padding:10px;margin-top:100px;width:800px;height:auto;text-align:center;margin:50px auto;"
>
<div
id=
"returnInfo"
></div>
</div>
<script
type=
"text/javascript"
>
function
update
()
{
if
(
document
.
getElementById
(
"txtUserName"
).
value
==
""
)
{
alert
(
"用户名为必填项!"
);
return
false
;
}
$
.
ajax
({
//几个参数需要注意一下
type
:
"POST"
,
//方法类型
dataType
:
"text"
,
//预期服务器返回的数据类型
url
:
"getConfig"
,
//url
data
:
$
(
'#frm'
).
serialize
(),
success
:
function
(
result
)
{
var
list
=
result
.
split
(
"---"
)
var
str
=
""
;
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
str
+=
'<div>'
+
list
[
i
]
+
'</div>'
}
document
.
getElementById
(
"returnInfo"
).
innerHTML
=
str
},
error
:
function
(
res
)
{
// document.getElementById("returnInfo").appendChild() = res;
}
});
}
function
batch_update
()
{
var
text
=
document
.
getElementById
(
"config_string"
).
value
;
var
macroMap
=
new
Map
();
if
(
document
.
getElementById
(
"txtUserName"
).
value
==
""
)
{
alert
(
"用户名为必填项!"
);
return
false
;
}
$
.
ajax
({
//几个参数需要注意一下
type
:
"POST"
,
//方法类型
dataType
:
"text"
,
//预期服务器返回的数据类型
url
:
"http://qcloud-sh1.chewrobot.com:8081/bot/update2"
,
//url
data
:
{
"userName"
:
document
.
getElementById
(
"txtUserName"
).
value
,
"configData"
:
text
,
"type"
:
"batch_update"
,
"configId"
:
0
},
success
:
function
(
result
)
{
var
list
=
result
.
split
(
"---"
)
var
str
=
""
;
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
str
+=
'<div>'
+
list
[
i
]
+
'</div>'
}
document
.
getElementById
(
"returnInfo"
).
innerHTML
=
str
},
error
:
function
(
res
)
{
// document.getElementById("returnInfo").appendChild() = res;
}
});
}
</script>
</body>
</html>
src/main/resources/templates/index.jsp
deleted
100644 → 0
View file @
f8d00711
<
%
--
Created
by
IntelliJ
IDEA
.
User:
hxw
Date:
18-5-8
Time:
下午
1:47
To
change
this
template
use
File
|
Settings
|
File
Templates
.
--
%
>
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<html>
<head>
<title>
$Title$
</title>
</head>
<body>
$END$
</body>
</html>
src/main/resources/templates/update.html
deleted
100644 → 0
View file @
f8d00711
<!DOCTYPE HTML>
<html>
<head>
<title>
配置文件 v2.2.4
</title>
<script
src=
"../static/js/jquery-3.3.1.min.js"
></script>
<meta
charset=
UTF-8
>
</head>
<body>
<div
style=
"background-color:#ccc;-moz-border-radius: 5px;-webkit-border-radius: 5px;border:1px solid #000;padding:10px;margin-top:100px;width:800px;height:500px;text-align:center;margin:50px auto;"
>
<form
id=
"frm"
onsubmit=
"return false"
action=
"##"
method=
"post"
>
<p>
用户名:
<input
name=
"userName"
type=
"text"
id=
"txtUserName"
tabindex=
"1"
value=
""
/></p>
<p>
内 容:
<textarea
style=
"width:700px;height:320px;word-break:break-all"
name=
"config_string"
type=
"password"
id=
"config_string"
tabindex=
"2"
value=
""
></textarea></p>
<p><input
type=
"button"
value=
"查询"
onclick=
"update()"
>
<input
type=
"reset"
value=
"重置"
></p>
<p><input
type=
"button"
value=
"批量更新"
onclick=
"batch_update()"
>
<input
type=
"reset"
value=
"重置"
></p>
</form>
</div>
<div
style=
"background-color:#ccc;-moz-border-radius: 5px;-webkit-border-radius: 5px;border:1px solid #000;padding:10px;margin-top:100px;width:800px;height:auto;text-align:center;margin:50px auto;"
>
<div
id=
"returnInfo"
></div>
</div>
<script
type=
"text/javascript"
>
function
update
()
{
if
(
document
.
getElementById
(
"txtUserName"
).
value
==
""
)
{
alert
(
"用户名为必填项!"
);
return
false
;
}
$
.
ajax
({
//几个参数需要注意一下
type
:
"POST"
,
//方法类型
dataType
:
"text"
,
//预期服务器返回的数据类型
url
:
"getConfig"
,
//url
data
:
$
(
'#frm'
).
serialize
(),
success
:
function
(
result
)
{
var
list
=
result
.
split
(
"---"
)
var
str
=
""
;
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
str
+=
'<div>'
+
list
[
i
]
+
'</div>'
}
document
.
getElementById
(
"returnInfo"
).
innerHTML
=
str
},
error
:
function
(
res
)
{
// document.getElementById("returnInfo").appendChild() = res;
}
});
}
function
batch_update
()
{
var
text
=
document
.
getElementById
(
"config_string"
).
value
;
var
macroMap
=
new
Map
();
if
(
document
.
getElementById
(
"txtUserName"
).
value
==
""
)
{
alert
(
"用户名为必填项!"
);
return
false
;
}
$
.
ajax
({
//几个参数需要注意一下
type
:
"POST"
,
//方法类型
dataType
:
"text"
,
//预期服务器返回的数据类型
url
:
"http://qcloud-sh1.chewrobot.com:8081/bot/update2"
,
//url
data
:
{
"userName"
:
document
.
getElementById
(
"txtUserName"
).
value
,
"configData"
:
text
,
"type"
:
"batch_update"
,
"configId"
:
0
},
success
:
function
(
result
)
{
var
list
=
result
.
split
(
"---"
)
var
str
=
""
;
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
str
+=
'<div>'
+
list
[
i
]
+
'</div>'
}
document
.
getElementById
(
"returnInfo"
).
innerHTML
=
str
},
error
:
function
(
res
)
{
// document.getElementById("returnInfo").appendChild() = res;
}
});
}
</script>
</body>
</html>
src/main/resources/templates/update3.html
deleted
100644 → 0
View file @
f8d00711
<!DOCTYPE HTML>
<html>
<head>
<title>
配置文件
</title>
<script
src=
"./js/jquery-3.1.1.min.js"
></script>
<meta
charset=
UTF-8
>
</head>
<body>
<div
style=
"background-color:#ccc;-moz-border-radius: 5px;-webkit-border-radius: 5px;border:1px solid #000;padding:10px;margin-top:100px;width:800px;height:autopx;text-align:center;margin:50px auto;"
>
<form
id=
"frm"
onsubmit=
"return false"
action=
"##"
method=
"post"
>
<p>
用户名:
<input
name=
"userName"
type=
"text"
id=
"txtUserName"
tabindex=
"1"
value=
""
/></p>
<p>
内 容:
<br/><textarea
style=
"width:700px;height:320px;word-break:break-all"
name=
"config_string"
type=
"password"
id=
"config_string"
tabindex=
"2"
value=
""
></textarea></p>
<p>
关键词替换:
<br/><textarea
style=
"width:700px;height:100px;word-break:break-all"
name=
"macro"
type=
"password"
id=
"macro"
tabindex=
"2"
value=
""
></textarea></p>
<p><input
type=
"button"
value=
"登录"
onclick=
"update()"
>
<input
type=
"reset"
value=
"重置"
></p>
</form>
</div>
<div
style=
"background-color:#ccc;-moz-border-radius: 5px;-webkit-border-radius: 5px;border:1px solid #000;padding:10px;margin-top:100px;width:800px;height:auto;text-align:center;margin:50px auto;"
>
<div
id=
"returnInfo"
></div>
</div>
<script
type=
"text/javascript"
>
function
update
()
{
var
macroStr
=
document
.
getElementById
(
"macro"
).
value
;
var
text
=
document
.
getElementById
(
"config_string"
).
value
;
var
macroMap
=
new
Map
();
if
(
document
.
getElementById
(
"txtUserName"
).
value
==
""
)
{
alert
(
"用户名为必填项!"
);
return
false
;
}
if
(
macroStr
!=
""
)
{
var
macro
=
macroStr
.
split
(
"
\
n"
);
for
(
var
i
=
0
;
i
<
macro
.
length
;
i
++
)
{
if
(
macro
[
i
]
!=
""
)
{
pair
=
macro
[
i
].
split
(
"|"
);
if
(
pair
.
length
==
1
)
{
alert
(
"格式有误"
);
}
text
=
text
.
replace
(
pair
[
0
],
pair
[
1
]);
}
}
}
$
.
ajax
({
//几个参数需要注意一下
type
:
"POST"
,
//方法类型
dataType
:
"text"
,
//预期服务器返回的数据类型
url
:
"http://qcloud-sh1.chewrobot.com:8081/bot/update2"
,
//url
data
:
{
"userName"
:
document
.
getElementById
(
"txtUserName"
).
value
,
"configData"
:
text
,
"type"
:
"batch_update"
,
"configId"
:
0
},
success
:
function
(
result
)
{
var
list
=
result
.
split
(
"---"
)
var
str
=
""
;
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
str
+=
'<div>'
+
list
[
i
]
+
'</div>'
}
document
.
getElementById
(
"returnInfo"
).
innerHTML
=
str
},
error
:
function
(
res
)
{
// document.getElementById("returnInfo").appendChild() = res;
}
});
}
</script>
</body>
</html>
src/processing/ChatCacheController.java
View file @
7d840a91
package
processing
;
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
GameEnvironment.GameEnv
;
import
com.alibaba.fastjson.JSONObject
;
import
com.qiwu.chatbotbackend.GameEnvironment.GameEnv
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
entity.ChatCache
;
import
com.qiwu.chatbotbackend.GameEnvironment.ObjectFileUtil
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.GameEnvironment.Util
;
import
com.qiwu.chatbotbackend.entity.ChatCache
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
java.io.*
;
import
java.io.*
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
import
java.util.Map
;
import
java.util.Map
;
public
class
ChatCacheController
{
public
class
ChatCacheController
{
public
static
long
TIME_OUT
=
5000
;
private
static
String
CHAT_CACHE_DIR
=
"ChatCache"
;
private
static
String
ENV_PATH
=
CHAT_CACHE_DIR
+
"/%s env.data"
;
private
static
String
INFO_PATH
=
CHAT_CACHE_DIR
+
"/%s info.data"
;
/**
/**
* 通过chat_key获得后台保存的历史信息点
* 通过chat_key获得后台保存的历史信息点
* chatCache:存储了chatKye相对应的对话记录(历史信息点)
* chatCache:存储了chatKye相对应的对话记录(历史信息点)
...
@@ -80,58 +92,69 @@ public class ChatCacheController {
...
@@ -80,58 +92,69 @@ public class ChatCacheController {
// context.setAttribute("chatCache", keyCache);
// context.setAttribute("chatCache", keyCache);
// }
// }
public
static
boolean
saveChatCache
(
String
userName
,
HashMap
<
String
,
String
>
infoPoints
)
throws
IOException
{
public
static
boolean
saveChatCache
(
String
chatKey
,
ChatCache
chatCache
)
throws
IOException
{
String
fileDir
=
System
.
getProperty
(
"user.dir"
)
+
"/ChatCache"
;
LocalDateTime
now
=
LocalDateTime
.
now
();
String
key
;
DateTimeFormatter
format
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd hh:mm:ss"
);
String
nowStr
=
now
.
format
(
format
);
boolean
saveFlag
=
true
;
boolean
saveFlag
=
true
;
try
{
try
{
File
dir
=
new
File
(
fileDir
);
File
dir
=
new
File
(
CHAT_CACHE_DIR
);
if
(!
dir
.
exists
())
if
(!
dir
.
exists
())
dir
.
mkdir
();
dir
.
mkdir
();
File
file
=
new
File
(
fileDir
+
"/"
+
userName
+
".txt"
);
ObjectFileUtil
.
writeObjectToFile
(
chatCache
.
getGameEnv
(),
String
.
format
(
ENV_PATH
,
chatKey
.
split
(
"~"
)[
0
]));
File
file
=
new
File
(
String
.
format
(
INFO_PATH
,
chatKey
.
split
(
"~"
)[
0
]));
FileWriter
fw
=
new
FileWriter
(
file
);
FileWriter
fw
=
new
FileWriter
(
file
);
Iterator
<
String
>
infoIter
=
infoPoints
.
keySet
().
iterator
();
String
jsonString
=
JSON
.
toJSONString
(
chatCache
.
getInfoPoint
());
while
(
infoIter
.
hasNext
())
{
fw
.
write
(
jsonString
);
key
=
infoIter
.
next
();
fw
.
write
(
key
+
"-----"
+
infoPoints
.
get
(
key
)
+
"\n"
);
}
fw
.
close
();
fw
.
close
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"游戏存档时发生异常"
);
saveFlag
=
false
;
saveFlag
=
false
;
}
}
return
saveFlag
;
return
saveFlag
;
}
}
public
static
boolean
loadChatCache
(
String
userName
,
ServletContext
context
)
{
public
static
ChatCache
loadChatCache
(
String
chatKey
,
ServletContext
context
,
UserInfo
userInfo
)
throws
Exception
{
ChatCache
chatCache
=
null
;
GameEnv
gameEnv
=
null
;
Map
<
String
,
String
>
infoPoint
=
null
;
String
key
=
chatKey
.
split
(
"~"
)[
0
];
String
fileDir
=
System
.
getProperty
(
"user.dir"
)
+
"/ChatCache"
;
String
fileDir
=
System
.
getProperty
(
"user.dir"
)
+
"/ChatCache"
;
String
line
,
pair
[];
String
line
,
pair
[];
Map
<
String
,
String
>
infoPoints
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
infoPoints
=
new
HashMap
<
String
,
String
>();
try
{
try
{
File
file
=
new
File
(
fileDir
+
"/"
+
userName
+
".txt"
);
gameEnv
=
(
GameEnv
)
ObjectFileUtil
.
readObjectFromFile
(
String
.
format
(
ENV_PATH
,
key
)
);
if
(!
file
.
exists
())
{
return
false
;
}
else
{
File
file
=
new
File
(
String
.
format
(
INFO_PATH
,
key
));
FileReader
fr
=
new
FileReader
(
file
);
FileReader
fr
=
new
FileReader
(
file
);
BufferedReader
br
=
new
BufferedReader
(
fr
);
BufferedReader
br
=
new
BufferedReader
(
fr
);
while
((
line
=
br
.
readLine
())
!=
null
)
{
String
jsonStr
=
br
.
readLine
();
pair
=
line
.
trim
().
split
(
"-----"
);
infoPoint
=
(
Map
)
JSON
.
parseObject
(
jsonStr
);
infoPoints
.
put
(
pair
[
0
],
pair
[
1
]);
}
// context.setAttribute(userName, );
// context.setAttribute(userName, );
chatCache
=
new
ChatCache
(
gameEnv
,
infoPoint
);
fr
.
close
();
fr
.
close
();
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
chatCache
=
new
ChatCache
(
userInfo
);
}
}
return
tru
e
;
return
chatCach
e
;
}
}
...
@@ -139,9 +162,15 @@ public class ChatCacheController {
...
@@ -139,9 +162,15 @@ public class ChatCacheController {
public
static
synchronized
ChatCache
getChatCache
2
(
String
chatKey
,
ServletContext
context
,
UserInfo
userinfo
)
throws
Exception
{
public
static
synchronized
ChatCache
getChatCache
(
String
chatKey
,
ServletContext
context
,
UserInfo
userinfo
,
Boolean
loadCache
)
throws
Exception
{
Map
<
String
,
ChatCache
>
chatCacheMap
=
null
;
Map
<
String
,
ChatCache
>
chatCacheMap
=
null
;
ChatCache
chatCache
=
null
;
ChatCache
chatCache
=
null
;
if
(
loadCache
){
loadChatCache
(
chatKey
,
context
,
userinfo
);
}
if
(
context
.
getAttribute
(
"chatCache"
)
==
null
)
{
if
(
context
.
getAttribute
(
"chatCache"
)
==
null
)
{
chatCacheMap
=
new
HashMap
<
String
,
ChatCache
>();
chatCacheMap
=
new
HashMap
<
String
,
ChatCache
>();
chatCacheMap
.
put
(
chatKey
,
new
ChatCache
(
userinfo
));
chatCacheMap
.
put
(
chatKey
,
new
ChatCache
(
userinfo
));
...
@@ -152,6 +181,7 @@ public class ChatCacheController {
...
@@ -152,6 +181,7 @@ public class ChatCacheController {
String
chatkey
;
String
chatkey
;
try
{
try
{
chatCache
=
chatCacheMap
.
get
(
chatKey
);
chatCache
=
chatCacheMap
.
get
(
chatKey
);
if
(
chatCache
==
null
){
if
(
chatCache
==
null
){
...
@@ -172,7 +202,7 @@ public class ChatCacheController {
...
@@ -172,7 +202,7 @@ public class ChatCacheController {
/**
/**
* chatChche中每个chatkey都有对应的最后更新时间,如果最后更新时间已经是x分钟前(超时),就清除该chatKey的数据
* chatChche中每个chatkey都有对应的最后更新时间,如果最后更新时间已经是x分钟前(超时),就清除该chatKey的数据
*/
*/
public
static
synchronized
void
updateChatCache4Delete
2
(
String
curChatKey
,
ServletContext
context
)
{
public
static
synchronized
void
updateChatCache4Delete
(
String
curChatKey
,
ServletContext
context
)
throws
IOException
{
String
chatKey
;
String
chatKey
;
ChatCache
chatCache
=
null
;
ChatCache
chatCache
=
null
;
long
lastChatTime
,
now
;
long
lastChatTime
,
now
;
...
@@ -188,7 +218,9 @@ public class ChatCacheController {
...
@@ -188,7 +218,9 @@ public class ChatCacheController {
history
=
chatCacheMap
.
get
(
chatKey
).
getInfoPoint
();
history
=
chatCacheMap
.
get
(
chatKey
).
getInfoPoint
();
lastChatTime
=
Long
.
valueOf
(
history
.
get
(
"lastUpdateTime"
));
lastChatTime
=
Long
.
valueOf
(
history
.
get
(
"lastUpdateTime"
));
now
=
System
.
currentTimeMillis
();
now
=
System
.
currentTimeMillis
();
if
(
now
-
lastChatTime
>
300000
)
{
if
(
now
-
lastChatTime
>
ChatCacheController
.
TIME_OUT
)
{
chatCache
=
chatCacheMap
.
get
(
chatKey
);
saveChatCache
(
"1909509284"
,
chatCache
);
it
.
remove
();
it
.
remove
();
}
}
}
}
...
@@ -198,7 +230,7 @@ public class ChatCacheController {
...
@@ -198,7 +230,7 @@ public class ChatCacheController {
/**
/**
* 根据chatKey更新chatCache的数据,并修改最后更新时间
* 根据chatKey更新chatCache的数据,并修改最后更新时间
*/
*/
public
static
synchronized
void
updateChatCache4Insert
2
(
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
GameEnv
gameEnv
,
ServletContext
context
)
{
public
static
synchronized
void
updateChatCache4Insert
(
Map
<
String
,
String
>
curInfoPoint
,
Map
<
String
,
String
>
historyInfoPoint
,
GameEnv
gameEnv
,
ServletContext
context
)
{
historyInfoPoint
.
put
(
"lastUpdateTime"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
historyInfoPoint
.
put
(
"lastUpdateTime"
,
String
.
valueOf
(
System
.
currentTimeMillis
()));
Map
<
String
,
ChatCache
>
keyCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
Map
<
String
,
ChatCache
>
keyCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
ChatCache
chatCache
=
keyCacheMap
.
get
(
curInfoPoint
.
get
(
"chat_key"
));
ChatCache
chatCache
=
keyCacheMap
.
get
(
curInfoPoint
.
get
(
"chat_key"
));
...
@@ -207,27 +239,26 @@ public class ChatCacheController {
...
@@ -207,27 +239,26 @@ public class ChatCacheController {
context
.
setAttribute
(
"chatCache"
,
keyCacheMap
);
context
.
setAttribute
(
"chatCache"
,
keyCacheMap
);
}
}
public
static
synchronized
String
saveChatCache
(
String
chatKey
,
ServletContext
context
){
// public static synchronized String saveChatCache(String chatKey, ChatCache chatCache){
Map
<
String
,
ChatCache
>
chatCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
//
ChatCache
chatCache
=
chatCacheMap
.
get
(
chatKey
);
//
// if(chatCache == null){
if
(
chatCache
==
null
){
// return "chat_key不存在或者已失效";
return
"chat_key不存在或者已失效"
;
// }else {
}
else
{
// String jChatCache = JSON.toJSONString(chatCache);
String
jChatCache
=
JSON
.
toJSONString
(
chatCache
);
// System.out.println(jChatCache);
System
.
out
.
println
(
jChatCache
);
//
//
//
// chatCache = JSON.parseObject(jChatCache,ChatCache.class);
chatCache
=
JSON
.
parseObject
(
jChatCache
,
ChatCache
.
class
);
// System.out.println(chatCache.getInfoPoint().size());
System
.
out
.
println
(
chatCache
.
getInfoPoint
().
size
());
//
// return "成功";
return
"成功"
;
// }
}
//
//
//
// }
}
}
}
src/processing/ConditionTableController.java
View file @
7d840a91
package
processing
;
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
entity.Condition
;
import
com.qiwu.chatbotbackend.
entity.Condition
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
java.io.BufferedWriter
;
import
java.io.BufferedWriter
;
...
...
src/processing/LogWriter.java
View file @
7d840a91
package
processing
;
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
java.io.*
;
import
java.io.*
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
public
class
LogWriter
{
public
class
LogWriter
{
private
PrintWriter
recorder
=
null
;
private
PrintWriter
recorder
=
null
;
String
PRINT_PATTERN
=
"<font color=\"%s\">%s"
+
DateTimeFormatter
dtf
=
DateTimeFormatter
.
ofPattern
(
"MM-dd HH:mm:ss"
);
LocalDateTime
ldt
=
null
;
String
PRINT_PATTERN
=
"<font color=\"%s\">[%s] %s"
+
"----------------------------------------------------------------------------<br></font>"
;
"----------------------------------------------------------------------------<br></font>"
;
Map
<
Integer
,
String
>
colerMap
=
new
HashMap
<
Integer
,
String
>(){
Map
<
Integer
,
String
>
colerMap
=
new
HashMap
<
Integer
,
String
>(){
{
{
put
(
0
,
"black"
);
put
(
0
,
"black"
);
put
(
1
,
"gray"
);
put
(
1
,
"gray"
);
put
(
2
,
"green"
);
put
(
2
,
"green"
);
put
(
3
,
"red"
);
put
(
3
,
"yellow"
);
put
(
4
,
"green"
);
put
(
5
,
"red"
);
}
}
};
};
public
LogWriter
(
String
filePath
,
String
fileName
)
throws
IOException
{
public
LogWriter
(
String
filePath
,
String
fileName
)
throws
IOException
{
File
file
=
new
File
(
filePath
+
"/"
+
fileName
+
".html"
);
File
file
=
new
File
(
filePath
+
"/"
+
fileName
+
".html"
);
System
.
out
.
println
(
file
.
getAbsolutePath
());
if
(!
file
.
exists
())
{
if
(!
file
.
exists
())
{
file
.
createNewFile
();
file
.
createNewFile
();
}
}
file
.
setReadable
(
true
,
false
);
file
.
setReadable
(
true
,
false
);
FileWriter
fw
=
new
FileWriter
(
file
,
true
);
FileWriter
fw
=
new
FileWriter
(
file
,
true
);
//BufferedWriter bw = new BufferedWriter(fos, "UTF-8");
//context.setAttribute("logWriter", bw);
BufferedWriter
bw
=
new
BufferedWriter
(
fw
);
BufferedWriter
bw
=
new
BufferedWriter
(
fw
);
...
@@ -40,7 +47,11 @@ public class LogWriter {
...
@@ -40,7 +47,11 @@ public class LogWriter {
}
}
public
void
record
(
String
text
,
int
level
){
public
void
record
(
String
text
,
int
level
){
recorder
.
println
(
String
.
format
(
PRINT_PATTERN
,
colerMap
.
get
(
level
),
text
));
ldt
=
LocalDateTime
.
now
();
recorder
.
println
(
String
.
format
(
PRINT_PATTERN
,
colerMap
.
get
(
level
),
ldt
.
format
(
dtf
),
text
));
}
public
void
writeln
(){
recorder
.
println
(
"<br>"
);
}
}
public
void
close
(){
public
void
close
(){
...
...
src/processing/MyFunc.java
View file @
7d840a91
package
processing
;
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
entity.Solution
;
import
com.qiwu.chatbotbackend.
entity.Solution
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
import
org.apache.http.client.entity.UrlEncodedFormEntity
;
...
...
src/processing/QuestionMatcher.java
View file @
7d840a91
package
processing
;
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
GameEnvironment.GameEnv
;
import
com.alibaba.fastjson.JSONObject
;
import
entity.Solution
;
import
com.qiwu.chatbotbackend.GameEnvironment.GameEnv
;
import
entity.Condi
tion
;
import
com.qiwu.chatbotbackend.entity.Solu
tion
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.entity.Condition
;
import
net.sf.json.JSONObject
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpResponse
;
...
@@ -25,7 +25,7 @@ import java.util.regex.Pattern;
...
@@ -25,7 +25,7 @@ import java.util.regex.Pattern;
public
class
QuestionMatcher
{
public
class
QuestionMatcher
{
static
Map
<
Integer
,
Condition
>
activatedMap
=
new
HashMap
<
Integer
,
Condition
>();
Map
<
Integer
,
Condition
>
activatedMap
=
new
HashMap
<
Integer
,
Condition
>();
static
String
POST_DATA_ERROR
=
"post数据有误"
;
static
String
POST_DATA_ERROR
=
"post数据有误"
;
...
@@ -182,7 +182,7 @@ public class QuestionMatcher {
...
@@ -182,7 +182,7 @@ public class QuestionMatcher {
for
(
Condition
condition
:
conditionList
)
{
for
(
Condition
condition
:
conditionList
)
{
if
(
condition
.
status
.
equals
(
"waiting"
)
&&
conditionSatisfy
(
condition
))
{
if
(
condition
.
status
.
equals
(
"waiting"
)
&&
conditionSatisfy
(
condition
))
{
logWriter
.
record
(
"-----匹配更新为------"
+
userInfo
.
id2config
.
get
(
condition
.
id
)
+
"-----------<br>"
,
2
);
if
(
condition
.
featureMap
.
get
(
"instantPost"
)
!=
null
)
{
if
(
condition
.
featureMap
.
get
(
"instantPost"
)
!=
null
)
{
...
@@ -193,11 +193,15 @@ public class QuestionMatcher {
...
@@ -193,11 +193,15 @@ public class QuestionMatcher {
if
(
condition
.
featureMap
.
get
(
"activate"
)
!=
null
&&
!
condition
.
featureMap
.
containsKey
(
"post"
))
{
if
(
condition
.
featureMap
.
get
(
"activate"
)
!=
null
&&
!
condition
.
featureMap
.
containsKey
(
"post"
))
{
//有post这个feature的配置条目会在最后激活它的待激活列表,这里就不激活了。
//有post这个feature的配置条目会在最后激活它的待激活列表,这里就不激活了。
bestMatch
=
condition
;
bestMatch
=
condition
;
logWriter
.
record
(
"匹配更新为:\""
+
userinfo
.
id2config
.
get
(
condition
.
id
)
+
"\""
,
2
);
logWriter
.
writeln
();
activateCondition
(
activatedQueue
,
curInfoPoint
.
get
(
"bot_name"
),
condition
.
priority
,
condition
.
auxiliaryPriority
,
condition
.
nextStep
,
context
);
activateCondition
(
activatedQueue
,
curInfoPoint
.
get
(
"bot_name"
),
condition
.
priority
,
condition
.
auxiliaryPriority
,
condition
.
nextStep
,
context
);
//} else if ((condition.priority > bestMatch.priority) || (condition.priority == bestMatch.priority && condition.auxiliaryPriority > bestMatch.auxiliaryPriority))
//} else if ((condition.priority > bestMatch.priority) || (condition.priority == bestMatch.priority && condition.auxiliaryPriority > bestMatch.auxiliaryPriority))
}
else
if
((
condition
.
auxiliaryPriority
>
bestMatch
.
auxiliaryPriority
)
||
(
condition
.
auxiliaryPriority
==
bestMatch
.
auxiliaryPriority
&&
condition
.
priority
>
bestMatch
.
priority
))
}
else
if
((
condition
.
auxiliaryPriority
>
bestMatch
.
auxiliaryPriority
)
||
(
condition
.
auxiliaryPriority
==
bestMatch
.
auxiliaryPriority
&&
condition
.
priority
>
bestMatch
.
priority
))
{
bestMatch
=
condition
;
bestMatch
=
condition
;
logWriter
.
record
(
"匹配更新为:\""
+
userinfo
.
id2config
.
get
(
condition
.
id
)
+
"\""
,
2
);
logWriter
.
writeln
();
}
}
}
}
}
}
}
...
@@ -228,13 +232,13 @@ public class QuestionMatcher {
...
@@ -228,13 +232,13 @@ public class QuestionMatcher {
if
(
conditionSatisfy
(
condition
))
{
if
(
conditionSatisfy
(
condition
))
{
if
(
condition
.
featureMap
.
containsKey
(
"activate"
)
&&
!
condition
.
featureMap
.
containsKey
(
"post"
))
{
if
(
condition
.
featureMap
.
containsKey
(
"activate"
)
&&
!
condition
.
featureMap
.
containsKey
(
"post"
))
{
logWriter
.
record
(
"
------激活匹配更新为------"
+
userinfo
.
id2config
.
get
(
condition
.
id
)
+
"-----------"
,
0
);
logWriter
.
record
(
"
匹配更新为:\""
+
userinfo
.
id2config
.
get
(
condition
.
id
)
+
"\""
,
2
);
logWriter
.
writeln
(
);
bestMatch
=
condition
;
bestMatch
=
condition
;
activateCondition
(
activatedQueue
,
curInfoPoint
.
get
(
"bot_name"
),
condition
.
priority
,
condition
.
auxiliaryPriority
,
condition
.
nextStep
,
context
);
activateCondition
(
activatedQueue
,
curInfoPoint
.
get
(
"bot_name"
),
condition
.
priority
,
condition
.
auxiliaryPriority
,
condition
.
nextStep
,
context
);
//} else if ((condition.activePriority > bestMatch.activePriority) || (condition.activePriority == bestMatch.activePriority && condition.auxiliaryPriority > bestMatch.auxiliaryPriority)) {
//} else if ((condition.activePriority > bestMatch.activePriority) || (condition.activePriority == bestMatch.activePriority && condition.auxiliaryPriority > bestMatch.auxiliaryPriority)) {
}
else
if
((
condition
.
auxiliaryPriority
>
bestMatch
.
auxiliaryPriority
)
||
(
condition
.
auxiliaryPriority
==
bestMatch
.
auxiliaryPriority
&&
condition
.
activePriority
>
bestMatch
.
activePriority
))
{
}
else
if
((
condition
.
auxiliaryPriority
>
bestMatch
.
auxiliaryPriority
)
||
(
condition
.
auxiliaryPriority
==
bestMatch
.
auxiliaryPriority
&&
condition
.
activePriority
>
bestMatch
.
activePriority
))
{
bestMatch
=
condition
;
bestMatch
=
condition
;
logWriter
.
record
(
"
------激活匹配更新为------"
+
userinfo
.
id2config
.
get
(
condition
.
id
)
+
"-------<br>"
,
0
);
logWriter
.
record
(
"
匹配更新为:\""
+
userinfo
.
id2config
.
get
(
condition
.
id
)
+
"\""
,
2
);
logWriter
.
writeln
(
);
}
}
}
}
...
@@ -272,8 +276,7 @@ public class QuestionMatcher {
...
@@ -272,8 +276,7 @@ public class QuestionMatcher {
if
(
keyword
==
null
)
{
if
(
keyword
==
null
)
{
flag
=
false
;
flag
=
false
;
if
(
flag
==
false
){
if
(
flag
==
false
){
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过--------------------------------------------------------"
+
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过------------------------"
,
5
);
logWriter
.
writeln
();
"<br>--------------------------------------------------------"
,
0
);
}
}
break
;
break
;
}
}
...
@@ -283,8 +286,7 @@ public class QuestionMatcher {
...
@@ -283,8 +286,7 @@ public class QuestionMatcher {
flag
=
false
;
flag
=
false
;
if
(
flag
==
false
){
if
(
flag
==
false
){
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过--------------------------------"
+
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过------------------------"
,
5
);
logWriter
.
writeln
();
"<br>--------------------------------------------------------"
,
0
);
}
}
}
}
...
@@ -299,8 +301,7 @@ public class QuestionMatcher {
...
@@ -299,8 +301,7 @@ public class QuestionMatcher {
if
(
keyword
==
null
)
{
if
(
keyword
==
null
)
{
flag
=
false
;
flag
=
false
;
if
(
flag
==
false
){
if
(
flag
==
false
){
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过-----------------------------"
+
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过------------------------"
,
5
);
logWriter
.
writeln
();
"<br>--------------------------------------------------------"
,
0
);
}
}
break
;
break
;
}
}
...
@@ -312,7 +313,7 @@ public class QuestionMatcher {
...
@@ -312,7 +313,7 @@ public class QuestionMatcher {
flag
=
false
;
flag
=
false
;
if
(
flag
==
false
){
if
(
flag
==
false
){
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过
<br>"
,
0
);
logWriter
.
record
(
"-----------------------"
+
premiseStr
+
"不匹配,跳过
------------------------"
,
5
);
logWriter
.
writeln
(
);
}
}
}
}
}
}
...
@@ -703,7 +704,8 @@ public class QuestionMatcher {
...
@@ -703,7 +704,8 @@ public class QuestionMatcher {
//nextNext关键字
//nextNext关键字
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//updateKnowledge关键字
//updateKnowledge关键字
if
(
ansCondition
.
featureMap
.
containsKey
(
"updateKnowledge"
))
{
if
(
ansCondition
.
featureMap
.
containsKey
(
"updateKnowledge"
))
{
...
@@ -712,6 +714,8 @@ public class QuestionMatcher {
...
@@ -712,6 +714,8 @@ public class QuestionMatcher {
logWriter
.
record
(
"---------------------更新答案结束"
,
1
);
logWriter
.
record
(
"---------------------更新答案结束"
,
1
);
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
if
(
ansCondition
.
featureMap
.
containsKey
(
"newNext"
))
{
if
(
ansCondition
.
featureMap
.
containsKey
(
"newNext"
))
{
...
@@ -740,6 +744,8 @@ public class QuestionMatcher {
...
@@ -740,6 +744,8 @@ public class QuestionMatcher {
}
}
}
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
if
(
ans
.
getNext
().
equals
(
""
))
{
if
(
ans
.
getNext
().
equals
(
""
))
{
...
@@ -760,6 +766,9 @@ public class QuestionMatcher {
...
@@ -760,6 +766,9 @@ public class QuestionMatcher {
reply
=
reply
.
replace
(
"{"
+
variable
+
"-1}"
,
curInfoPoint
.
get
(
variable
));
reply
=
reply
.
replace
(
"{"
+
variable
+
"-1}"
,
curInfoPoint
.
get
(
variable
));
}
else
if
(
m
.
group
(
1
).
endsWith
(
"-2}"
))
{
}
else
if
(
m
.
group
(
1
).
endsWith
(
"-2}"
))
{
if
(
historyInfoPoint
.
get
(
variable
)
!=
null
)
if
(
historyInfoPoint
.
get
(
variable
)
!=
null
)
if
(
historyInfoPoint
.
get
(
variable
).
equals
(
"do_reset"
)){
reply
=
reply
.
replace
(
"{"
+
variable
+
"-2}"
,
""
);
}
else
reply
=
reply
.
replace
(
"{"
+
variable
+
"-2}"
,
historyInfoPoint
.
get
(
variable
));
reply
=
reply
.
replace
(
"{"
+
variable
+
"-2}"
,
historyInfoPoint
.
get
(
variable
));
}
}
}
}
...
@@ -823,7 +832,7 @@ public class QuestionMatcher {
...
@@ -823,7 +832,7 @@ public class QuestionMatcher {
}
}
ChatCacheController
.
updateChatCache4Insert
2
(
curInfoPoint
,
historyInfoPoint
,
gameEnv
,
context
);
ChatCacheController
.
updateChatCache4Insert
(
curInfoPoint
,
historyInfoPoint
,
gameEnv
,
context
);
//context.setAttribute("chat_key+"+userinfo.botAccount,historyInfoPoint);
//context.setAttribute("chat_key+"+userinfo.botAccount,historyInfoPoint);
...
@@ -861,9 +870,13 @@ public class QuestionMatcher {
...
@@ -861,9 +870,13 @@ public class QuestionMatcher {
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
key
=
it
.
next
();
key
=
it
.
next
();
values
=
curInfoPoint
.
get
(
key
);
values
=
curInfoPoint
.
get
(
key
);
if
(
values
!=
null
&&
!
values
.
equals
(
" "
)
&&
!
values
.
equals
(
""
)
&&
!
skipSet
.
contains
(
key
))
if
(
values
!=
null
&&
!
values
.
equals
(
" "
)
&&
!
values
.
equals
(
""
)
&&
!
skipSet
.
contains
(
key
))
{
if
(
key
.
endsWith
(
"_backup"
))
{
key
=
key
.
substring
(
0
,
key
.
length
()
-
7
);
}
debugInfo
+=
(
" "
+
key
+
":\'"
+
values
+
"\' "
);
debugInfo
+=
(
" "
+
key
+
":\'"
+
values
+
"\' "
);
}
}
}
debugInfo
+=
")(已知:"
;
debugInfo
+=
")(已知:"
;
it
=
historyInfoPoint
.
keySet
().
iterator
();
it
=
historyInfoPoint
.
keySet
().
iterator
();
...
@@ -871,7 +884,7 @@ public class QuestionMatcher {
...
@@ -871,7 +884,7 @@ public class QuestionMatcher {
key
=
it
.
next
();
key
=
it
.
next
();
value
=
historyInfoPoint
.
get
(
key
);
value
=
historyInfoPoint
.
get
(
key
);
if
(
value
!=
null
&&
!
value
.
equals
(
" "
)
&&
!
value
.
equals
(
""
)
&&
!
skipSet
.
contains
(
key
))
if
(
value
!=
null
&&
!
value
.
equals
(
" "
)
&&
!
value
.
equals
(
""
)
&&
!
skipSet
.
contains
(
key
)
&&
!
key
.
endsWith
(
"最后的回答"
)
&&
!
key
.
endsWith
(
"最后一个condition"
)
)
debugInfo
+=
(
" "
+
key
+
":\'"
+
value
+
"\' "
);
debugInfo
+=
(
" "
+
key
+
":\'"
+
value
+
"\' "
);
}
}
...
@@ -965,8 +978,8 @@ public class QuestionMatcher {
...
@@ -965,8 +978,8 @@ public class QuestionMatcher {
HttpEntity
he
=
resp
.
getEntity
();
HttpEntity
he
=
resp
.
getEntity
();
respContent
=
EntityUtils
.
toString
(
he
,
"UTF-8"
);
respContent
=
EntityUtils
.
toString
(
he
,
"UTF-8"
);
logWriter
.
record
(
"提交表单接收到的数据:<br>"
+
respContent
,
2
);
logWriter
.
record
(
"提交表单接收到的数据:<br>"
+
respContent
,
2
);
JSONObject
jobj
=
JSONObject
.
fromString
(
respContent
);
JSONObject
jobj
=
JSONObject
.
parseObject
(
respContent
);
Iterator
<
String
>
kit
=
jobj
.
key
s
();
Iterator
<
String
>
kit
=
jobj
.
key
Set
().
iterator
();
while
(
kit
.
hasNext
())
{
while
(
kit
.
hasNext
())
{
keyName
=
kit
.
next
();
keyName
=
kit
.
next
();
...
@@ -1171,8 +1184,12 @@ public class QuestionMatcher {
...
@@ -1171,8 +1184,12 @@ public class QuestionMatcher {
}
}
if
(
updateValue
.
equals
(
""
))
if
(
updateValue
.
equals
(
""
))
{
updateValue
=
"do_reset"
;
curInfoPoint
.
put
(
variableName
+
"_backup"
,
curInfoPoint
.
get
(
variableName
));
//更新答案将某变量设为空时,要将当前信息点也清空,不然后边信息点转移时这个变量的已知信息依然不是空的。
// 为了避免将当前信息点清空后debug信息显示不完整,现创造一个备份,在appendDebugInfo后会将这个备份清空。
curInfoPoint
.
put
(
variableName
,
""
);
}
historyInfoPoint
.
put
(
variableName
,
updateValue
);
historyInfoPoint
.
put
(
variableName
,
updateValue
);
}
}
...
...
src/processing/UserInfoController.java
View file @
7d840a91
package
processing
;
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
entity.Condition
;
import
com.qiwu.chatbotbackend.
entity.Condition
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
java.io.*
;
import
java.io.*
;
...
@@ -24,6 +24,8 @@ public class UserInfoController {
...
@@ -24,6 +24,8 @@ public class UserInfoController {
String
line
;
String
line
;
System
.
out
.
println
(
"configDir"
+
CONFIG_DIR
);
File
dir
=
new
File
(
CONFIG_DIR
);
File
dir
=
new
File
(
CONFIG_DIR
);
if
(!
dir
.
exists
())
if
(!
dir
.
exists
())
dir
.
mkdir
();
dir
.
mkdir
();
...
@@ -51,6 +53,8 @@ public class UserInfoController {
...
@@ -51,6 +53,8 @@ public class UserInfoController {
public
static
void
userConfigInit
(
String
botAccount
,
ServletContext
context
)
throws
IOException
{
public
static
void
userConfigInit
(
String
botAccount
,
ServletContext
context
)
throws
IOException
{
String
line
;
String
line
;
File
userFile
=
new
File
(
CONFIG_DIR
+
"/"
+
botAccount
+
".txt"
);
File
userFile
=
new
File
(
CONFIG_DIR
+
"/"
+
botAccount
+
".txt"
);
System
.
out
.
println
(
userFile
.
getAbsolutePath
());
if
(!
userFile
.
exists
())
{
if
(!
userFile
.
exists
())
{
BufferedReader
br
=
new
BufferedReader
(
new
StringReader
(
""
));
BufferedReader
br
=
new
BufferedReader
(
new
StringReader
(
""
));
UserInfo
userinfo
=
new
UserInfo
(
botAccount
);
UserInfo
userinfo
=
new
UserInfo
(
botAccount
);
...
@@ -107,7 +111,7 @@ public class UserInfoController {
...
@@ -107,7 +111,7 @@ public class UserInfoController {
condition
.
answer
=
next
[
0
].
split
(
"~"
);
condition
.
answer
=
next
[
0
].
split
(
"~"
);
//condition.nextStep = next[1];
//condition.nextStep = next[1];
//第二处
//第二处
condition
.
nextStep
=
next
[
1
].
split
(
"="
)[
1
];
condition
.
nextStep
=
next
[
1
].
split
(
"="
,
2
)[
1
];
condition
.
id
=
Integer
.
parseInt
(
next
[
3
].
split
(
"="
)[
1
]);
condition
.
id
=
Integer
.
parseInt
(
next
[
3
].
split
(
"="
)[
1
]);
condition
.
status
=
next
[
2
].
split
(
"="
)[
1
];
condition
.
status
=
next
[
2
].
split
(
"="
)[
1
];
...
@@ -275,8 +279,10 @@ public class UserInfoController {
...
@@ -275,8 +279,10 @@ public class UserInfoController {
userConfigInit
(
botAccount
,
context
);
userConfigInit
(
botAccount
,
context
);
}
}
if
(
context
.
getAttribute
(
botAccount
)
==
null
)
{
if
(
context
.
getAttribute
(
botAccount
)
==
null
)
{
userinfo
=
new
UserInfo
(
botAccount
);
userinfo
.
conditionTable
=
new
HashMap
<
String
,
List
<
Condition
>>();
return
null
;
//userinfo = new UserInfo(botAccount);
//userinfo.conditionTable = new HashMap<String, List<Condition>>();
}
else
{
}
else
{
userinfo
=
(
UserInfo
)
context
.
getAttribute
(
botAccount
);
userinfo
=
(
UserInfo
)
context
.
getAttribute
(
botAccount
);
}
}
...
...
src/processing/WorldController.java
View file @
7d840a91
package
processing
;
package
com
.
qiwu
.
chatbotbackend
.
processing
;
import
GameEnvironment.GameEnv
;
import
com.qiwu.chatbotbackend.
GameEnvironment.GameEnv
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -21,7 +21,7 @@ public class WorldController {
...
@@ -21,7 +21,7 @@ public class WorldController {
List
<
String
>
textList
=
null
;
List
<
String
>
textList
=
null
;
String
subValuePair
[]
=
null
;
String
subValuePair
[]
=
null
;
logWriter
.
record
(
String
.
format
(
"
%s(%s, %s, %s)"
,
varName
,
varValue
,
historyInfoPoint
.
get
(
"site"
)
),
0
);
logWriter
.
record
(
String
.
format
(
"
---------------------key:%s, value:%s"
,
varName
,
varValue
),
0
);
if
(
valuePair
[
0
].
startsWith
(
"query"
)){
//查询专用
if
(
valuePair
[
0
].
startsWith
(
"query"
)){
//查询专用
...
@@ -29,20 +29,22 @@ public class WorldController {
...
@@ -29,20 +29,22 @@ public class WorldController {
if
(
varName
.
startsWith
(
"goods_"
))
{
if
(
varName
.
startsWith
(
"goods_"
))
{
switch
(
valuePair
[
0
])
{
switch
(
valuePair
[
0
])
{
case
"queryGoodsIntro"
:
case
"queryGoodsIntro"
:
returnStr
=
gameEnv
.
queryGoodsIntroByGoodsName
(
varName
);
subValuePair
=
currentInfoPoint
.
get
(
valuePair
[
1
]).
split
(
":"
,
2
);
if
(
returnStr
==
null
)
returnStr
=
gameEnv
.
queryGoodsIntroByGoodsName
(
subValuePair
[
1
]);
if
(
returnStr
==
null
)
returnStr
=
"无"
;
returnStr
=
"无"
;
break
;
break
;
case
"queryAttrByGoodsName"
:
case
"queryAttrByGoodsName"
:
subValuePair
=
currentInfoPoint
.
get
(
valuePair
[
1
]).
split
(
":"
,
2
);
subValuePair
=
currentInfoPoint
.
get
(
valuePair
[
1
]).
split
(
":"
,
2
);
subValuePair
[
0
]
=
subValuePair
[
0
].
replace
(
"哪里"
,
"location"
);
returnStr
=
gameEnv
.
queryGoodsAttrByGoodsName
(
subValuePair
[
0
],
subValuePair
[
1
]);
returnStr
=
gameEnv
.
queryGoodsAttrByGoodsName
(
subValuePair
[
0
],
subValuePair
[
1
]);
if
(
returnStr
==
null
)
if
(
returnStr
==
null
)
returnStr
=
"无"
;
returnStr
=
"无"
;
break
;
break
;
case
"queryAllAttrByGoodsName"
:
case
"queryAllAttrByGoodsName"
:
textList
=
gameEnv
.
queryGoodsAllAttrByGoodsName
(
varName
);
textList
=
gameEnv
.
queryGoodsAllAttrByGoodsName
(
varName
);
if
(
textList
==
null
)
if
(
textList
==
null
||
textList
.
size
()
==
0
)
returnStr
=
"无"
;
returnStr
=
"无"
;
else
{
else
{
for
(
String
site
:
textList
)
for
(
String
site
:
textList
)
...
@@ -52,7 +54,7 @@ public class WorldController {
...
@@ -52,7 +54,7 @@ public class WorldController {
break
;
break
;
case
"queryAroundGoodsByClassName"
:
case
"queryAroundGoodsByClassName"
:
textList
=
gameEnv
.
queryGoodsByClassAndSite
(
namePair
[
1
],
historyInfoPoint
.
get
(
"site"
));
textList
=
gameEnv
.
queryGoodsByClassAndSite
(
namePair
[
1
],
historyInfoPoint
.
get
(
"site"
));
if
(
textList
==
null
)
if
(
textList
==
null
||
textList
.
size
()
==
0
)
returnStr
=
"无"
;
returnStr
=
"无"
;
else
{
else
{
for
(
String
site
:
textList
)
for
(
String
site
:
textList
)
...
@@ -101,12 +103,16 @@ public class WorldController {
...
@@ -101,12 +103,16 @@ public class WorldController {
sites
=
gameEnv
.
queryPathBySite
(
historyInfoPoint
.
get
(
"site"
),
valuePair
[
1
]);
sites
=
gameEnv
.
queryPathBySite
(
historyInfoPoint
.
get
(
"site"
),
valuePair
[
1
]);
break
;
break
;
}
}
if
(
sites
==
null
)
if
(
sites
==
null
||
sites
.
size
()
==
0
)
returnStr
=
"
无
"
;
returnStr
=
"
啥都没有
"
;
else
{
else
{
returnStr
=
"有"
;
if
(
sites
.
size
()
>
0
)
{
for
(
String
site
:
sites
)
for
(
String
site
:
sites
)
returnStr
+=
"、"
+
site
;
returnStr
+=
"、"
+
site
;
returnStr
=
returnStr
.
substring
(
1
);
}
else
{
returnStr
=
"啥都没有"
;
}
}
}
}
}
}
else
{
//增删改统一使用
}
else
{
//增删改统一使用
...
@@ -114,7 +120,7 @@ public class WorldController {
...
@@ -114,7 +120,7 @@ public class WorldController {
}
}
logWriter
.
record
(
"return:"
+
returnStr
,
0
);
logWriter
.
record
(
"
---------------------
return:"
+
returnStr
,
0
);
return
returnStr
;
return
returnStr
;
}
}
...
...
src/servlet/GameDesignServlet.java
View file @
7d840a91
package
servlet
;
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
db.SqlHelper
;
import
com.qiwu.chatbotbackend.db.SqlHelper
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.entity.JConfig
;
import
gameDesign.*
;
import
com.qiwu.chatbotbackend.entity.UserInfo
;
import
processing.MyFunc
;
import
com.qiwu.chatbotbackend.gameDesign.*
;
import
processing.ConditionTableController
;
import
com.qiwu.chatbotbackend.processing.MyFunc
;
import
processing.UserInfoController
;
import
com.qiwu.chatbotbackend.processing.ConditionTableController
;
import
com.qiwu.chatbotbackend.processing.UserInfoController
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
...
@@ -16,20 +17,40 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -16,20 +17,40 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.*
;
import
java.io.*
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.
ArrayList
;
import
java.util.
*
;
import
java.util.Iterator
;
import
java.util.Lis
t
;
import
static
java
.
lang
.
System
.
ou
t
;
@WebServlet
(
name
=
"GameDesignServlet"
,
urlPatterns
=
{
"/gameDesign"
})
@WebServlet
(
name
=
"GameDesignServlet"
,
urlPatterns
=
{
"/gameDesign"
})
public
class
GameDesignServlet
extends
HttpServlet
{
public
class
GameDesignServlet
extends
HttpServlet
{
String
POST_URL
=
"http://localhost:1111/conditionProcess"
;
//分组及其相应的id,id初始化为0, 新建分组成功后id会更新。
HashMap
<
String
,
Integer
>
categoryMap
=
new
HashMap
<
String
,
Integer
>(){
{
put
(
"地图"
,
0
);
put
(
"剧情"
,
0
);
put
(
"物品"
,
0
);
put
(
"NPC"
,
0
);
put
(
"全局变量"
,
0
);
}
};
//每个condition的三元组两端需要补充的关键词,比如npc名字、npc属性等
HashMap
<
String
,
HashSet
<
String
>>
relationKeywords
=
new
HashMap
<
String
,
HashSet
<
String
>>();
//特定的relation的三元组不会被添加到relationKeywords
HashSet
<
String
>
exceptRelation
=
new
HashSet
<
String
>();
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
Integer
botId
,
projectId
,
dataId
;
Integer
botId
,
projectId
,
dataId
,
returnStatus
=
1
;
String
botAccount
=
null
,
moduleName
,
userName
;
String
botAccount
=
null
,
moduleName
,
userName
,
moduleName2
,
returnMessage
=
"Success"
;
ServletContext
context
=
this
.
getServletContext
();
ServletContext
context
=
this
.
getServletContext
();
boolean
flag
;
JSONObject
json
=
null
,
root
=
null
;
Boolean
flag
;
SqlHelper
helper
=
null
;
SqlHelper
helper
=
null
;
List
<
Integer
>
idList
=
new
ArrayList
<>();
List
<
Integer
>
idList
=
new
ArrayList
<>();
ElementConstructor
constructor
=
n
ull
;
ElementConstructor
constructor
=
n
ew
ElementConstructor
()
;
try
{
try
{
helper
=
new
SqlHelper
();
helper
=
new
SqlHelper
();
...
@@ -42,17 +63,19 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -42,17 +63,19 @@ public class GameDesignServlet extends HttpServlet {
if
(
jsonStr
!=
null
&&
!
jsonStr
.
equals
(
""
))
{
if
(
jsonStr
!=
null
&&
!
jsonStr
.
equals
(
""
))
{
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
jsonStr
);
JSONObject
receiveParaneters
=
JSONObject
.
parseObject
(
jsonStr
);
dataId
=
(
Integer
)
jsonObject
.
get
(
"id"
);
dataId
=
(
Integer
)
receiveParaneters
.
get
(
"id"
);
JSONObject
gameElements
=
helper
.
queryGameElementsByBotId
(
dataId
);
JSONObject
gameElements
=
helper
.
queryGameElementsByBotId
(
dataId
);
out
.
println
(
gameElements
.
toJSONString
());
botId
=
(
Integer
)
gameElements
.
get
(
"botId"
);
botId
=
(
Integer
)
gameElements
.
get
(
"botId"
);
botAccount
=
(
String
)
gameElements
.
get
(
"botAccount"
);
botAccount
=
(
String
)
gameElements
.
get
(
"botAccount"
);
userName
=
(
String
)
gameElements
.
get
(
"userName"
);
userName
=
(
String
)
gameElements
.
get
(
"userName"
);
System
.
out
.
println
(
"botId:"
+
botId
+
",botAccount:"
+
botAccount
);
out
.
println
(
"botId:"
+
botId
+
",botAccount:"
+
botAccount
);
//假设重建用户信息
//假设重建用户信息
if
(
context
.
getAttribute
(
botAccount
)
==
null
)
{
if
(
context
.
getAttribute
(
botAccount
)
==
null
)
{
...
@@ -66,9 +89,9 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -66,9 +89,9 @@ public class GameDesignServlet extends HttpServlet {
//清空之前生成的配置条目
//清空之前生成的配置条目
try
{
try
{
flag
=
clearOldConfig
(
botId
,
userinfo
,
helper
);
flag
=
botInit
(
botId
,
userinfo
,
helper
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
System
.
out
.
println
(
"清空旧数据失败"
);
out
.
println
(
"清空旧数据失败"
);
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
...
@@ -76,64 +99,165 @@ public class GameDesignServlet extends HttpServlet {
...
@@ -76,64 +99,165 @@ public class GameDesignServlet extends HttpServlet {
Iterator
<
String
>
moduleIter
=
gameElements
.
keySet
().
iterator
();
Iterator
<
String
>
moduleIter
=
gameElements
.
keySet
().
iterator
();
StringBuffer
mergedConfigText
=
new
StringBuffer
();
StringBuffer
mergedConfigText
=
new
StringBuffer
();
while
(
moduleIter
.
hasNext
())
{
while
(
moduleIter
.
hasNext
())
{
moduleName
=
moduleIter
.
next
();
moduleName
=
moduleIter
.
next
();
switch
(
moduleName
)
{
switch
(
moduleName
)
{
case
"map"
:
case
"map"
:
constructor
=
new
MapConstructor
(
helper
,
botId
);
moduleName2
=
"地图"
;
constructor
=
new
MapConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
break
;
case
"plots"
:
case
"plots"
:
constructor
=
new
PlotConstructor
(
helper
,
botId
);
moduleName2
=
"剧情"
;
constructor
=
new
PlotConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
.
construct
(
gameElements
,
userinfo
);
root
=
((
PlotConstructor
)
constructor
).
getId2j
().
get
((
String
)
gameElements
.
get
(
"start"
));
break
;
break
;
case
"goods"
:
case
"goods"
:
constructor
=
new
ItemConstructor
(
helper
,
botId
);
moduleName2
=
"物品"
;
constructor
=
new
ItemConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
break
;
case
"globalVarialbe"
:
case
"globalVarialbe"
:
constructor
=
new
GlobalVariableConstructor
(
helper
,
botId
);
moduleName2
=
"全局变量"
;
constructor
=
new
GlobalVariableConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
break
;
case
"npc"
:
case
"npc"
:
constructor
=
new
CharacterConstructor
(
helper
,
botId
);
moduleName2
=
"NPC"
;
constructor
=
new
CharacterConstructor
(
helper
,
botId
,
exceptRelation
);
constructor
.
construct
(
gameElements
,
userinfo
);
break
;
break
;
default
:
default
:
continue
;
continue
;
}
}
if
(
constructor
.
getOperationStatus
()
==
1
)
{
System
.
out
.
println
(
moduleName
);
out
.
println
(
moduleName
);
constructor
.
construct
(
gameElements
,
userinfo
);
//先清空再插入
//先清空再插入
idList
.
clear
();
idList
.
clear
();
helper
.
batchInsertVariableByBotId
(
botId
,
constructor
);
helper
.
batchInsertVariableByBotId
(
botId
,
constructor
);
helper
.
batchInsertConfigByBotId
(
botId
,
constructor
,
idList
);
constructor
.
postProcessing
(
idList
);
List
<
JSONObject
>
jsonList
=
new
ArrayList
<
JSONObject
>();
for
(
JConfig
jConfig:
constructor
.
getjConfigList
()){
json
=
jConfig
.
toJson
(
constructor
.
getConditionDescription
());
constructor
.
parseKeyword
(
json
,
relationKeywords
,
exceptRelation
);
jsonList
.
add
(
json
);
}
helper
.
batchInsertConfigByBotId
(
botId
,
jsonList
,
idList
,
categoryMap
.
get
(
moduleName2
));
constructor
.
postProcessing
(
idList
,
categoryMap
.
get
(
moduleName2
));
constructor
.
generateConfigText
(
idList
);
constructor
.
generateConfigText
(
idList
);
mergedConfigText
.
append
(
constructor
.
getConfigText
());
mergedConfigText
.
append
(
constructor
.
getConfigText
());
}
else
{
returnStatus
=
0
;
returnMessage
=
constructor
.
getMessage
();
break
;
}
}
}
if
(
returnStatus
==
1
)
{
StringReader
sr
=
new
StringReader
(
mergedConfigText
.
toString
());
StringReader
sr
=
new
StringReader
(
mergedConfigText
.
toString
());
BufferedReader
br
=
new
BufferedReader
(
sr
);
BufferedReader
br
=
new
BufferedReader
(
sr
);
UserInfoController
.
buildUserInfo
(
br
,
userinfo
,
true
);
UserInfoController
.
buildUserInfo
(
br
,
userinfo
,
true
);
context
.
setAttribute
(
botAccount
,
userinfo
);
context
.
setAttribute
(
botAccount
,
userinfo
);
ConditionTableController
.
writeConfigText
(
botAccount
,
userinfo
);
ConditionTableController
.
writeConfigText
(
botAccount
,
userinfo
);
Boolean
postResult
=
actionRegenerate
(
root
,
gameElements
,
userinfo
);
}
helper
.
destroy
();
helper
.
destroy
();
}
else
{
returnStatus
=
0
;
returnMessage
=
"请求解析失败"
;
}
}
response
.
setCharacterEncoding
(
"utf-8"
);
response
.
setContentType
(
"text/plain"
);
JSONObject
responseJSONObject
=
new
JSONObject
();
responseJSONObject
.
put
(
"status"
,
returnStatus
);
responseJSONObject
.
put
(
"message"
,
returnMessage
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setContentType
(
"application/json; charset=utf-8"
);
System
.
out
.
println
(
"xx:"
+
responseJSONObject
.
toJSONString
());
try
{
PrintWriter
out
=
response
.
getWriter
();
PrintWriter
out
=
response
.
getWriter
();
out
.
println
(
"完成"
);
out
.
append
(
responseJSONObject
.
toString
());
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
out
!=
null
)
{
out
.
close
();
}
}
}
}
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
OutputStream
out
=
response
.
getOutputStream
();
OutputStream
out
=
response
.
getOutputStream
();
out
.
write
(
"ssss"
.
getBytes
());
out
.
write
(
"ssss"
.
getBytes
());
out
.
flush
();
out
.
flush
();
}
}
public
boolean
clearOldConfig
(
int
botId
,
UserInfo
userInfo
,
SqlHelper
helper
)
throws
SQLException
,
IOException
{
public
boolean
botInit
(
int
botId
,
UserInfo
userInfo
,
SqlHelper
helper
)
throws
SQLException
,
IOException
{
boolean
deleteConfigFlag
=
helper
.
deleteConfigByBotId
(
botId
);
boolean
deleteConfigFlag
=
helper
.
deleteConfigByBotId
(
botId
);
boolean
deleteVariableFlag
=
helper
.
deleteVariableByBotId
(
botId
);
boolean
deleteVariableFlag
=
helper
.
deleteVariableByBotId
(
botId
);
boolean
deleteCategoryFlag
=
helper
.
deleteCategoryByBotId
(
botId
);
boolean
batchInsertCategoryFlag
=
helper
.
batchInsertCategoryByBotId
(
botId
,
categoryMap
);
return
deleteConfigFlag
&&
deleteVariableFlag
;
return
deleteConfigFlag
&&
deleteVariableFlag
;
}
}
public
boolean
actionRegenerate
(
JSONObject
root
,
JSONObject
gameElements
,
UserInfo
userInfo
){
String
startCondition
;
String
botName
=
(
String
)
gameElements
.
get
(
"botName"
);
JSONObject
returnMessage
=
null
;
JSONObject
actionPostData
=
new
JSONObject
();
out
.
println
(
"root"
+
root
.
toJSONString
());
startCondition
=
(
String
)
root
.
get
(
"conditionName"
);
actionPostData
.
put
(
"startCondition"
,
startCondition
);
actionPostData
.
put
(
"botName_yhm"
,
(
String
)
gameElements
.
get
(
"botName"
));
actionPostData
.
put
(
"botName"
,
botName
);
actionPostData
.
put
(
"botId"
,
(
Integer
)
gameElements
.
get
(
"botId"
));
actionPostData
.
put
(
"type"
,
"game_plot_init"
);
actionPostData
.
put
(
"welcome"
,
(
String
)
gameElements
.
get
(
"plotStartText"
));
actionPostData
.
put
(
"relationKeywords"
,
relationKeywords
);
out
.
println
(
actionPostData
.
toJSONString
());
userInfo
.
extraInfo
.
put
(
"activeAction"
,
startCondition
);
try
{
returnMessage
=
MyFunc
.
postJSON
(
POST_URL
,
actionPostData
);
}
catch
(
UnsupportedEncodingException
e
)
{
e
.
printStackTrace
();
}
if
((
Integer
)
returnMessage
.
get
(
"status"
)
==
1
)
{
return
true
;
}
else
{
out
.
println
(
returnMessage
.
get
(
"parameter"
));
out
.
println
(
"剧情初始化失败"
);
return
false
;
}
}
}
}
src/servlet/GetAnswerServlet.java
View file @
7d840a91
package
servlet
;
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
entity.*
;
import
com.qiwu.chatbotbackend.
entity.*
;
import
processing.*
;
import
com.qiwu.chatbotbackend.
processing.*
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
...
@@ -15,7 +15,7 @@ import java.text.ParseException;
...
@@ -15,7 +15,7 @@ import java.text.ParseException;
import
java.util.*
;
import
java.util.*
;
@WebServlet
(
name
=
"GetAnswerServlet"
,
urlPatterns
=
{
"/test"
,
"/test/"
})
@WebServlet
(
name
=
"GetAnswerServlet"
,
urlPatterns
=
{
"/test"
,
"/test/"
,
"/dialog"
})
public
class
GetAnswerServlet
extends
HttpServlet
{
public
class
GetAnswerServlet
extends
HttpServlet
{
/**
/**
* GetAnswerServlet就是处理post请求并返回答案的入口
* GetAnswerServlet就是处理post请求并返回答案的入口
...
@@ -32,9 +32,16 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -32,9 +32,16 @@ public class GetAnswerServlet extends HttpServlet {
Map
<
String
,
String
>
historyInfoPoint
=
null
;
Map
<
String
,
String
>
historyInfoPoint
=
null
;
Solution
bestMatch
=
null
;
Solution
bestMatch
=
null
;
Condition
ansCondition
=
null
;
Condition
ansCondition
=
null
;
String
ansJ
,
return_str
=
""
,
state
=
""
;
String
ansJ
=
""
,
return_str
=
""
,
state
=
""
;
String
chatKey
=
receiveParamters
.
get
(
"chat_key"
)[
0
];
String
chatKey
=
receiveParamters
.
get
(
"chat_key"
)[
0
];
String
botName
=
receiveParamters
.
get
(
"bot_name"
)[
0
];
String
botName
=
receiveParamters
.
get
(
"bot_name"
)[
0
];
chatKey
=
botName
+
"~"
+
chatKey
;
receiveParamters
.
get
(
"chat_key"
)[
0
]
=
chatKey
;
OutputStream
out
=
response
.
getOutputStream
();
OutputStream
out
=
response
.
getOutputStream
();
ServletContext
context
=
this
.
getServletContext
();
ServletContext
context
=
this
.
getServletContext
();
boolean
debugFlag
=
false
;
boolean
debugFlag
=
false
;
...
@@ -56,15 +63,32 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -56,15 +63,32 @@ public class GetAnswerServlet extends HttpServlet {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
if
(
userinfo
!=
null
)
{
//获得用户历史信息
//获得用户历史信息
ChatCache
chatCache
=
null
;
ChatCache
chatCache
=
null
;
try
{
try
{
chatCache
=
ChatCacheController
.
getChatCache2
(
chatKey
,
context
,
userinfo
);
Boolean
loadCache
=
false
;
if
(
receiveParamters
.
containsKey
(
"yaobuyao"
))
{
String
startKeyword
=
receiveParamters
.
get
(
"yaobuyao"
)[
0
];
if
(
startKeyword
.
equals
(
"开始游戏"
)
||
startKeyword
.
equals
(
"继续游戏"
)
||
startKeyword
.
equals
(
"继续"
)
||
startKeyword
.
equals
(
"开始"
))
{
loadCache
=
true
;
}
}
chatCache
=
ChatCacheController
.
getChatCache
(
chatKey
,
context
,
userinfo
,
loadCache
);
}
catch
(
SQLException
e
)
{
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
/**
* 如果读档成功,则返回存档前的状态(包括最后一个condition和最后的回答)
* 如果读档失败,则开始新的游戏,读档失败的判断标准是除了初始化数据外没有其他任何数据
*/
if
(
userinfo
.
varInitialMap
.
size
()
-
chatCache
.
getInfoPoint
().
size
()
==
0
)
{
historyInfoPoint
=
chatCache
.
getInfoPoint
();
historyInfoPoint
=
chatCache
.
getInfoPoint
();
...
@@ -84,7 +108,7 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -84,7 +108,7 @@ public class GetAnswerServlet extends HttpServlet {
bestMatch
=
matcher
.
getSolution
(
ansCondition
,
context
,
userinfo
);
bestMatch
=
matcher
.
getSolution
(
ansCondition
,
context
,
userinfo
);
if
(
ansCondition
.
featureMap
.
containsKey
(
"activate"
)
&&
ansCondition
.
featureMap
.
containsKey
(
"post"
))
{
if
(
ansCondition
.
featureMap
.
containsKey
(
"activate"
)
&&
ansCondition
.
featureMap
.
containsKey
(
"post"
))
{
//如果当前condition包含激活和提交表单两个操作,那么在提交
操作完成之后会再激活一次待激活列表,简称后激活阶段
//如果当前condition包含激活和提交表单两个操作,那么在所有操作
操作完成之后会再激活一次待激活列表,简称后激活阶段
bestMatch
=
matcher
.
postActivate
(
ansCondition
,
context
,
userinfo
);
bestMatch
=
matcher
.
postActivate
(
ansCondition
,
context
,
userinfo
);
}
}
}
catch
(
ParseException
e
)
{
}
catch
(
ParseException
e
)
{
...
@@ -93,8 +117,8 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -93,8 +117,8 @@ public class GetAnswerServlet extends HttpServlet {
//清理超时的用户数据
//清理超时的用户数据
if
(
context
.
getAttribute
(
"cacheUpdateTime"
)
==
null
)
if
(
context
.
getAttribute
(
"cacheUpdateTime"
)
==
null
)
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
if
(
System
.
currentTimeMillis
()
-
(
long
)
context
.
getAttribute
(
"cacheUpdateTime"
)
>
300000
)
{
if
(
System
.
currentTimeMillis
()
-
(
long
)
context
.
getAttribute
(
"cacheUpdateTime"
)
>
ChatCacheController
.
TIME_OUT
)
{
ChatCacheController
.
updateChatCache4Delete2
(
chatKey
,
context
);
ChatCacheController
.
updateChatCache4Delete
(
chatKey
,
context
);
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
context
.
setAttribute
(
"cacheUpdateTime"
,
System
.
currentTimeMillis
());
}
}
//bestMatch.setAnswer(" \n" + return_str + "\n " + bestMatch.getAnswer());
//bestMatch.setAnswer(" \n" + return_str + "\n " + bestMatch.getAnswer());
...
@@ -108,12 +132,25 @@ public class GetAnswerServlet extends HttpServlet {
...
@@ -108,12 +132,25 @@ public class GetAnswerServlet extends HttpServlet {
}
}
matcher
.
infoTransfer
(
bestMatch
,
context
,
debugFlag
);
matcher
.
infoTransfer
(
bestMatch
,
context
,
debugFlag
);
}
else
{
String
nextStep
=
chatCache
.
getInfoPoint
().
get
(
"currentAction"
);
String
reply
=
chatCache
.
getInfoPoint
().
get
(
"lastReply"
);
bestMatch
=
new
Solution
(
1
,
reply
,
"nextStep="
+
nextStep
);
}
ansJ
=
MyFunc
.
toJson
(
bestMatch
);
}
else
{
ansJ
=
"找不到配置文件"
;
}
logWriter
.
record
(
"<br><br>"
+
logWriter
.
writeln
();
"------------------------------------------------对话处理结束"
,
0
);
logWriter
.
writeln
();
logWriter
.
record
(
"-----------------------------------------对话处理结束"
,
0
);
logWriter
.
writeln
();
logWriter
.
writeln
();
logWriter
.
close
();
logWriter
.
close
();
ansJ
=
MyFunc
.
toJson
(
bestMatch
);
System
.
out
.
println
(
ansJ
);
System
.
out
.
println
(
ansJ
);
out
.
write
(
ansJ
.
getBytes
());
out
.
write
(
ansJ
.
getBytes
());
out
.
flush
();
out
.
flush
();
...
...
src/servlet/GetConfigServlet.java
View file @
7d840a91
package
servlet
;
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.annotation.WebServlet
;
...
@@ -14,7 +14,7 @@ public class GetConfigServlet extends HttpServlet {
...
@@ -14,7 +14,7 @@ public class GetConfigServlet extends HttpServlet {
request
.
setCharacterEncoding
(
"UTF-8"
);
request
.
setCharacterEncoding
(
"UTF-8"
);
String
userName
=
request
.
getParameter
(
"userName"
);
String
userName
=
request
.
getParameter
(
"userName"
);
String
path
=
System
.
getProperty
(
"user.dir"
)
+
"/
config/"
+
userName
+
".txt"
;
String
path
=
"
config/"
+
userName
+
".txt"
;
File
file
=
new
File
(
path
);
File
file
=
new
File
(
path
);
OutputStream
out
=
response
.
getOutputStream
();
OutputStream
out
=
response
.
getOutputStream
();
...
...
src/servlet/ReloadChatCacheServlet.java
View file @
7d840a91
package
servlet
;
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.annotation.WebServlet
;
...
...
src/servlet/ReloadConfigServlet.java
View file @
7d840a91
package
servlet
;
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
processing.UserInfoController
;
import
com.qiwu.chatbotbackend.
processing.UserInfoController
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
...
...
src/servlet/SaveChatCacheServlet.java
View file @
7d840a91
package
servlet
;
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
entity.ChatCache
;
import
com.qiwu.chatbotbackend.
entity.ChatCache
;
import
processing.ChatCacheController
;
import
com.qiwu.chatbotbackend.
processing.ChatCacheController
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
...
@@ -30,8 +30,8 @@ public class SaveChatCacheServlet extends HttpServlet {
...
@@ -30,8 +30,8 @@ public class SaveChatCacheServlet extends HttpServlet {
Map
<
String
,
ChatCache
>
chatCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
Map
<
String
,
ChatCache
>
chatCacheMap
=
(
Map
<
String
,
ChatCache
>)
context
.
getAttribute
(
"chatCache"
);
ChatCache
chatCache
=
chatCacheMap
.
get
(
chatKey
);
ChatCache
chatCache
=
chatCacheMap
.
get
(
chatKey
);
message
=
ChatCacheController
.
saveChatCache
(
chatKey
,
context
);
//
message = ChatCacheController.saveChatCache(chatKey, context);
out
.
write
(
message
.
getBytes
());
//
out.write(message.getBytes());
out
.
flush
();
out
.
flush
();
}
}
...
...
src/servlet/UpdateServlet.java
View file @
7d840a91
package
servlet
;
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
entity.Condition
;
import
com.qiwu.chatbotbackend.
entity.Condition
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
processing.MyFunc
;
import
com.qiwu.chatbotbackend.
processing.MyFunc
;
import
processing.UserInfoController
;
import
com.qiwu.chatbotbackend.
processing.UserInfoController
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
...
...
src/servlet/UpdateSingleConfigServlet.java
View file @
7d840a91
package
servlet
;
package
com
.
qiwu
.
chatbotbackend
.
servlet
;
import
entity.UserInfo
;
import
com.qiwu.chatbotbackend.
entity.UserInfo
;
import
processing.ConditionTableController
;
import
com.qiwu.chatbotbackend.
processing.ConditionTableController
;
import
processing.UserInfoController
;
import
com.qiwu.chatbotbackend.
processing.UserInfoController
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.ServletException
;
...
...
src/test/java/com/qiwu/chatbotbackend/ChatbotBackendApplicationTests.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
;
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
ChatbotBackendApplicationTests
{
@Test
public
void
contextLoads
()
{
}
}
src/test/java/com/qiwu/chatbotbackend/WorldTests.java
deleted
100644 → 0
View file @
f8d00711
package
com
.
qiwu
.
chatbotbackend
;
import
com.qiwu.chatbotbackend.GameEnvironment.GameEnv
;
import
com.qiwu.chatbotbackend.processing.LogWriter
;
import
com.qiwu.chatbotbackend.processing.WorldController
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
java.io.*
;
import
java.util.HashMap
;
import
java.util.Map
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
public
class
WorldTests
{
@Test
public
void
testQuery
()
throws
Exception
{
String
result
=
""
;
Map
<
String
,
String
>
curInfoPoint
=
new
HashMap
<
String
,
String
>(){
{
put
(
"testCondition"
,
"cc:瑞娜"
);
put
(
"testCondition2"
,
"数量:蓝色药水"
);
put
(
"testCondition3"
,
"瑞娜:友好度"
);
put
(
"testCondition4"
,
"瑞娜:友好度"
);
put
(
"testCondition5"
,
" :瑞娜"
);
}
};
Map
<
String
,
String
>
hisInfoPoint
=
new
HashMap
<
String
,
String
>(){
{
put
(
"site"
,
"海边"
);
}
};
LogWriter
logWriter
=
new
LogWriter
(
"config"
,
"text"
);
// GameEnv gameEnv = new GameEnv("3474861621");
// WorldController controller = new WorldController(logWriter);
//
// result = controller.worldOperation(gameEnv, "goods_query", "queryAttrByGoodsName:testCondition2", curInfoPoint, hisInfoPoint);
// System.out.println(result);
// assertEquals("2", result);
//
// result = controller.worldOperation(gameEnv, "map_query", "queryCanGoBySite:2", curInfoPoint, hisInfoPoint);
// System.out.println(result);
// assertEquals("有、山洞、沙滩、营地", result);
//
// result = controller.worldOperation(gameEnv, "NPC_query", "queryAttrByNPCName:testCondition3", curInfoPoint, hisInfoPoint);
// System.out.println(result);
// assertEquals("100", result);
//
// /**
// * 方法暂不存在
// *
// result = controller.worldOperation(gameEnv, "goods_query", "queryAroundGoodsByClassName:testCondition4", curInfoPoint, hisInfoPoint);
// System.out.println(result);
// assertEquals("100", result);
// */
//
// result = controller.worldOperation(gameEnv, "NPC_query", "queryNpcIntro:testCondition5", curInfoPoint, hisInfoPoint);
// System.out.println(result);
// assertEquals("至始至终的帮手", result);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment