diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_11_1.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_11_1.xml
new file mode 100644
index 0000000..8d0801d
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_11_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_11_1.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_11_1.xml
new file mode 100644
index 0000000..afdb5fd
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_11_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_11_1.xml b/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_11_1.xml
new file mode 100644
index 0000000..798cc46
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jdk8_2_11_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_11_1.xml b/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_11_1.xml
new file mode 100644
index 0000000..54a5eed
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_11_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_11_1.xml b/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_11_1.xml
new file mode 100644
index 0000000..fd61dcb
--- /dev/null
+++ b/.idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_parameter_names_2_11_1.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_lettuce_lettuce_core_5_3_2_RELEASE.xml b/.idea/libraries/Maven__io_lettuce_lettuce_core_5_3_2_RELEASE.xml
new file mode 100644
index 0000000..cb094d4
--- /dev/null
+++ b/.idea/libraries/Maven__io_lettuce_lettuce_core_5_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_netty_netty_buffer_4_1_51_Final.xml b/.idea/libraries/Maven__io_netty_netty_buffer_4_1_51_Final.xml
new file mode 100644
index 0000000..ee1f51a
--- /dev/null
+++ b/.idea/libraries/Maven__io_netty_netty_buffer_4_1_51_Final.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_netty_netty_codec_4_1_51_Final.xml b/.idea/libraries/Maven__io_netty_netty_codec_4_1_51_Final.xml
new file mode 100644
index 0000000..74eb5ed
--- /dev/null
+++ b/.idea/libraries/Maven__io_netty_netty_codec_4_1_51_Final.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_netty_netty_common_4_1_51_Final.xml b/.idea/libraries/Maven__io_netty_netty_common_4_1_51_Final.xml
new file mode 100644
index 0000000..9a85e9a
--- /dev/null
+++ b/.idea/libraries/Maven__io_netty_netty_common_4_1_51_Final.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_netty_netty_handler_4_1_51_Final.xml b/.idea/libraries/Maven__io_netty_netty_handler_4_1_51_Final.xml
new file mode 100644
index 0000000..ca938c4
--- /dev/null
+++ b/.idea/libraries/Maven__io_netty_netty_handler_4_1_51_Final.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_netty_netty_resolver_4_1_51_Final.xml b/.idea/libraries/Maven__io_netty_netty_resolver_4_1_51_Final.xml
new file mode 100644
index 0000000..545e57c
--- /dev/null
+++ b/.idea/libraries/Maven__io_netty_netty_resolver_4_1_51_Final.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_netty_netty_transport_4_1_51_Final.xml b/.idea/libraries/Maven__io_netty_netty_transport_4_1_51_Final.xml
new file mode 100644
index 0000000..498e9c0
--- /dev/null
+++ b/.idea/libraries/Maven__io_netty_netty_transport_4_1_51_Final.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__io_projectreactor_reactor_core_3_3_8_RELEASE.xml b/.idea/libraries/Maven__io_projectreactor_reactor_core_3_3_8_RELEASE.xml
new file mode 100644
index 0000000..f0d3ae7
--- /dev/null
+++ b/.idea/libraries/Maven__io_projectreactor_reactor_core_3_3_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__mysql_mysql_connector_java_8_0_21.xml b/.idea/libraries/Maven__mysql_mysql_connector_java_8_0_21.xml
new file mode 100644
index 0000000..32c4db1
--- /dev/null
+++ b/.idea/libraries/Maven__mysql_mysql_connector_java_8_0_21.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_10_13.xml b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_10_13.xml
new file mode 100644
index 0000000..66814b3
--- /dev/null
+++ b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_1_10_13.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_10_13.xml b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_10_13.xml
new file mode 100644
index 0000000..a15e47a
--- /dev/null
+++ b/.idea/libraries/Maven__net_bytebuddy_byte_buddy_agent_1_10_13.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_13_3.xml b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_13_3.xml
new file mode 100644
index 0000000..bc0bb7b
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_api_2_13_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_13_3.xml b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_13_3.xml
new file mode 100644
index 0000000..9289ccb
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_logging_log4j_log4j_to_slf4j_2_13_3.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_37.xml b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_37.xml
new file mode 100644
index 0000000..29450a4
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_core_9_0_37.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_37.xml b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_37.xml
new file mode 100644
index 0000000..b895fa5
--- /dev/null
+++ b/.idea/libraries/Maven__org_apache_tomcat_embed_tomcat_embed_websocket_9_0_37.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_6.xml b/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_6.xml
new file mode 100644
index 0000000..52c8f81
--- /dev/null
+++ b/.idea/libraries/Maven__org_aspectj_aspectjweaver_1_9_6.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_hibernate_hibernate_core_5_4_18_Final.xml b/.idea/libraries/Maven__org_hibernate_hibernate_core_5_4_18_Final.xml
new file mode 100644
index 0000000..a6faed9
--- /dev/null
+++ b/.idea/libraries/Maven__org_hibernate_hibernate_core_5_4_18_Final.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..ec6d1fd
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..46c098e
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_autoconfigure_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..89b790c
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..1a37aed
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_aop_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..759f31f
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_jpa_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_redis_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_redis_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..c9ce16c
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_data_redis_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..532dab4
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_jdbc_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..e98d29c
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_json_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..dfb4a08
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_logging_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..48aa959
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_test_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..8428c06
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_tomcat_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..75ae771
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_web_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_websocket_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_websocket_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..013fd6f
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_websocket_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..4763e37
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..aaa8cfc
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_boot_spring_boot_test_autoconfigure_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..99702f8
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_data_spring_data_commons_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..0299a9b
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_data_spring_data_jpa_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_data_spring_data_keyvalue_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_data_spring_data_keyvalue_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..ed96f84
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_data_spring_data_keyvalue_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_data_spring_data_redis_2_3_2_RELEASE.xml b/.idea/libraries/Maven__org_springframework_data_spring_data_redis_2_3_2_RELEASE.xml
new file mode 100644
index 0000000..154958d
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_data_spring_data_redis_2_3_2_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_aop_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_aop_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..016a15c
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_aop_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_websocket_2_3_0_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_aspects_5_2_8_RELEASE.xml
similarity index 66%
rename from .idea/libraries/Maven__org_springframework_boot_spring_boot_starter_websocket_2_3_0_RELEASE.xml
rename to .idea/libraries/Maven__org_springframework_spring_aspects_5_2_8_RELEASE.xml
index 91ed6bf..5ec2db7 100644
--- a/.idea/libraries/Maven__org_springframework_boot_spring_boot_starter_websocket_2_3_0_RELEASE.xml
+++ b/.idea/libraries/Maven__org_springframework_spring_aspects_5_2_8_RELEASE.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_beans_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_beans_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..f7366a0
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_beans_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_context_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_context_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..36899c5
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_context_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_context_support_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_context_support_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..034f9b5
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_context_support_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_core_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_core_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..f96376b
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_core_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_expression_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_expression_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..644628e
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_expression_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_jcl_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_jcl_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..7f2add5
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_jcl_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_jdbc_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_jdbc_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..b47f68d
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_jdbc_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_messaging_5_2_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_messaging_5_2_8_RELEASE.xml
similarity index 77%
rename from .idea/libraries/Maven__org_springframework_spring_messaging_5_2_6_RELEASE.xml
rename to .idea/libraries/Maven__org_springframework_spring_messaging_5_2_8_RELEASE.xml
index b0777f6..33dab9e 100644
--- a/.idea/libraries/Maven__org_springframework_spring_messaging_5_2_6_RELEASE.xml
+++ b/.idea/libraries/Maven__org_springframework_spring_messaging_5_2_8_RELEASE.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_orm_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_orm_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..59665a8
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_orm_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_oxm_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_oxm_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..b98147a
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_oxm_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_test_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_test_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..76f2a7c
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_test_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_tx_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_tx_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..2542dba
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_tx_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_web_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_web_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..f0719cd
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_web_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_webmvc_5_2_8_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_webmvc_5_2_8_RELEASE.xml
new file mode 100644
index 0000000..a8f2f7b
--- /dev/null
+++ b/.idea/libraries/Maven__org_springframework_spring_webmvc_5_2_8_RELEASE.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/Maven__org_springframework_spring_websocket_5_2_6_RELEASE.xml b/.idea/libraries/Maven__org_springframework_spring_websocket_5_2_8_RELEASE.xml
similarity index 77%
rename from .idea/libraries/Maven__org_springframework_spring_websocket_5_2_6_RELEASE.xml
rename to .idea/libraries/Maven__org_springframework_spring_websocket_5_2_8_RELEASE.xml
index a50ab8e..09f1cba 100644
--- a/.idea/libraries/Maven__org_springframework_spring_websocket_5_2_6_RELEASE.xml
+++ b/.idea/libraries/Maven__org_springframework_spring_websocket_5_2_8_RELEASE.xml
@@ -1,13 +1,13 @@
-
+
-
+
-
+
-
+
\ No newline at end of file
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 837f486..7e4a448 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -5,7 +5,55 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -42,92 +90,96 @@
-
-
+
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
@@ -144,40 +196,46 @@
- variablePathInUsDir
- text
- tts_ls
- 23
- SERVER_URL
- BASE_HOST_URL
- getChannelAllBots
- serverAddresses
- GAME_EDITOR_HOST
- requestTerminate
- offlineStr
- CHANGE_SOUND
- filepath
- POOL
+ direct
+ isNoScreenRequest
+ SendPart
+ numStr
+ userId
+ lunchHistory
+ workName
+ getAllProjects
+ writerWithDefaultPrettyPrinter
+ outTime
+ url
+ <%=
+ rank
+ dealNoScreenIntentTemp
+ backTrigger
+ botAccount
+ flower
+ linkAccountSucceededEvent
+ {
+ centerCrop
+ fitXY
+ dealDefaultIntent
+ HOST_UTL
+ JIAOYOUTIANXIA
+ xiaodu-speaker-api-test
generalMP3
- App.LOGGER
- auth
- response
- type
- params
- asyncDelete
- checkZipFile
- referenceName
- zipDir
- add
- asynResultList
- stringRedisTemplate
- genRecordWithChange
- stringRedisTemplate.opsForValue()
- tts
+ xiaodu-speaker-api-pro
+ ASIDE_IMG
+ dealCollectOrUnCollectIntent
+ botAccount2Project
!CollectionUtils.isEmpty
log
+ recommendPageData
+ getTheActorsWithWords
+ fitXY
+ centerCrop
+ xiaodu-speaker-api-pro
+ xiaodu-speaker-api-test
@@ -186,57 +244,57 @@
@@ -253,11 +311,11 @@
-
+
-
+
@@ -268,9 +326,9 @@
-
-
-
+
+
+
@@ -281,6 +339,7 @@
+
@@ -331,33 +390,26 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
-
+
+
@@ -366,6 +418,9 @@
+
+
+
@@ -379,13 +434,13 @@
-
-
-
-
+
+
+
+
-
+
@@ -393,12 +448,12 @@
-
-
-
+
+
+
-
+
@@ -432,12 +487,12 @@
-
-
-
+
+
+
-
+
@@ -489,10 +544,10 @@
-
-
-
+
+
+
@@ -502,11 +557,11 @@
-
-
+
+
+
-
-
+
@@ -696,28 +751,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
@@ -725,41 +792,41 @@
-
-
+
+
-
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
-
-
-
-
-
+
+
+
+
+
-
-
+
+
@@ -767,10 +834,10 @@
-
-
+
+
-
+
@@ -779,399 +846,397 @@
-
-
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
-
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTSUtils.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTSUtils.java
index 98d0c61..44e4cee 100755
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTSUtils.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTSUtils.java
@@ -666,7 +666,7 @@ public class TTSUtils {
}
}
long temp;
- log.warn("sox 切除静音耗时:"+((temp=System.currentTimeMillis())-startMark));
+// log.warn("sox 切除静音耗时:"+((temp=System.currentTimeMillis())-startMark));
List str = cutedPaths.stream().map(s -> "-i "+s).collect(Collectors.toList());
StringBuilder builder = new StringBuilder("ffmpeg ").append(StringUtils.join(str, " ")).append(" -filter_complex ");
for (int k = 0; k < filePathList.size(); k++) {
@@ -674,7 +674,7 @@ public class TTSUtils {
}
builder.append("concat=n=").append(filePathList.size()).append(":v=0:a=1[a] -map [a] ").append(targetFilepath);
CallPython.ffmpegExecute(builder.toString());
- log.warn("ffmpeg 拼接耗时:"+(System.currentTimeMillis()-temp));
+// log.warn("ffmpeg 拼接耗时:"+(System.currentTimeMillis()-temp));
POOL.submit(() -> {
for (String delPath: cutedPaths) new File(delPath).delete();
});
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/DeployController.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/DeployController.java
index 282189b..1b7cb44 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/DeployController.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/controller/DeployController.java
@@ -153,6 +153,7 @@ public class DeployController {
log.error("耗时:"+(System.currentTimeMillis()-startTime));
toChannel.close();
if ("audio".equals(targetDir)) FileUtil.deleteFile(new File(targetDir));
+ Files.createDirectories(Paths.get(targetDir));
FileUtil.decompress(tempSliceName+".zip", targetDir);
deleteSlice(zipDir, prefix, botAccount);
params.put("result", "success");
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTServiceEdition2.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTServiceEdition2.java
index a0cd3c3..fd650c4 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTServiceEdition2.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTServiceEdition2.java
@@ -27,6 +27,7 @@ import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import static ai.qiwu.com.tts_service.common.TTSConstants.DEFAULT_MOOD;
import static ai.qiwu.com.tts_service.service.TTService.POOL;
@@ -414,7 +415,7 @@ public class TTServiceEdition2 {
String wavFilename = filePath.substring(0, filePath.length()-4)+".wav";
//对于请求参数中带有npcName的,首先判断其是否是分段请求,即检查text中是否包含AB符号
if (StringUtils.isNotBlank(data.getNpcName())) {
- if (genRecordWithChange(url, data, filePath, requestMethod, getOnline)) return new ResponseCodeWithData(HttpServletResponse.SC_OK);
+ if (genRecordWithChangeEdition2(url, data, filePath, requestMethod, getOnline)) return new ResponseCodeWithData(HttpServletResponse.SC_OK);
}
// 若wav不存在则先下载,通过person来区分是否是第三方
if (!TTSUtils.doesFileExist(wavFilename)) {
@@ -504,6 +505,100 @@ public class TTServiceEdition2 {
return res;
}
+ private boolean genRecordWithChangeEdition2(String url, GeneralMP3Data data, String personToneFilePath,
+ String requestMethod, boolean getOnline) {
+ String text = data.getText();
+ if (!text.contains("\uD83C\uDD70")) {
+ return false;
+ }
+ List splitList = new ArrayList<>();
+ String[] arr = text.split("\uD83C\uDD70");
+ for (String item: arr) {
+ splitList.addAll(Arrays.asList(item.split("\uD83C\uDD71")));
+ }
+ List> asynResultList = new ArrayList<>(splitList.size());
+ List conditionPathList = new ArrayList<>(splitList.size());
+ String recordFolder = StringUtils.join(new String[]{Initialize.getAudioDir(), data.getBotname(),
+ Initialize.getUploadedDir(), data.getNpcName()}, File.separator);
+ String usDir = StringUtils.join(new String[]{Initialize.getAudioDir(),data.getBotname(),
+ data.getPerson(), data.getTone()}, File.separator);
+ splitList = splitList.stream().filter(s -> StringUtils.isNotBlank(s.replaceAll("\\p{P}", "")))
+ .map(s -> {
+ String filename;
+ String filepath = new StringBuilder(recordFolder).append(File.separator)
+ .append((filename=TTSUtils.buildMP3Filename(s))).toString();
+ if (!TTSUtils.doesFileExist(filepath)) {
+ filepath = new StringBuilder(usDir).append(File.separator).append(filename).toString();
+ if (!TTSUtils.doesFileExist(filepath)) {
+ if (Boolean.TRUE.equals(stringRedisTemplate.opsForValue().setIfAbsent(filepath, "1", 30, TimeUnit.SECONDS))) {
+ if (!TTSUtils.doesFileExist(filepath)) {
+ final String finalPath = filepath;
+ Future result = POOL.submit(() -> {
+ try {
+ GeneralMP3Data variableData = new GeneralMP3Data(data.getServer(), s,data.getPerson(),
+ data.getTone(), data.getBotname(), data.getCache(),data.getVolume(),data.getSpeed(),data.getPitch());
+ ResponseCodeWithData response = generalMP3(url, variableData, finalPath, requestMethod, getOnline);
+ if (response == null || response.getCode() != 200) return "0";
+ return "1";
+ } finally {
+ stringRedisTemplate.delete(finalPath);
+ }
+ });
+ asynResultList.add(result);
+ } else {
+ stringRedisTemplate.delete(filepath);
+ }
+ } else {
+ conditionPathList.add(filepath);
+ }
+ }
+ }
+ return filepath;
+ }).collect(Collectors.toList());
+
+ try {
+ if (asynResultList.size() != 0) {
+ String result;
+ try {
+ for (Future future : asynResultList) {
+ result = future.get(40, TimeUnit.SECONDS);
+ if ("0".equals(result)) return false;
+ }
+ } catch (Exception e) {
+ log.error("获取分段响应结果出错:{},text:{}",e,text);
+ return false;
+ }
+ }
+ if (conditionPathList.size() != 0) {
+ for (String conditionPath: conditionPathList) {
+ int co = 0;
+ while (Boolean.TRUE.equals(stringRedisTemplate.hasKey(conditionPath)) && co++ < 10) {
+ try {
+ Thread.sleep(500);
+ } catch (Exception e) {
+ // do nothing
+ }
+ }
+ if (co == 11 && Boolean.TRUE.equals(stringRedisTemplate.hasKey(conditionPath))) {
+ log.error("genRecordWithChangeEdition2 分段遇到竞争等待5s对方仍未结束,"+conditionPath);
+ return false;
+ }
+ }
+ }
+// long start = System.currentTimeMillis();
+ TTSUtils.combineMp3File(splitList, personToneFilePath, false);
+// log.warn("拼接耗时:{}->{}",personToneFilePath,(System.currentTimeMillis()-start));
+ if (!new File(personToneFilePath).exists()) {
+ log.error("分段合并音频,未找到合并后的文件");
+ return false;
+ }
+ } catch (Exception e) {
+ log.error("genRecordWithChangeEdition2:合成音频失败:{}",e.toString());
+ return false;
+ }
+ return true;
+ }
+
private boolean genRecordWithChange(String url, GeneralMP3Data data, String personToneFilePath,
String requestMethod, boolean getOnline) {
final String text = data.getText();
@@ -1225,4 +1320,20 @@ public class TTServiceEdition2 {
log.error("合成多个音频文件出错:{}", e.toString());
}
}
+
+ public static void main(String[] args) {
+ final String text = "\uD83C\uDD70今天\uD83C\uDD71是第\uD83C\uDD706\uD83C\uDD71,\uD83C\uDD70文件\uD83C\uDD71天,音频\uD83C\uDD70出错\uD83C\uDD71@#";
+ List splitList = new ArrayList<>();
+ String[] arr = text.split("\uD83C\uDD70");
+ for (String item: arr) {
+ splitList.addAll(Arrays.asList(item.split("\uD83C\uDD71")));
+ }
+ System.out.println(splitList);
+ splitList = splitList.stream().filter(s -> StringUtils.isNotBlank(s.replaceAll("\\p{P}", ""))).collect(Collectors.toList());
+
+ System.out.println(splitList);
+// System.out.println(TTSUtils.buildMP3Filename("今天是第"));
+// System.out.println(TTSUtils.buildMP3Filename("天"));
+// System.out.println(TTSUtils.buildMP3Filename("6"));
+ }
}
diff --git a/xiaoduhome/pom.xml b/xiaoduhome/pom.xml
index 1aa26ee..bd8a3fe 100755
--- a/xiaoduhome/pom.xml
+++ b/xiaoduhome/pom.xml
@@ -5,7 +5,7 @@
org.springframework.boot
spring-boot-starter-parent
- 2.3.0.RELEASE
+ 2.3.2.RELEASE
ai.qiwu.com
@@ -41,11 +41,6 @@
runtime
-
- org.springframework.boot
- spring-boot-starter-thymeleaf
- 2.1.6.RELEASE
-
@@ -148,6 +143,11 @@
commons-lang3
3.9
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ 2.11.0
+
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Config.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Config.java
index 4cbfa40..6a69671 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Config.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Config.java
@@ -24,6 +24,7 @@ public class Config {
String path = System.getProperty("java.class.path");
path = path.substring(0, path.lastIndexOf(File.separator)+1) + filename;
log.warn("配置文件:{}",path);
+// path = "/home/yf01/文档/xiaodu.properties";
properties.load(new InputStreamReader(new FileInputStream(path), StandardCharsets.UTF_8));
// properties.load(new InputStreamReader(Config.class.getClassLoader().getResourceAsStream(filename), StandardCharsets.UTF_8));
} catch (Exception e) {
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java
index 6f57060..c06b422 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Constants.java
@@ -10,14 +10,9 @@ public interface Constants {
String CAN_NOT_MOVE_USER_KEY = "audio_box_stay_";
String QI_WU_INTERFACE = "http://didi-gz3.jiaoyou365.com:8070/api/chat2";
- String QI_WU_INTERFACE_di2 = "http://didi-gz2.jiaoyou365.com:8070/api/chat2";
String INTERFACE_DI = "http://didi-gz3.jiaoyou365.com:8070/api/chat2";
- String TTS_DIDI3_GET = "http://didi-gz3.jiaoyou365.com:9663/api/audio/get?path=";
- String TTS_DIDI2_GET = "http://didi-gz2.jiaoyou365.com:9663/api/audio/get?path=";
String TTS_DIDI3_GET_XIAOAI = "http://didi-gz3.jiaoyou365.com:9663/api/audio/get?type=";
String TTS_DIDI4_GET_XIAOAI = "http://didi-gz4.jiaoyou365.com:9663/api/audio/get?type=";
- String TTS_DIDI4_GET_XIAOAI_STATIC = "http://didi-gz4.jiaoyou365.com:9663/static/";
- String SERVICE_NAME = "BAIDU";
String PRIVATE_KEY = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANMWIYduiQZt0B7s" +
"IZ6PW15gpcO7Yn+9ZbaMSHwzJqNeDAZzh6HXF7r0ZpQcw3XEWKPAPWyuJ5eqZf46" +
"W/NyJQkcddWrA/5OvcZw1uAmzTt8sWz1zokt2e6v6SucvvHoPxLGjfTKWh6Qr+2x" +
@@ -32,12 +27,10 @@ public interface Constants {
"oQLr+wpTs5Qt6n7oh9HZWK6DCD8SUOfWu/7gENzrefE1V9jTxnfeLQJBANKf4QfA" +
"CvwfHTyEgphcWrWDzB7bEqUDWiEjfO8sf+lwj9I0yU6fO/+aUtwU9xwkij1PscUF" +
"9AWUhbas+LG9mds=";
- Integer GET_PRODUCT_TOKEN_FAIL_STATUS = 10086;
- String IMG_PREFIX = "https://didi-gz5.jiaoyou365.com";
String IMG_CUSTOM_PREFIX = "https://didi-gz5.jiaoyou365.com/duai/image/";
String PRE_PRODUCT_IMG = "prod:";
String PRE_ENTER_PRODUCT = "enter";
- String PRE_PRODUCT_PLAY = "我要玩";
+ String PRE_PRODUCT_PLAY = "打开";
String LOAD_INTRO = "扫描二维码输入手机号获取验证码登录";
String REWARD_FLOWER = "请扫码支付";
@@ -48,25 +41,24 @@ public interface Constants {
Integer RE_RA_CA_PAGE_SIZE = 12;
interface DPL_COMPONENT_ID {
+ String CUR_FIRST_ROW_INDEX = "curFirstRowIndex";
+ String SCROLL_ID = "udScroll";
+ String CATEGORY_NAME = "categoryName";
+ String START_ACTUAL_INDEX = "actualIndex";
String FLOWE = "flowe";
- String FLOWER_PRODUCT_ID = "190817185926388308";
String FLOWER_LOAD = "flowerLoad";
String PRE_COLLE = "colle";
String COLLEC_ID = "colleAL";
String UN_COLLEC_ID = "colleUn";
- String COLLECT_IMAGE_ID = "collectImage";
- String COLLECT_TEXT_ID = "collectText";
String BACK_TRACE = "trace";
String NEXT_PAGE_INDEX = "comCnt";
String PRE_CATEGORY = "categ";
String PRE_FUNNY_IMG = "funny";
- String CLICK_PATTERN = "[{type: SendEvent,componentId:%s}]";
-
- String COLLECTED_IMG_URL = "https://didi-gz5.jiaoyou365.com/duai/image/collec.png";
- String UN_COLLECTED_IMG_URL = "https://didi-gz5.jiaoyou365.com/duai/image/uncollec.png";
- String DEFAULT_ASIDE_IMG_URL = "http://didi-gz5.jiaoyou365.com/Editor/upload/img/npc/2019/02/19174004213.png";
+ String COLLECTED_IMG_URL = "https://hw-gz25.heyqiwu.cn/duai/image/collec.png";
+ String UN_COLLECTED_IMG_URL = "https://hw-gz25.heyqiwu.cn/duai/image/uncollec.png";
+ String DEFAULT_ASIDE_IMG_URL = "http://hw-gz25.heyqiwu.cn/Editor/upload/img/npc/2019/02/19174004213.png";
}
interface PRODUCT_INTRO {
@@ -78,47 +70,34 @@ public interface Constants {
String FLOWER = "打赏鲜花";
String COLLECED = "已收藏";
String UN_COLLEC = "收藏";
- String CHAT_COLLECT = "我要收藏";
- String CHAT_UN_COLLECT = "取消收藏";
String COLLECT_BOT_WORD = "已为您收藏该作品";
String COLLECT_BOT_WORD_MG = "已将%s加入您的收藏";
String UN_COLLECT_BOT_WORD = "已将该作品移出您的收藏列表";
String UN_COLLECT_BOT_WORD_MG = "已将%s移出您的收藏列表";
}
- interface CATEGORY_IMG_URL {
- String NAME_GU_FENG = "古风";
- String NAME_KE_HUAN = "科幻";
- String NAME_ZHAN_XING = "占星";
- String NAME_LOVE = "恋爱";
- String NAME_ZAI_NAN = "灾难";
- String NAME_JIA_KONG = "架空";
- String NAME_CHILD = "儿童";
- String NAME_JING_YING = "经营";
- String NAME_MAO_XIAN = "冒险";
- String NAME_WU_XIA = "武侠";
- }
-
interface SKILL_SECURITY {
String REDIRECT_URI = "https://xiaodu.baidu.com/saiya/auth/3a0610f8af67a3c92d803a80a1c8976c";
+// String REDIRECT_URI = "https://xiaodu.baidu.com/saiya/auth/4fbc7b9112e3a43dc7dbf43fd556929e";
String REDIRECT_URI_TEST = "https://xiaodu-dbp.baidu.com/saiya/auth/3a0610f8af67a3c92d803a80a1c8976c";
+// String REDIRECT_URI_TEST = "https://xiaodu-dbp.baidu.com/saiya/auth/4fbc7b9112e3a43dc7dbf43fd556929e";
String CLIENT_ID = "aiqiwucom";
String CLIENT_SECRET = "miaoquanwei";
}
interface WelcomeWord {
String WELCOME = "欢迎来到交游天下。与剧情人物自由对话,带您体验不同的人生和情怀。向您推荐新上线的求生记,您可以说打开求生记。或者说,推荐其它作品。";
- String WELCOME_FORMAT = "欢迎来到交游天下。与剧情人物自由对话,带您体验不同的人生和情怀。向您推荐新上线的%s,您可以说打开%s。或者说,推荐其它作品。";
+// String WELCOME_FORMAT = "欢迎来到交游天下。与剧情人物自由对话,带您体验不同的人生和情怀。向您推荐新上线的%s,您可以说打开%s。或者说,推荐其它作品。";
String SKILL = "交游天下";
String SKILL_DEFAULT = "我们的技能";
// 欢迎来到晓悟智能故事。与可爱的角色们自由对话,畅游不同的故事世界。我们新上线了遇见伽利略,你可以说打开遇见伽利略。或者说,推荐其它作品。
- String WELCOME_SMART = "欢迎来到晓悟智能故事。我们新上线了遇见伽利略,你可以说打开遇见伽利略。或者说,推荐其它作品。";
+// String WELCOME_SMART = "欢迎来到晓悟智能故事。我们新上线了遇见伽利略,你可以说打开遇见伽利略。或者说,推荐其它作品。";
String WELCOME_SMART_FORMAT = "欢迎来到晓悟智能故事。与可爱的角色们自由对话,畅游不同的故事世界。我们新上线了%s,你可以说打开%s。或者说,推荐其它作品。";
String WELCOME_SMART_FORMAT_AI = "欢迎来到晓悟智能故事。推荐我们新上线的%s,你可以说打开%s。或者说,推荐其它作品。";
String SKILL_SMART = "智能故事";
String XIAOWU_SKILL_SMART = "晓悟智能故事";
// 与剧情人物自由对话,带您体验不同的人生和情怀。
- String WELCOME_NOVEL = "欢迎来到晓悟智能小说。向您推荐新上线的妖刀异闻录,您可以说打开妖刀异闻录。或者说,推荐其它作品。";
+// String WELCOME_NOVEL = "欢迎来到晓悟智能小说。向您推荐新上线的野蛮女友,您可以说打开野蛮女友。或者说,推荐其它作品。";
String WELCOME_NOVEL_FORMAT = "欢迎来到晓悟智能小说。与剧情人物自由对话,带您体验不同的人生和情怀。向您推荐新上线的%s,您可以说打开%s。或者说,推荐其它作品。";
String SKILL_NOVEL = "智能小说";
String XIAOWU_SKILL_NOVEL = "晓悟智能小说";
@@ -162,17 +141,6 @@ public interface Constants {
String HTTP_CONNECTION_CLOSE_FAILED = "与终端的链接关闭错误";
}
- interface ManageProduct {
- String BAIDU_COOKIE = "BAIDUID=5A90207BBC953C38E8FEAB3B064D8E7B:FG=1;BDUSS=Vota2FuQldVUmc3LVl0aTJ5NDVLOENKR1BLekxVMngzOHZBc1EtUW5sR25rRjlkSUFBQUFBJCQAAAAAAAAAAAEAAACty2MsUmVhY2hsb3ZlAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAKcDOF2nAzhdU";
- String GET_TOKEN = "https://xiaodu.baidu.com/dbppay/skill-pay/product/token";
- String CREATE_PRODUCT = "https://xiaodu.baidu.com/dbppay/skill-pay/product/inskillproducts";
- String UPDATE_PRODUCT = "https://xiaodu.baidu.com/dbppay/skill-pay/product/inskillproducts";
- String DELETE_PRODUCT = "https://xiaodu.baidu.com/dbppay/skill-pay/product/inskillproducts";
- String QUERY_PRODUCT = "https://xiaodu.baidu.com/dbppay/skill-pay/product/inskillproducts";
- String PUBLISH_PRODUCT = "https://xiaodu.baidu.com/dbppay/skill-pay/product/publish";
- String GET_ALL_PRODUCT_SITUATION = "https://xiaodu.baidu.com/dbppay/skill-pay/saiya/v1/skills/inskillproducts";
- }
-
interface XIAOWU_API {
String BASIC_PREFIX = "Basic ";
String BEARER = "Bearer ";
@@ -182,10 +150,8 @@ public interface Constants {
String SDK_TOKEN = "https://account-center-test.chewrobot.com/api/sdk/token";
String GET_USER_INFO_BY_TOKEN ="https://account-center-test.chewrobot.com/api/sdk/user/info";
- String FLOWER_INTERFACE = "http://aws-nx2.chewrobot.com:18082/api/flower/count";
- String USER_CLOOEC_LIST = "http://aliyun-hz1.chewrobot.com:18082/api/favorite";
+// String FLOWER_INTERFACE = "http://aws-nx2.chewrobot.com:18082/api/flower/count";
String USER_ID_BY_TOKEN = "https://account-center-test.chewrobot.com/api/sdk/user/info";
- String ASIDE_IMG_URL = "http://didi-gz3.jiaoyou365.com:18082/api/works";
}
interface BAI_DU {
@@ -193,4 +159,14 @@ public interface Constants {
String BAIDU_TOKEN = "https://openapi.baidu.com/oauth/2.0/token?grant_type=authorization_code&client_id=dSG525LMr887uLlfAyK1C1ag&client_secret=1azuXoKHMSWT5MVNNkZ4C5mED23qySZh&redirect_uri=https%3A%2F%2Fwww.miaoshop.top%2Fxiaodu%2Fbaidu%2Fcode&code=";
String BAIDU_AUTHORIZE = "https://openapi.baidu.com/oauth/2.0/authorize?response_type=code&client_id=dSG525LMr887uLlfAyK1C1ag&redirect_uri=https%3A%2F%2Fwww.miaoshop.top%2Fxiaodu%2Fbaidu%2Fcode&confirm_login=1&state=mqw";
}
+
+ interface DPL2 {
+ String TRIGGER_HOME_PAGE_LOAD = "loadingPage";
+ String TRIGGER_HOME_PAGE_UPDATE = "homePageUpdate";
+ String ATTRIBUTE_PAGE_UPDATE_COUNT = "updatePageCount";
+ String AUDIO_END = "audio";
+ String PRODUCT_END_MARK = "end";
+ String COLLECT_BUTTON_CLICK = "collectClick";
+ String BACK_TRIGGER = "backTrigger";
+ }
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java
index 98b18ca..58cbab3 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java
@@ -231,6 +231,34 @@ public class OkHttp3Utils {
});
}
+ public static void backPostAsyncByChannel(String url, String requestJsonStr, String channel) {
+ Request request = new Request.Builder()
+ .url(url)
+ .post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestJsonStr))
+ .header("App-Channel-Id", channel)
+ .build();
+ client.newCall(request).enqueue(new Callback() {
+ @Override
+ public void onFailure(@NotNull Call call, @NotNull IOException e) {
+ log.info("退出失败");
+ }
+
+ @Override
+ public void onResponse(@NotNull Call call, @NotNull Response response) throws IOException {
+ try (ResponseBody body = response.body()){
+ body.string();
+// log.info("退出成功:{}", body.string());
+ } catch (SocketTimeoutException e) {
+ log.error("捕获到SocketTimeoutException:{}", e.toString());
+ client.dispatcher().cancelAll();
+ client.connectionPool().evictAll();
+ } catch (Exception e) {
+ log.error("backPostAsync:"+e.toString());
+ }
+ }
+ });
+ }
+
public static void xiaoaiBackPostAsync(String url, String requestJsonStr, Integer type) {
String header = "xiaoai-jiaoyou-audio-test";
if (type != null) {
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Test.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Test.java
deleted file mode 100644
index 74e0a27..0000000
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Test.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package ai.qiwu.com.xiaoduhome.common;
-
-
-/**
- * @author 苗权威
- * @dateTime 19-10-21 下午6:09
- */
-public class Test {
- public static void main(String[] args) {
-
- }
-}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java
index 15cac0e..99c4d80 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java
@@ -13,6 +13,8 @@ import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
+import static ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew.LOAD_AUTH_CALLBACK_URL;
+
/**
* @author 苗权威
* @dateTime 19-6-29 下午5:11
@@ -60,9 +62,9 @@ public class Utils {
* @return
*/
public static boolean verifyLoadRequest(String clientId, String redirectUri) {
- return Constants.SKILL_SECURITY.CLIENT_ID.equals(clientId) &&
- (Constants.SKILL_SECURITY.REDIRECT_URI_TEST.equals(redirectUri)||
- Constants.SKILL_SECURITY.REDIRECT_URI.equals(redirectUri));
+ return Constants.SKILL_SECURITY.CLIENT_ID.equals(clientId) && LOAD_AUTH_CALLBACK_URL.contains(redirectUri);
+// (Constants.SKILL_SECURITY.REDIRECT_URI_TEST.equals(redirectUri)||
+// Constants.SKILL_SECURITY.REDIRECT_URI.equals(redirectUri));
}
/**
@@ -74,9 +76,7 @@ public class Utils {
*/
public static boolean verifyTokenRequest(String clientId, String clientSecret, String redirectUri) {
// log.info("clientID:{},clientSecret:{},redirectUri:{}", clientId, clientSecret, redirectUri);
- return Constants.SKILL_SECURITY.CLIENT_ID.equals(clientId) &&
- (Constants.SKILL_SECURITY.REDIRECT_URI_TEST.equals(redirectUri)||
- Constants.SKILL_SECURITY.REDIRECT_URI.equals(redirectUri)) &&
+ return Constants.SKILL_SECURITY.CLIENT_ID.equals(clientId) && LOAD_AUTH_CALLBACK_URL.contains(redirectUri) &&
Constants.SKILL_SECURITY.CLIENT_SECRET.equals(clientSecret);
}
@@ -135,7 +135,6 @@ public class Utils {
/**
* 获取真实ip
*
- * @param acceptInnerIp 是否可以返回内网ip
* @return 真实ip
*/
public static String getRemoteIpByServletRequest(HttpServletRequest request) {
@@ -261,7 +260,7 @@ public class Utils {
int i;
if (first) {
first = false;
- if (str.equals("十")) {
+ if ("十".equals(str)) {
if (arr.length == 1) return 10;
num.append(1);
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/DataSourceConfig.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/DataSourceConfig.java
index bbbf171..473fa59 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/DataSourceConfig.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/DataSourceConfig.java
@@ -1,5 +1,6 @@
package ai.qiwu.com.xiaoduhome.common.config;
+import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -30,13 +31,31 @@ public class DataSourceConfig {
@Qualifier("primaryDataSource")
@ConfigurationProperties(prefix = "spring.datasource.primary")
public DataSource primaryDataSource() {
- return DataSourceBuilder.create().build();
+ HikariDataSource dataSource = new HikariDataSource();
+ dataSource.setConnectionTimeout(60000);
+ dataSource.setMaxLifetime(60000);
+ dataSource.setMaximumPoolSize(1000);
+ dataSource.setReadOnly(false);
+ dataSource.setIdleTimeout(60000);
+ dataSource.setValidationTimeout(3000);
+ dataSource.setMinimumIdle(10);
+ dataSource.setPoolName("jiaoyoudb");
+ return dataSource;
}
@Bean("secondaryDataSource")
@Qualifier("secondaryDataSource")
@ConfigurationProperties(prefix = "spring.datasource.secondary")
public DataSource secondaryDataSource() {
- return DataSourceBuilder.create().build();
+ HikariDataSource dataSource = new HikariDataSource();
+ dataSource.setConnectionTimeout(60000);
+ dataSource.setMaxLifetime(60000);
+ dataSource.setMaximumPoolSize(1000);
+ dataSource.setReadOnly(false);
+ dataSource.setIdleTimeout(60000);
+ dataSource.setValidationTimeout(3000);
+ dataSource.setMinimumIdle(10);
+ dataSource.setPoolName("audiobox");
+ return dataSource;
}
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/RedisConfig.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/RedisConfig.java
index 82ae6b1..8d9669e 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/RedisConfig.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/RedisConfig.java
@@ -1,6 +1,7 @@
package ai.qiwu.com.xiaoduhome.common.config;
import ai.qiwu.com.xiaoduhome.pojo.OverTimeDetail;
+import ai.qiwu.com.xiaoduhome.pojo.UserBehaviorData;
import ai.qiwu.com.xiaoduhome.pojo.XiaoDuNoScreenStore;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.PropertyAccessor;
@@ -19,12 +20,9 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
@Configuration
public class RedisConfig {
- @Bean
- public RedisTemplate xiaoduRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
- RedisTemplate redisTemplate = new RedisTemplate<>();
- redisTemplate.setConnectionFactory(redisConnectionFactory);
-
- Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer(XiaoDuNoScreenStore.class);
+ @Bean("userBehaviorTemplate")
+ public RedisTemplate xiaoduRedisTemplate(RedisConnectionFactory redisConnectionFactory) {
+ Jackson2JsonRedisSerializer serializer = new Jackson2JsonRedisSerializer<>(UserBehaviorData.class);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
@@ -32,6 +30,8 @@ public class RedisConfig {
serializer.setObjectMapper(objectMapper);
+ RedisTemplate redisTemplate = new RedisTemplate<>();
+ redisTemplate.setConnectionFactory(redisConnectionFactory);
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(serializer);
redisTemplate.setHashKeySerializer(new StringRedisSerializer());
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/WebSocketConfig.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/WebSocketConfig.java
index 711f7fd..551f8fe 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/WebSocketConfig.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/config/WebSocketConfig.java
@@ -8,10 +8,10 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
* @author 苗权威
* @dateTime 19-11-18 下午5:51
*/
-@Configuration
+//@Configuration
public class WebSocketConfig {
- @Bean
+// @Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
index 111dddd..94ce404 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
@@ -1,73 +1,32 @@
package ai.qiwu.com.xiaoduhome.common.temple;
-import ai.qiwu.com.xiaoduhome.common.BaseHolder;
import ai.qiwu.com.xiaoduhome.common.Constants;
-import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyDocument;
-import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyPageItemData;
import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyPojo;
-import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyUtil;
import ai.qiwu.com.xiaoduhome.common.temple.onLunch.LunchBotData;
import ai.qiwu.com.xiaoduhome.common.temple.playUpdate.PlayUpdateDocument;
import ai.qiwu.com.xiaoduhome.common.temple.playUpdate.PlayUpdatePojo;
-import ai.qiwu.com.xiaoduhome.common.temple.rank.RankUtil;
-import ai.qiwu.com.xiaoduhome.common.temple.rank.RankingDocument;
-import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandBotInfo;
-import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandDocument;
-import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandPojo;
-import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
-import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
-import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryBotIdTime;
import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Item;
import ai.qiwu.com.xiaoduhome.pojo.dpl.MyDocument;
-import ai.qiwu.com.xiaoduhome.pojo.pageData.HistoryData;
-import ai.qiwu.com.xiaoduhome.repository.primary.AppFavoriteTBRepository;
-import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryBotTimeRepository;
-import ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil;
-import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.RandomStringUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.stereotype.Component;
-import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Base64;
import java.util.List;
-import static ai.qiwu.com.xiaoduhome.common.Constants.DPL_COMPONENT_ID.PRE_CATEGORY;
import static ai.qiwu.com.xiaoduhome.common.Constants.IMG_CUSTOM_PREFIX;
-import static ai.qiwu.com.xiaoduhome.common.Constants.IMG_PREFIX;
/**
* @author 苗权威
* @dateTime 19-8-24 下午2:03
*/
@Slf4j
-@Component
+//@Component
public class TempleUtils {
- private static FrameTemple FRAME_RAKKING;
- private static FrameTemple FRAME_RECOMMAND;
- private static FrameTemple FRAME_CATEGORY;
-// private static RankingDocument RANKING_DOCUMENT;
-
- static {
- FRAME_RAKKING = JSON.parseObject(getDPLTemple("static/json/frame.json"), FrameTemple.class);
- FRAME_RAKKING.getItems().get(1).getItems().get(0).setText("小度小度,打开排行榜");
- FRAME_RAKKING.getItems().get(0).setText("排行榜");
- FRAME_RECOMMAND = JSON.parseObject(getDPLTemple("static/json/frame.json"), FrameTemple.class);
- FRAME_RECOMMAND.getItems().get(1).getItems().get(0).setText("小度小度,打开推荐页");
- FRAME_RECOMMAND.getItems().get(0).setText("推荐作品");
- FRAME_CATEGORY = JSON.parseObject(getDPLTemple("static/json/frame.json"), FrameTemple.class);
- FRAME_CATEGORY.getItems().get(1).getItems().get(0).setText("小度小度,打开第十七个");
- FRAME_CATEGORY.getItems().get(0).setText("作品分类");
- }
public static PlayUpdateDocument getPlayUpdate(String audio, String text) {
PlayUpdateDocument document = JSON.parseObject(getDPLTemple("static/json/playUpdate.json"), PlayUpdateDocument.class);
@@ -77,170 +36,6 @@ public class TempleUtils {
return document;
}
- public static FunnyDocument getFunnyDocument(List bots) {
- FunnyDocument document = FunnyUtil.getFunnyDocument();
- List datas = new ArrayList<>();
- FunnyPojo page = FunnyUtil.getPagerCom(document);
- List dataList = new ArrayList<>();
- page.setItems(dataList);
- for (OnProductDetail bot : bots) {
- FunnyPageItemData data = new FunnyPageItemData();
- data.setImgSrc(new StringBuilder(IMG_PREFIX).append(bot.getBannerImgUrl()).toString());
- String intro = bot.getIntro();
- if (StringUtils.isBlank(intro)) intro = "作者太懒,啥都没写";
- data.setText(intro);
- data.setHead(correctName(bot.getName()));
- data.setImgId(new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString());
- data.setAnimId(String.valueOf(bot.getId()));
- datas.add(data);
- dataList.add(FunnyUtil.getPagerItem());
- }
- page.setData(datas);
- return document;
- }
-
-// public static RankingDocument getRanking() {
-// if (RANKING_DOCUMENT != null) {
-// return RANKING_DOCUMENT;
-// }
-// RANKING_DOCUMENT = JSON.parseObject(getDPLTemple("static/json/ranking.json"), RankingDocument.class);
-// List datas = new ArrayList<>();
-// StringBuilder botIds = new StringBuilder();
-// for (GameProjectTb bot:ScheduleService.getRankingList()) {
-// botIds.append(bot.getBotAccount()).append(File.separator);
-// String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString();
-// String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
-// RankBotInfo rankBotInfo = new RankBotInfo(imgSrc, imageId, correctName(bot.getName()));
-// datas.add(rankBotInfo);
-// }
-// if (botIds.length() != 0) {
-// botIds.deleteCharAt(botIds.length()-1);
-// String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
-// RANKING_DOCUMENT.setRankBotIds(idToken);
-// }
-// RANKING_DOCUMENT.getMainTemplate().getItems().get(0).getItems().get(2).getItems().get(0).setData(datas);
-// return RANKING_DOCUMENT;
-// }
-
-// public static RankingDocument getRankingFirst() {
-// RankingDocument document = JSON.parseObject(getDPLTemple("static/json/rankFirst.json"), RankingDocument.class);
-// List bots = ScheduleService.getRankingList();
-// List datas = new ArrayList<>();
-// for (int i = 0; i < 3; i++) {
-// GameProjectTb bot = bots.get(i);
-// RankBotInfo data = new RankBotInfo(new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString(),
-// new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString(), correctName(bot.getName()));
-// if (i == 0) data.setLogo("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/first.png");
-// else if (i == 1) data.setLogo("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/second.png");
-// else data.setLogo("https://aliyun-hz1.chewrobot.com/xiaoduhome/image/third.png");
-// OnProductDetail detail = ScheduleService.getProductIdDetail().get(bot.getBotAccount());
-// Date createTime = detail.getCreateTime();
-// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-// String time = sdf.format(createTime);
-// data.setTime(new StringBuilder(Constants.PRODUCT_INTRO.CREATE_TIME).append(time).toString());
-// data.setWatches(new StringBuilder("点击数: ").append(bot.getWatch()).toString());
-// data.setAuth(new StringBuilder(Constants.PRODUCT_INTRO.AUTHOR).append(bot.getAuthorName()).toString());
-// StringBuilder labels = new StringBuilder(Constants.PRODUCT_INTRO.LABEL);
-// for (String label: detail.getLabels()) {
-// labels.append(Constants.PRODUCT_INTRO.SPACE).append(label);
-// }
-// data.setLabel(labels.toString());
-// data.setIntro(detail.getIntro());
-// datas.add(data);
-// }
-// document.getMainTemplate().getItems().get(2).setData(datas);
-// return document;
-// }
-
- public static RecommandDocument getRecommend(int num) {
- RecommandDocument document = JSON.parseObject(getDPLTemple("static/json/recommand2.json"), RecommandDocument.class);
- List firstRowData = new ArrayList<>();
- List secondRowData = new ArrayList<>();
- StringBuilder botIds = new StringBuilder();
- int upBound = num+8 <= ScheduleService.getAllProductCount()? num+8: ScheduleService.getAllProductCount();
- for (int i = num; i < upBound; i++) {
- OnProductDetail detail = ScheduleService.getAllOnProduct().get(i);
- botIds.append(detail.getBotAccount()).append(File.separator);
- String imgSrc = new StringBuilder(IMG_PREFIX).append(detail.getBannerImgUrl()).toString();
- String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(detail.getName()).toString();
- if (i < num+4) {
- RecommandBotInfo recommend = new RecommandBotInfo(imgSrc, imageId, correctName(detail.getName()));
- recommend.setNum(i-num+1);
- firstRowData.add(recommend);
- }else {
- RecommandBotInfo recommend = new RecommandBotInfo(imgSrc, imageId, correctName(detail.getName()));
- recommend.setNum(i-num+1);
- secondRowData.add(recommend);
- }
- }
- if (botIds.length() != 0) {
- botIds.deleteCharAt(botIds.length()-1);
- String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
- document.setRecommendIdList(idToken);
- document.setCount(String.valueOf(upBound-num));
- }
- List listContainer = document.getMainTemplate().getItems().get(2).getItems();
- listContainer.get(0).setData(firstRowData);
- listContainer.get(1).setData(secondRowData);
- return document;
- }
-
- public static RecommandDocument getRecommend() {
- RecommandDocument document = JSON.parseObject(getDPLTemple("static/json/recommand.json"), RecommandDocument.class);
- List datas = new ArrayList<>();
- StringBuilder botIds = new StringBuilder();
- for (GameProjectTb bot:ScheduleService.getRecommendList()) {
- botIds.append(bot.getBotAccount()).append(File.separator);
- String imgSrc = new StringBuilder(IMG_PREFIX).append(bot.getBannerImgUrl()).toString();
- String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
- RecommandBotInfo recommend = new RecommandBotInfo(imgSrc, imageId, correctName(bot.getName()));
- datas.add(recommend);
- }
- if (botIds.length() != 0) {
- botIds.deleteCharAt(botIds.length()-1);
- String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
- document.setRecommendIdList(idToken);
- document.setCount(String.valueOf(botIds.length()));
- }
- document.getMainTemplate().getItems().get(0).getItems().get(2).getItems().get(0).setData(datas);
- return document;
- }
-
- public static CollectHistoryDocument getHistory(String userId) {
- CollectHistoryDocument historyDocument = JSON.parseObject(getDPLTemple("static/json/history.json"), CollectHistoryDocument.class);
- XiaoDuHistoryBotTimeRepository historyTBRepository = BaseHolder.getBean("xiaoDuHistoryBotTimeRepository");
- List historyProInfo = historyTBRepository.getByXiaoduUserId(userId);
- if (historyProInfo == null || historyProInfo.size() == 0) return null;
- ArrayList projectInfoList = new ArrayList<>();
- int i = 1;
- final StringBuilder build = new StringBuilder();
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- for (XiaoDuHistoryBotIdTime historyInfo: historyProInfo) {
- String botAccount = historyInfo.getBotId();
- build.append(botAccount).append(File.separator);
- OnProductDetail productDetail = ScheduleService.getProductIdDetail().get(botAccount);
-
- String intro = productDetail.getIntro();
- if (StringUtils.isBlank(intro)) intro = "作者太懒没写介绍";
- String imgUrl = new StringBuilder(IMG_PREFIX).append(productDetail.getBannerImgUrl()).toString();
- String botAccountId = new StringBuilder(Constants.PRE_ENTER_PRODUCT).append(correctName(productDetail.getName())).toString();
- String lastTime = sdf.format(new java.sql.Date(historyInfo.getLastTime()));
- String name = productDetail.getName();
- HistoryData data = new HistoryData(botAccountId, i++, imgUrl, correctName(name), intro);
- data.setLastTime(lastTime);
- projectInfoList.add(data);
- }
- String idToken;
- if (build.length() != 0) {
- build.deleteCharAt(build.length()-1);
- idToken = Base64.getEncoder().encodeToString(build.toString().getBytes());
- historyDocument.setIdToken(idToken);
- }
- CollectHistoryMainTemplate collectHistoryMainTemplate = historyDocument.getMainTemplate();
- collectHistoryMainTemplate.getItems().get(2).getItems().get(0).setData(projectInfoList);
- return historyDocument;
- }
-
private static MyDocument buildCollectTemple() {
return JSON.parseObject(getDPLTemple("static/json/collect.json"), MyDocument.class);
}
@@ -274,10 +69,10 @@ public class TempleUtils {
int begin = row*4;
String name, imgId, imgSrc;
for (int i = begin; i < begin+4; i++) {
- name = ScheduleServiceNew.CATEGORY[i];
+ name = ScheduleServiceNew.CATEGORY.get(i);
imgSrc = new StringBuilder(IMG_CUSTOM_PREFIX)
.append(ScheduleServiceNew.CATEGORY_CHARAC[i]).append(".png").toString();
- imgId = Constants.DPL_COMPONENT_ID.PRE_CATEGORY +ScheduleServiceNew.CATEGORY[i];
+ imgId = Constants.DPL_COMPONENT_ID.PRE_CATEGORY +ScheduleServiceNew.CATEGORY.get(i);
LunchBotData data = new LunchBotData(imgSrc, imgId, name);
data.setNum(i+1);
dataList.add(data);
@@ -313,18 +108,6 @@ public class TempleUtils {
return builder.toString();
}
- public static FrameTemple getFrameRakking() {
- return FRAME_RAKKING;
- }
-
- public static FrameTemple getFrameRecommand() {
- return FRAME_RECOMMAND;
- }
-
- public static FrameTemple getFrameCategory() {
- return FRAME_CATEGORY;
- }
-
private static FunnyPojo getFunnyPageItemPojo() {
FunnyPojo pojo = new FunnyPojo();
pojo.setType("Container");
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java
index 286e75b..3a71e51 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/onLunch/LunchUtils.java
@@ -4,7 +4,6 @@ import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils;
import ai.qiwu.com.xiaoduhome.common.temple.productInfo.ProductInfoPojo;
import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
-import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
import lombok.extern.slf4j.Slf4j;
@@ -37,7 +36,7 @@ public class LunchUtils {
LunchMainTemplate mainTemplate = new LunchMainTemplate();
document.setMainTemplate(mainTemplate);
- List dataList = ScheduleServiceNew.getTheChannelAllProjectData("baidu-screen-jiaoyou-audio-test");
+ List dataList = ScheduleServiceNew.getTheChannelAllProjectData("jiaoyou-audio-test");
int size = dataList.size();
int rows = size/4 + (size%4 == 0?0:1);
int i, bound;
@@ -75,28 +74,28 @@ public class LunchUtils {
return document;
}
- public static LunchDocument buildLunchDocument() {
- LunchDocument document = new LunchDocument();
- document.setDuration(240000);
- LunchMainTemplate mainTemplate = new LunchMainTemplate();
- document.setMainTemplate(mainTemplate);
-
-// LunchPojo conRecommend = buildLunchList(TempleUtils.buildDataList(ScheduleService.getRecommendList(),1));
-// conRecommend.setFirstItem(Collections.singletonList(TempleUtils.getFrameRecommand()));
-// conRecommend.setMarginTop("8dp");
+// public static LunchDocument buildLunchDocument() {
+// LunchDocument document = new LunchDocument();
+// document.setDuration(240000);
+// LunchMainTemplate mainTemplate = new LunchMainTemplate();
+// document.setMainTemplate(mainTemplate);
//
-// LunchPojo conRanking = buildLunchList(TempleUtils.buildDataList(ScheduleService.getRankingList(), 9));
-// conRanking.setFirstItem(Collections.singletonList(TempleUtils.getFrameRakking()));
-
- LunchPojo conCategory = buildLunchCategoryList(TempleUtils.buildCategoryDataList(0));
- conCategory.setFirstItem(Collections.singletonList(TempleUtils.getFrameCategory()));
-
- LunchPojo scroll = buildLunchScroll();
-// scroll.setItems(Arrays.asList(conRecommend,conRanking,conCategory));
-
-// mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,LUNCH_LOGO_IMG,LUNCH_HSITORY_IMG,LUNCH_COLLECT_IMG,scroll));
- return document;
- }
+//// LunchPojo conRecommend = buildLunchList(TempleUtils.buildDataList(ScheduleService.getRecommendList(),1));
+//// conRecommend.setFirstItem(Collections.singletonList(TempleUtils.getFrameRecommand()));
+//// conRecommend.setMarginTop("8dp");
+////
+//// LunchPojo conRanking = buildLunchList(TempleUtils.buildDataList(ScheduleService.getRankingList(), 9));
+//// conRanking.setFirstItem(Collections.singletonList(TempleUtils.getFrameRakking()));
+//
+// LunchPojo conCategory = buildLunchCategoryList(TempleUtils.buildCategoryDataList(0));
+// conCategory.setFirstItem(Collections.singletonList(TempleUtils.getFrameCategory()));
+//
+// LunchPojo scroll = buildLunchScroll();
+//// scroll.setItems(Arrays.asList(conRecommend,conRanking,conCategory));
+//
+//// mainTemplate.getItems().addAll(Arrays.asList(LUNCH_BACK_IMG,LUNCH_HEAD,LUNCH_LOGO_IMG,LUNCH_HSITORY_IMG,LUNCH_COLLECT_IMG,scroll));
+// return document;
+// }
private static LunchDocument buildCategoryDocument() {
LunchDocument document = new LunchDocument();
@@ -264,7 +263,7 @@ public class LunchUtils {
backGroundImg.setTop("0dp");
backGroundImg.setLeft("0dp");
// backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backNew.jpg");
- backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/headImg.jpg");
+ backGroundImg.setSrc("https://hw-gz25.heyqiwu.cn/duai/image/headImg.jpg");
backGroundImg.setHeight("100%");
backGroundImg.setScaleType("fitXY");
backGroundImg.setWidth("100%");
@@ -286,7 +285,7 @@ public class LunchUtils {
head.setWidth("100%");
head.setHeight("100%");
head.setScaleType("centerCrop");
- head.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/heaImg.png");
+ head.setSrc("https://hw-gz25.heyqiwu.cn/duai/image/heaImg.png");
return head;
}
@@ -336,7 +335,7 @@ public class LunchUtils {
LunchPojo logo = new LunchPojo();
logo.setType("Image");
- logo.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/logo.png");
+ logo.setSrc("https://hw-gz25.heyqiwu.cn/duai/image/logo.png");
logo.setWidth("200dp");
logo.setHeight("58dp");
logoCon.setItems(Collections.singletonList(logo));
@@ -347,7 +346,7 @@ public class LunchUtils {
LunchPojo logo = new LunchPojo();
logo.setType("Image");
logo.setPosition("absolute");
- logo.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/history.png");
+ logo.setSrc("https://hw-gz25.heyqiwu.cn/duai/image/history.png");
logo.setWidth("24dp");
logo.setHeight("24dp");
logo.setScaleType("centerInside");
@@ -361,7 +360,7 @@ public class LunchUtils {
LunchPojo logo = new LunchPojo();
logo.setType("Image");
logo.setPosition("absolute");
- logo.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/collec.png");
+ logo.setSrc("https://hw-gz25.heyqiwu.cn/duai/image/collec.png");
logo.setWidth("24dp");
logo.setHeight("24dp");
logo.setScaleType("centerInside");
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java
index 8d8dcab..3488619 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/play/PlayUtils.java
@@ -3,7 +3,6 @@ package ai.qiwu.com.xiaoduhome.common.temple.play;
import ai.qiwu.com.xiaoduhome.pojo.ActorWithWord;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
import ai.qiwu.com.xiaoduhome.pojo.playAside.PlayPageData;
-import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
import java.util.*;
@@ -165,7 +164,7 @@ public class PlayUtils {
backGroundImg.setTop("20dp");
backGroundImg.setHeight("24dp");
backGroundImg.setWidth("24dp");
- backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/flower.png");
+ backGroundImg.setSrc("https://didi-gz25.heyqiwu.cn/duai/image/flower.png");
backGroundImg.setOnClick(Collections.singletonList(new Event("SendEvent", "playButton")));
backGroundImg.setScaleType("fitCenter");
@@ -181,7 +180,7 @@ public class PlayUtils {
backGroundImg.setHeight("24dp");
backGroundImg.setWidth("24dp");
backGroundImg.setComponentId("playCollect");
- backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/collec.png");
+ backGroundImg.setSrc("https://didi-gz25.heyqiwu.cn/duai/image/collec.png");
backGroundImg.setOnClick(Collections.singletonList(new Event("SendEvent", "playButton")));
backGroundImg.setScaleType("fitCenter");
@@ -197,7 +196,7 @@ public class PlayUtils {
backGroundImg.setHeight("50dp");
backGroundImg.setWidth("50dp");
backGroundImg.setComponentId("playCollect");
- backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/uncollec.png");
+ backGroundImg.setSrc("https://didi-gz25.heyqiwu.cn/duai/image/uncollec.png");
backGroundImg.setOnClick(Collections.singletonList(new Event("SendEvent", "playButton")));
backGroundImg.setScaleType("fitCenter");
@@ -223,7 +222,7 @@ public class PlayUtils {
backGroundImg.setType("Image");
backGroundImg.setComponentId("playCollect");
backGroundImg.setMarginLeft("35dp");
- backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/collec.png");
+ backGroundImg.setSrc("https://didi-gz25.heyqiwu.cn/duai/image/collec.png");
backGroundImg.setHeight("50dp");
backGroundImg.setWidth("50dp");
backGroundImg.setScaleType("fitCenter");
@@ -259,7 +258,7 @@ public class PlayUtils {
backGroundImg.setType("Image");
backGroundImg.setComponentId("playCollect");
backGroundImg.setMarginLeft("35dp");
- backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/uncollec.png");
+ backGroundImg.setSrc("https://didi-gz25.heyqiwu.cn/duai/image/uncollec.png");
backGroundImg.setHeight("50dp");
backGroundImg.setWidth("50dp");
backGroundImg.setScaleType("fitCenter");
@@ -294,7 +293,7 @@ public class PlayUtils {
PlayPojo backGroundImg = new PlayPojo();
backGroundImg.setType("Image");
backGroundImg.setMarginLeft("35dp");
- backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/flower.png");
+ backGroundImg.setSrc("https://didi-gz25.heyqiwu.cn/duai/image/flower.png");
backGroundImg.setHeight("50dp");
backGroundImg.setWidth("50dp");
backGroundImg.setScaleType("fitCenter");
@@ -356,7 +355,7 @@ public class PlayUtils {
backGroundImg.setPosition("absolute");
backGroundImg.setTop("0dp");
backGroundImg.setLeft("0dp");
- backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backNew.jpg");
+ backGroundImg.setSrc("https://didi-gz25.heyqiwu.cn/duai/image/backNew.jpg");
backGroundImg.setHeight("100%");
backGroundImg.setWidth("100%");
backGroundImg.setScaleType("fitXY");
@@ -377,7 +376,7 @@ public class PlayUtils {
PlayPojo logo = new PlayPojo();
logo.setType("Image");
logo.setPosition("absolute");
- logo.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/logo.png");
+ logo.setSrc("https://didi-gz25.heyqiwu.cn/duai/image/logo.png");
logo.setWidth("200dp");
logo.setHeight("58dp");
logo.setTop("20dp");
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java
index 9f4f7de..40f94bf 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/productInfo/ProductInfoUtils.java
@@ -184,7 +184,7 @@ public class ProductInfoUtils {
image.setType("Image");
image.setHeight("60dp");
image.setWidth("60dp");
- image.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/feel.png");
+ image.setSrc("https://hw-gz25.heyqiwu.cn/duai/image/feel.png");
image.setScaleType("fitCenter");
ProductInfoPojo startText = new ProductInfoPojo();
@@ -208,7 +208,7 @@ public class ProductInfoUtils {
image.setType("Image");
image.setHeight("60dp");
image.setWidth("60dp");
- image.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/flower.png");
+ image.setSrc("https://hw-gz25.heyqiwu.cn/duai/image/flower.png");
image.setScaleType("fitCenter");
ProductInfoPojo flower = new ProductInfoPojo();
@@ -272,7 +272,7 @@ public class ProductInfoUtils {
backGroundImg.setPosition("absolute");
backGroundImg.setTop("0dp");
backGroundImg.setLeft("0dp");
- backGroundImg.setSrc("https://didi-gz5.jiaoyou365.com/duai/image/backNew.jpg");
+ backGroundImg.setSrc("https://hw-gz25.heyqiwu.cn/duai/image/backNew.jpg");
backGroundImg.setHeight("100%");
backGroundImg.setWidth("100%");
backGroundImg.setScaleType("fitXY");
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankUtil.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankUtil.java
index 9f88982..f04efab 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankUtil.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/rank/RankUtil.java
@@ -1,14 +1,8 @@
package ai.qiwu.com.xiaoduhome.common.temple.rank;
-import ai.qiwu.com.xiaoduhome.common.BaseHolder;
-import ai.qiwu.com.xiaoduhome.common.Constants;
-import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
-import ai.qiwu.com.xiaoduhome.repository.primary.GameProjectTbRepository;
-import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import lombok.extern.slf4j.Slf4j;
-import java.io.File;
import java.util.*;
/**
@@ -18,121 +12,121 @@ import java.util.*;
@Slf4j
public class RankUtil {
- private static final RankingPojo RANK_FOOTER = buildRankFooter();
-
- private static final RankingPojo RANK_BACKGROUND_IMG = buildRankBackgroundImg();
-
- private static final RankingPojo RANK_HEAD = buildRankHead();
-
- private static final List RANK_CONTAINER_LIST = buildImgTextContainer();
-
- private static RankingDocument RANKING_DOCUMENT;
-
- public static RankingDocument getRankDocument() {
- if (RANKING_DOCUMENT != null) return RANKING_DOCUMENT;
- RANKING_DOCUMENT = new RankingDocument();
- RankingMainTemplate mainTemplate = new RankingMainTemplate();
- RANKING_DOCUMENT.setMainTemplate(mainTemplate);
-
- List dataFirst = new ArrayList<>();
- List dataSec = new ArrayList<>();
- StringBuilder botIds = new StringBuilder();
- int i = 0;
- for (GameProjectTb bot : ScheduleService.getRankingList()) {
- botIds.append(bot.getBotAccount()).append(File.separator);
- String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString();
- String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
- RankBotInfo rankBotInfo = new RankBotInfo(imgSrc, imageId, correctName(bot.getName()));
- if (i < 4) {
- dataFirst.add(rankBotInfo);
- }else if (i < 8){
- dataSec.add(rankBotInfo);
- }else {
- break;
- }
- i++;
- }
- if (botIds.length() != 0) {
- botIds.deleteCharAt(botIds.length()-1);
- String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
- RANKING_DOCUMENT.setRankBotIds(idToken);
- }
- buildMainItem(dataFirst,dataSec, mainTemplate.getItems());
- return RANKING_DOCUMENT;
- }
-
- public static RankingDocument updateRankDocument(int num) {
- RankingDocument document = new RankingDocument();
- RankingMainTemplate mainTemplate = new RankingMainTemplate();
- document.setMainTemplate(mainTemplate);
- GameProjectTbRepository repository = BaseHolder.getBean("gameProjectTbRepository");
- List bots;
- try {
- bots = repository.postRankBot(num*8);
- } catch (Exception e) {
- log.error("查询后续排行榜作品信息出错");
- return null;
- }
- if (bots == null || bots.size() == 0) return null;
- StringBuilder botIds = new StringBuilder();
- List dataFirst = new ArrayList<>();
- List dataSec = new ArrayList<>();
- int i = 1;
- for (GameProjectTb bot: bots) {
- botIds.append(bot.getBotAccount()).append(File.separator);
- String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString();
- String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
- RankBotInfo rankBotInfo = new RankBotInfo(imgSrc, imageId, correctName(bot.getName()));
- rankBotInfo.setNum(i);
- if (i < 4) {
- dataFirst.add(rankBotInfo);
- } else if (i == 4) {
- dataFirst.add(rankBotInfo);
- } else if (i < 9) {
- dataSec.add(rankBotInfo);
- } else {
- break;
- }
- i++;
- }
- if (botIds.length() != 0) {
- botIds.deleteCharAt(botIds.length()-1);
- String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
- document.setRankBotIds(idToken);
- }
- buildMainItem(dataFirst, dataSec, mainTemplate.getItems());
- return document;
- }
-
- private static void buildMainItem(List dataFirst, List dataSec, List items) {
- RankingPojo main = new RankingPojo();
- main.setType("ScrollView");
- main.setHeight("100%");
- main.setWidth("100%");
-
- RankingPojo list = new RankingPojo();
- list.setType("List");
- list.setWidth("100%");
- list.setDirection("horizontal");
- list.setMarginLeft("15dp");
- list.setData(dataFirst);
- list.setItems(RANK_CONTAINER_LIST);
-
- RankingPojo list2 = new RankingPojo();
- list2.setType("List");
- list2.setWidth("100%");
- list2.setDirection("horizontal");
- list2.setMarginLeft("15dp");
- list2.setData(dataSec);
- list2.setItems(RANK_CONTAINER_LIST);
-
- main.setItems(Arrays.asList(list, list2));
-
- items.add(RANK_BACKGROUND_IMG);
- items.add(RANK_HEAD);
- items.add(main);
- items.add(RANK_FOOTER);
- }
+// private static final RankingPojo RANK_FOOTER = buildRankFooter();
+//
+// private static final RankingPojo RANK_BACKGROUND_IMG = buildRankBackgroundImg();
+//
+// private static final RankingPojo RANK_HEAD = buildRankHead();
+//
+// private static final List RANK_CONTAINER_LIST = buildImgTextContainer();
+//
+// private static RankingDocument RANKING_DOCUMENT;
+//
+// public static RankingDocument getRankDocument() {
+// if (RANKING_DOCUMENT != null) return RANKING_DOCUMENT;
+// RANKING_DOCUMENT = new RankingDocument();
+// RankingMainTemplate mainTemplate = new RankingMainTemplate();
+// RANKING_DOCUMENT.setMainTemplate(mainTemplate);
+//
+// List dataFirst = new ArrayList<>();
+// List dataSec = new ArrayList<>();
+// StringBuilder botIds = new StringBuilder();
+// int i = 0;
+// for (GameProjectTb bot : ScheduleService.getRankingList()) {
+// botIds.append(bot.getBotAccount()).append(File.separator);
+// String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString();
+// String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
+// RankBotInfo rankBotInfo = new RankBotInfo(imgSrc, imageId, correctName(bot.getName()));
+// if (i < 4) {
+// dataFirst.add(rankBotInfo);
+// }else if (i < 8){
+// dataSec.add(rankBotInfo);
+// }else {
+// break;
+// }
+// i++;
+// }
+// if (botIds.length() != 0) {
+// botIds.deleteCharAt(botIds.length()-1);
+// String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
+// RANKING_DOCUMENT.setRankBotIds(idToken);
+// }
+// buildMainItem(dataFirst,dataSec, mainTemplate.getItems());
+// return RANKING_DOCUMENT;
+// }
+//
+// public static RankingDocument updateRankDocument(int num) {
+// RankingDocument document = new RankingDocument();
+// RankingMainTemplate mainTemplate = new RankingMainTemplate();
+// document.setMainTemplate(mainTemplate);
+// GameProjectTbRepository repository = BaseHolder.getBean("gameProjectTbRepository");
+// List bots;
+// try {
+// bots = repository.postRankBot(num*8);
+// } catch (Exception e) {
+// log.error("查询后续排行榜作品信息出错");
+// return null;
+// }
+// if (bots == null || bots.size() == 0) return null;
+// StringBuilder botIds = new StringBuilder();
+// List dataFirst = new ArrayList<>();
+// List dataSec = new ArrayList<>();
+// int i = 1;
+// for (GameProjectTb bot: bots) {
+// botIds.append(bot.getBotAccount()).append(File.separator);
+// String imgSrc = new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString();
+// String imageId = new StringBuilder(Constants.PRE_PRODUCT_IMG).append(bot.getName()).toString();
+// RankBotInfo rankBotInfo = new RankBotInfo(imgSrc, imageId, correctName(bot.getName()));
+// rankBotInfo.setNum(i);
+// if (i < 4) {
+// dataFirst.add(rankBotInfo);
+// } else if (i == 4) {
+// dataFirst.add(rankBotInfo);
+// } else if (i < 9) {
+// dataSec.add(rankBotInfo);
+// } else {
+// break;
+// }
+// i++;
+// }
+// if (botIds.length() != 0) {
+// botIds.deleteCharAt(botIds.length()-1);
+// String idToken = Base64.getEncoder().encodeToString(botIds.toString().getBytes());
+// document.setRankBotIds(idToken);
+// }
+// buildMainItem(dataFirst, dataSec, mainTemplate.getItems());
+// return document;
+// }
+
+// private static void buildMainItem(List dataFirst, List dataSec, List items) {
+// RankingPojo main = new RankingPojo();
+// main.setType("ScrollView");
+// main.setHeight("100%");
+// main.setWidth("100%");
+//
+// RankingPojo list = new RankingPojo();
+// list.setType("List");
+// list.setWidth("100%");
+// list.setDirection("horizontal");
+// list.setMarginLeft("15dp");
+// list.setData(dataFirst);
+// list.setItems(RANK_CONTAINER_LIST);
+//
+// RankingPojo list2 = new RankingPojo();
+// list2.setType("List");
+// list2.setWidth("100%");
+// list2.setDirection("horizontal");
+// list2.setMarginLeft("15dp");
+// list2.setData(dataSec);
+// list2.setItems(RANK_CONTAINER_LIST);
+//
+// main.setItems(Arrays.asList(list, list2));
+//
+// items.add(RANK_BACKGROUND_IMG);
+// items.add(RANK_HEAD);
+// items.add(main);
+// items.add(RANK_FOOTER);
+// }
private static RankingPojo buildRankFooter() {
RankingPojo footerCon = new RankingPojo();
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java
index 9dbb0c4..8122ae2 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/recommand/RecommendUtil.java
@@ -3,10 +3,8 @@ package ai.qiwu.com.xiaoduhome.common.temple.recommand;
import ai.qiwu.com.xiaoduhome.common.Constants;
import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils;
-import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData;
import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
-import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
index 3356d73..6999c4e 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
@@ -3,6 +3,7 @@ package ai.qiwu.com.xiaoduhome.controller;
import ai.qiwu.com.xiaoduhome.common.Constants;
import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import ai.qiwu.com.xiaoduhome.common.Utils;
+import ai.qiwu.com.xiaoduhome.dpl2.Dpl2Service;
import ai.qiwu.com.xiaoduhome.pojo.NoticeReceiveData;
import ai.qiwu.com.xiaoduhome.pojo.data.BaseHostData;
import ai.qiwu.com.xiaoduhome.service.*;
@@ -10,6 +11,7 @@ import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.exc.MismatchedInputException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.ScanOptions;
@@ -35,6 +37,13 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public class XiaoDuHomeController {
+ public static volatile String WELCOME_NOVEL = "欢迎来到晓悟智能小说。向您推荐新上线的野蛮女友,您可以说打开野蛮女友。或者说,推荐其它作品。";
+
+ public static volatile String WELCOME_SMART = "欢迎来到晓悟智能故事。我们新上线了遇见伽利略,你可以说打开遇见伽利略。或者说,推荐其它作品。";
+
+// public static volatile String WELCOME_FORMAT = "欢迎来到交游天下。与剧情人物自由对话,带您体验不同的人生和情怀。向您推荐新上线的%s,您可以说打开%s。或者说,推荐其它作品。";
+ public static volatile String WELCOME_FORMAT = "欢迎来到交游天下。与剧情人物自由对话,带您体验不同的人生和情怀。向您推荐新上线的野蛮女友,您可以说打开野蛮女友。或者说,推荐其它作品。";
+
private int test = 0;
private final StringRedisTemplate stringRedisTemplate;
@@ -72,16 +81,18 @@ public class XiaoDuHomeController {
HttpServletRequest request = null;
try {
//log.info("--------------分界线-------------------");
-// DplBotService service = new DplBotService((request=Utils.getHttpServletRequest()), 5);
- DplBotServiceBoth service = new DplBotServiceBoth((request=Utils.getHttpServletRequest()), 5, stringRedisTemplate);
-// log.info("请求信息中的attributes:{}", service.getRequest().getSession().getAttributes());
-// log.info(service.getStrRequest());
+// DplBotServiceBoth service = new DplBotServiceBoth((request=Utils.getHttpServletRequest()), 5, stringRedisTemplate);
+ Dpl2Service service = new Dpl2Service((request=Utils.getHttpServletRequest()), stringRedisTemplate);
+ log.info("请求信息中的attributes:{}", service.getRequest().getSession().getAttributes());
+ log.info(service.getStrRequest());
//service.disableVerify();
service.enableVerify();
- // log.info("响应信息:{}", str);
- return service.run();
+ String str = service.run();
+ log.info("响应信息:{}", str);
+ return str;
+// return service.run();
} catch (MismatchedInputException ex) {
-// log.info("交游探活:"+ex);
+ log.info("交游探活:"+ ExceptionUtils.getStackTrace(ex));
if (test++ < 5) {
try {
Enumeration enumeration = request.getHeaderNames();
@@ -122,7 +133,9 @@ public class XiaoDuHomeController {
// log.info(service.getStrRequest());
//service.disableVerify();
service.enableVerify();
- // log.info("响应信息:{}", str);
+// String str = service.run();
+// log.info("响应信息:{}", str);
+// return str;
return service.run();
} catch (MismatchedInputException ex) {
} catch (Exception e) {
@@ -141,8 +154,8 @@ public class XiaoDuHomeController {
public String novel() {
try {
// log.info("--------------分界线-------------------");
-// DplBotService service = new DplBotService(Utils.getHttpServletRequest(), 2);
DplBotServiceBoth service = new DplBotServiceBoth(Utils.getHttpServletRequest(), 2, stringRedisTemplate);
+// Dpl2Service service = new Dpl2Service(Utils.getHttpServletRequest(), stringRedisTemplate);
// log.info("请求信息中的attributes:{}", service.getRequest().getSession().getAttributes());
// log.info(service.getStrRequest());
//service.disableVerify();
@@ -157,6 +170,18 @@ public class XiaoDuHomeController {
return null;
}
+ @PostMapping("/change/welcome/word")
+ public void changeWelcomeWord(String pwd, String type, String word) {
+ if (StringUtils.startsWith(pwd, "mqw") && pwd.length() == 8) {
+ switch (type) {
+ case "adult" : WELCOME_NOVEL = word;
+ case "child" : WELCOME_SMART = word;
+ case "all" : WELCOME_FORMAT = word;
+ }
+ }
+ log.warn("/change/welcome/word:adult:{},child:{},all:{}", WELCOME_NOVEL, WELCOME_SMART, WELCOME_FORMAT);
+ }
+
@PostMapping("/change/host")
public void changeBaseHost(@RequestBody BaseHostData data) {
if (StringUtils.startsWith(data.getSecretKey(), "mqw")
@@ -305,9 +330,12 @@ public class XiaoDuHomeController {
}
public static void main(String[] args) {
- String s = "a%2Froot%2FTTS-service%2Faudio%2F453766697%2FLiehu1%2F%E6%AD%A3%E5%B8%B8%2F8f4a0d176b4f06b29864898ebcc1c3e6.mp3";
- String s1 = "a%2Froot%2FTTS-service%2Faudio%2F453766697%2FLiehu1%2F%E6%AD%A3%E5%B8%B8%2F8f4a0d176b4f06b29864898ebcc1c3e6.mp3";
- String s2 = "a/root/TTS-service/audio/453766697/Liehu1%2F%E6%AD%A3%E5%B8%B8%2F8f4a0d176b4f06b29864898ebcc1c3e6.mp3";
- String s3 = "/root/TTS-service/audio/453766697/Liehu1%2F%E6%AD%A3%E5%B8%B8%2F8f4a0d176b4f06b29864898ebcc1c3e6.mp3";
+ String welcomeWord = WELCOME_NOVEL;
+ try {
+ welcomeWord = String.format(welcomeWord, "cecece","cecece");
+ } catch (Exception e) {
+ welcomeWord = "fail";
+ }
+ System.out.println(welcomeWord);
}
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/Dpl2Service.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/Dpl2Service.java
new file mode 100644
index 0000000..b412bfa
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/Dpl2Service.java
@@ -0,0 +1,1724 @@
+package ai.qiwu.com.xiaoduhome.dpl2;
+
+import ai.qiwu.com.xiaoduhome.common.BaseHolder;
+import ai.qiwu.com.xiaoduhome.common.Constants;
+import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
+import ai.qiwu.com.xiaoduhome.common.Utils;
+import ai.qiwu.com.xiaoduhome.dpl2.model.*;
+import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuOrderTB;
+import ai.qiwu.com.xiaoduhome.pojo.ActorWithWord;
+import ai.qiwu.com.xiaoduhome.pojo.DialogData;
+import ai.qiwu.com.xiaoduhome.pojo.UserBehaviorData;
+import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData;
+import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuOrderTbRepository;
+import ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil;
+import ai.qiwu.com.xiaoduhome.service.RequestTerminal;
+import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
+import ai.qiwu.com.xiaoduhome.spirit.SpiritRedisService;
+import ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants;
+import com.baidu.dueros.bot.BaseBot;
+import com.baidu.dueros.data.request.IntentRequest;
+import com.baidu.dueros.data.request.LaunchRequest;
+import com.baidu.dueros.data.request.Query;
+import com.baidu.dueros.data.request.SessionEndedRequest;
+import com.baidu.dueros.data.request.audioplayer.event.PlaybackFinishedEvent;
+import com.baidu.dueros.data.request.audioplayer.event.PlaybackNearlyFinishedEvent;
+import com.baidu.dueros.data.request.audioplayer.event.PlaybackStartedEvent;
+import com.baidu.dueros.data.request.audioplayer.event.PlaybackStoppedEvent;
+import com.baidu.dueros.data.request.events.LinkAccountSucceededEvent;
+import com.baidu.dueros.data.request.events.NextRequired;
+import com.baidu.dueros.data.request.pay.event.ChargeEvent;
+import com.baidu.dueros.data.response.OutputSpeech;
+import com.baidu.dueros.data.response.card.Card;
+import com.baidu.dueros.data.response.card.LinkAccountCard;
+import com.baidu.dueros.data.response.directive.SendPart;
+import com.baidu.dueros.data.response.directive.dpl.Document;
+import com.baidu.dueros.data.response.directive.dpl.ExecuteCommands;
+import com.baidu.dueros.data.response.directive.dpl.RenderDocument;
+import com.baidu.dueros.data.response.directive.dpl.commands.ScrollToElementCommand;
+import com.baidu.dueros.data.response.directive.dpl.commands.ScrollToIndexCommand;
+import com.baidu.dueros.data.response.directive.dpl.event.UserEvent;
+import com.baidu.dueros.data.response.directive.pay.Charge;
+import com.baidu.dueros.model.Response;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.RandomUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
+import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.util.CollectionUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.stream.Collectors;
+
+import static ai.qiwu.com.xiaoduhome.common.Constants.*;
+import static ai.qiwu.com.xiaoduhome.common.Constants.DPL_COMPONENT_ID.*;
+import static ai.qiwu.com.xiaoduhome.common.Constants.ErrorMsg.SORRY_UNCATCH;
+import static ai.qiwu.com.xiaoduhome.common.Constants.PRODUCT_INTRO.*;
+import static ai.qiwu.com.xiaoduhome.common.Constants.RE_RA_CA_PAGE_SIZE;
+import static ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil.POOL;
+
+/**
+ * painter
+ * 20-8-24 下午6:18
+ */
+@Slf4j
+public class Dpl2Service extends BaseBot {
+
+ private static Document FIRST_PAGE;
+ private static Document categoryPage;
+
+ private static JsonNode colHisPageData;
+ private static JsonNode productListPageData;
+ private static JsonNode homePageData;
+ private static JsonNode playPageData;
+ private static JsonNode recommendPageData;
+ private static JsonNode productDetailPageData;
+
+ static {
+ try {
+ FIRST_PAGE = ScheduleServiceNew.objectMapper.readValue(DplbotServiceUtil.getDPLTemple("static/dpl2/firstPage.json"), Document.class);
+ categoryPage = ScheduleServiceNew.objectMapper.readValue(Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream("static/dpl2/category.json"), Document.class);
+
+ colHisPageData = ScheduleServiceNew.objectMapper.readTree(Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream("static/dpl2/collectHistory.json"));
+ productListPageData = ScheduleServiceNew.objectMapper.readTree(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream("static/dpl2/productList.json"));
+ homePageData = ScheduleServiceNew.objectMapper.readTree(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream("static/dpl2/home.json"));
+ playPageData = ScheduleServiceNew.objectMapper.readTree(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream("static/dpl2/play.json"));
+ recommendPageData = ScheduleServiceNew.objectMapper.readTree(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream("static/dpl2/recommand.json"));
+ productDetailPageData = ScheduleServiceNew.objectMapper.readTree(Thread.currentThread()
+ .getContextClassLoader().getResourceAsStream("static/dpl2/productDetail.json"));
+
+ } catch (Exception e) {
+ log.error("加载初始化界面失败");
+ }
+ }
+
+ private final String channel;
+ private final StringRedisTemplate stringRedisTemplate;
+
+ private String customUserId;
+
+ public Dpl2Service(HttpServletRequest request, StringRedisTemplate stringRedisTemplate) throws IOException {
+ super(request);
+ this.channel = "baidu-screen-jiaoyou-audio-test";
+// this.channel = "jiaoyou-audio-test";
+ this.stringRedisTemplate = stringRedisTemplate;
+ this.botMonitor.setEnvironmentInfo(PRIVATE_KEY, 1);
+ }
+
+ @Override
+ protected Response onLaunch(LaunchRequest launchRequest) {
+ RenderDocument renderDocument = new RenderDocument(FIRST_PAGE);
+ this.addDirective(renderDocument);
+ // 初次进入时创建用户的行为信息,包括历史记录,送花数,收藏记录
+ // 历史记录,收藏记录,送花数,郊游天下id
+ final String accessToken = getAccessToken();
+ final String userId = customUserId();
+ RequestTerminal.backRequestByChannel(customUserId(), channel);
+ POOL.submit(() -> {
+ if (accessToken == null) {
+ DplbotServiceUtil.onLunchFillUserBehaviorDataInMaster(userId, channel, null, false);
+ } else {
+ UserBehaviorData data = DplbotServiceUtil.getRedisTemplate().opsForValue().get(userId);
+ String jytUserId = null;
+ if (data != null) jytUserId = data.getJytUserId();
+ if (jytUserId == null) jytUserId = DplbotServiceUtil.getUserIdByToken(accessToken, channel, userId);
+ UserBehaviorData behaviorData = DplbotServiceUtil.onLunchFillUserBehaviorDataInMaster(userId, channel, jytUserId, true);
+ log.info("onLunch data:"+behaviorData);
+ }
+ });
+ setSessionAttribute(BACK_TRACE, null);
+ return new Response();
+ }
+
+ @Override
+ protected Response onInent(IntentRequest intentRequest) {
+ String redisId = SpiritRedisService.PREFIX_REDIS+customUserId();
+ if (Boolean.TRUE.equals(stringRedisTemplate.hasKey(redisId))) {
+ String trace = getSessionAttribute(BACK_TRACE);
+ if (StringUtils.endsWith(trace, File.separator)) {
+ String lastData;
+ if ((lastData=stringRedisTemplate.opsForValue().get(redisId))!=null) {
+ String redisIdleId = SpiritRedisService.PREFIX_REDIS_IDLE+customUserId();
+ if ("out".equals(lastData)) {
+ String idleNum = stringRedisTemplate.opsForValue().get(redisIdleId);
+ boolean firstIdle;
+ if ((firstIdle = StringUtils.isBlank(idleNum)) || "1".equals(idleNum)) {
+ try {
+ Thread.sleep(2000);
+ } catch (Exception e){
+ // do nothing
+ }
+ lastData = stringRedisTemplate.opsForValue().get(redisId);
+ if (StringUtils.isNotBlank(lastData) && !"out".equals(lastData)) {
+ stringRedisTemplate.delete(redisIdleId);
+ stringRedisTemplate.delete(redisId);
+// return dealScreenOutTimeResult(lastData, getUserId(), channel);
+ }
+ if (firstIdle) idleNum = "1";
+ else idleNum = "2";
+ stringRedisTemplate.opsForValue().set(redisIdleId, idleNum, 10, TimeUnit.SECONDS);
+ return buildTextResponse((RandomUtils.nextInt() & 1) == 1 ? XiaoAiConstants.TTS.WAIT_WORD_1 :
+ XiaoAiConstants.TTS.WAIT_WORD_2);
+ } else {
+ stringRedisTemplate.delete(redisIdleId);
+ stringRedisTemplate.delete(redisId);
+ }
+ } else {
+ stringRedisTemplate.delete(redisIdleId);
+ stringRedisTemplate.delete(redisId);
+ return dealScreenOutTimeResult(lastData);
+ }
+ } else {
+ log.info("outtime lastData is null");
+ }
+ } else {
+ stringRedisTemplate.delete(redisId);
+ }
+ }
+ try {
+ Future future = DplbotServiceUtil.getPOOL().submit(() -> dealDefaultIntent(intentRequest, customUserId(), null));
+ return future.get(2500, TimeUnit.MILLISECONDS);
+ } catch (InterruptedException | ExecutionException e) {
+ log.warn("获取任务执行结果出错:{}", ExceptionUtils.getStackTrace(e));
+ return buildTextResponse(SORRY_UNCATCH);
+ } catch (TimeoutException e) {
+ log.info("超时,让用户再说一遍:{}",e.toString());
+ stringRedisTemplate.opsForValue().setIfAbsent(redisId, "out", 10, TimeUnit.SECONDS);
+ addDirective(new SendPart("outTime"));
+ return buildTextResponse("主人请稍等,晓悟正在加载数据");
+ } catch (Exception all) {
+ log.warn("任务执行发生了错误:{}", ExceptionUtils.getStackTrace(all));
+ return buildTextResponse(SORRY_UNCATCH);
+ }
+ }
+
+ @Override
+ protected Response onUserEvent(UserEvent userEvent) {
+ String componentId = userEvent.getPayload().getComponentId();
+ log.info("componentId:"+componentId);
+ try {
+ switch (componentId) {
+ case DPL2.TRIGGER_HOME_PAGE_UPDATE: {
+ this.setExpectSpeech(true);
+ return buildTextResponse("获取更多作品请对我说,刷新");
+ }
+ case DPL2.TRIGGER_HOME_PAGE_LOAD: {
+ openRandomHome();
+ return buildTextResponse(Constants.WelcomeWord.WELCOME);
+ }
+ case DPL2.AUDIO_END : return audioEvent();
+ case DPL2.BACK_TRIGGER : {
+ setSessionAttribute(CUR_FIRST_ROW_INDEX, null);
+ return dealBackIntent();
+ }
+ default: {
+ String componentPrefix = componentId.substring(0, 5);
+ switch (componentPrefix) {
+ case Constants.PRE_PRODUCT_IMG : return dealOpenProductDetail(ScheduleServiceNew.getProjectByName(componentId.substring(5)));
+ case Constants.PRE_ENTER_PRODUCT : return directInProduct(componentId.substring(5));
+ case FLOWE : return dealSendFlowerIntent(customUserId(), "1");
+ case PRE_COLLE : return dealCollectOrUnCollectIntent("colleCo".equals(componentId), null);
+ case PRE_CATEGORY : return openCategoryProductList(componentId.substring(5), 1);
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("onUserEvent error:"+ ExceptionUtils.getStackTrace(e));
+ }
+ return new Response();
+ }
+
+ private Response audioEvent() {
+ if (getSessionAttribute("end") != null) {
+ try {
+ setSessionAttribute("end", null);
+ String endData = stringRedisTemplate.opsForValue().get(SpiritRedisService.PREFIX_REDIS+customUserId()+"_end");
+ String path = OkHttp3Utils.doPostJsonStr(ScheduleServiceNew.BASE_HOST_URL+"9663/api/audio", endData);
+ if (StringUtils.isBlank(path) || "null".equals(path)) {
+ log.error("onNextRequiredEvent 小度没有获取到音频链接");
+ return new Response();
+ }
+ CentralResponseVO vo = ScheduleServiceNew.objectMapper.readValue(endData, CentralResponseVO.class);
+ DialogData datum = vo.getDialogs().stream().filter(dialogData ->
+ dialogData.getBotAccount().equals(ScheduleServiceNew.getTheChannelBotAccount(channel))).findFirst().orElse(null);
+ if (datum == null) {
+ log.error("onNextRequiredEvent 没有找到推荐bot的话语:"+endData);
+ return new Response();
+ }
+ this.setExpectSpeech(true);
+ return dealRecommend(null, datum.getText(), path);
+ } catch (Exception e) {
+ log.warn(ExceptionUtils.getStackTrace(e));
+ }
+ }
+ this.setExpectSpeech(true);
+ return new Response();
+ }
+
+ @Override
+ protected Response onSessionEnded(SessionEndedRequest sessionEndedRequest) {
+ RequestTerminal.backRequestByChannel(customUserId(), channel);
+ return super.onSessionEnded(sessionEndedRequest);
+ }
+
+ @Override
+ protected Response onPlaybackStartedEvent(PlaybackStartedEvent playbackStartedEvent) {
+ return super.onPlaybackStartedEvent(playbackStartedEvent);
+ }
+
+ @Override
+ protected Response onPlaybackStoppedEvent(PlaybackStoppedEvent playbackStoppedEvent) {
+ return super.onPlaybackStoppedEvent(playbackStoppedEvent);
+ }
+
+ @Override
+ protected Response onPlaybackNearlyFinishedEvent(PlaybackNearlyFinishedEvent playbackNearlyFinishedEvent) {
+ return super.onPlaybackNearlyFinishedEvent(playbackNearlyFinishedEvent);
+ }
+
+ @Override
+ protected Response onPlaybackFinishedEvent(PlaybackFinishedEvent playbackFinishedEvent) {
+ return super.onPlaybackFinishedEvent(playbackFinishedEvent);
+ }
+
+ @Override
+ protected Response onLinkAccountSucceededEvent(LinkAccountSucceededEvent linkAccountSucceededEvent) {
+// log.info("登录成功返回信息:{}",linkAccountSucceededEvent);
+ String accessToken = getAccessToken();
+ String jytUserId;
+ if (!isNoScreenRequest()) {
+ log.info("检测到有屏登录");
+ String userId = customUserId();
+ jytUserId = DplbotServiceUtil.getUserIdByToken(accessToken, channel, userId);
+ DplbotServiceUtil.onLunchFillUserBehaviorData(userId, channel, jytUserId, true);
+// DplbotServiceUtil.noticeOtherServer(5, null, null, false, userId, jytUserId, channel, false);
+ if (jytUserId == null) {
+ log.warn("登录后获取用户的app id 失败");
+ }
+ } else {
+ jytUserId = DplbotServiceUtil.getUserIdByToken(accessToken, null, getUserId());
+ if (jytUserId == null)
+ log.warn("登录后获取用户的app id 失败");
+ }
+ setSessionAttribute("userId", jytUserId);
+ return buildTextResponse("您已登录成功");
+ }
+
+ @Override
+ protected Response onChargeEvent(ChargeEvent chargeEvent) {
+ String token = chargeEvent.getToken();
+ String[] tokens = token.split(File.separator);
+ log.info("onChargeEvent token:"+token);
+ final String botAccount = tokens[0];
+ String str = "恭喜您支付成功,开始体验吧";
+ if (!isNoScreenRequest()) {
+ String userId = getUserId();
+ String jytUserId = getSessionAttribute("userId");
+ Boolean response = DplbotServiceUtil.dealChargeCallback(chargeEvent, userId, getAccessToken(),
+ jytUserId, ScheduleServiceNew.getWorkNameByBotAccount(botAccount), channel);
+ log.info("onChargeEvent response:"+response);
+ if (Boolean.TRUE.equals(response)) {
+ DplbotServiceUtil.updateUserFlower(userId, Integer.parseInt(tokens[1]), channel,
+ jytUserId, getAccessToken(), botAccount);
+ try {
+ if ("0".equals(tokens[2])) {
+ log.info("onChargeEvent in project token:{}",token);
+ dealOpenProductDetail(ScheduleServiceNew.getProjectByBotAccount(botAccount));
+ str = "恭喜您支付成功";
+ }
+ } catch (Exception e) {
+ log.warn(ExceptionUtils.getStackTrace(e));
+ }
+ } else {
+ str = "很抱歉,您没有支付成功";
+ }
+ } else {
+ String userId = customUserId();
+ String jytUserId = getSessionAttribute("userId");
+ if (StringUtils.isBlank(jytUserId)) jytUserId = DplbotServiceUtil.getUserIdByToken(getAccessToken(), channel, getUserId());
+ if (StringUtils.isBlank(jytUserId)) {
+ jytUserId = "null";
+ }
+ boolean response = DplbotServiceUtil.dealChargeCallback(chargeEvent, userId, getAccessToken(),
+ jytUserId, ScheduleServiceNew.getWorkNameByBotAccount(botAccount), channel);
+ if (!response) {
+ str = "很抱歉,您没有支付成功";
+ }
+ }
+ return buildTextResponse(str);
+ }
+
+ @Override
+ protected Response onNextRequiredEvent(NextRequired nextRequired) {
+ try {
+ switch (nextRequired.getToken()) {
+ case "outTime": {
+ String lastData;
+ String redisId = SpiritRedisService.PREFIX_REDIS+customUserId();
+ if ((lastData=stringRedisTemplate.opsForValue().get(redisId))!=null) {
+ if ("out".equals(lastData)) {
+ stringRedisTemplate.delete(redisId);
+ setExpectSpeech(true);
+ return buildTextResponse("主人晓悟加载数据失败了,请您再重复下刚才的操作吧");
+ } else {
+ stringRedisTemplate.delete(redisId);
+ return dealScreenOutTimeResult(lastData);
+ }
+ } else {
+ log.info("send part out time lastData is null");
+ setExpectSpeech(true);
+ return new Response();
+ }
+ }
+ case "end": {
+ String endData = stringRedisTemplate.opsForValue().get(SpiritRedisService.PREFIX_REDIS+customUserId()+"_end");
+ String path = OkHttp3Utils.doPostJsonStr(ScheduleServiceNew.BASE_HOST_URL+"9663/api/audio", endData);
+ if (StringUtils.isBlank(path) || "null".equals(path)) {
+ log.error("onNextRequiredEvent 小度没有获取到音频链接");
+ return new Response();
+ }
+ CentralResponseVO vo = ScheduleServiceNew.objectMapper.readValue(endData, CentralResponseVO.class);
+ DialogData datum = vo.getDialogs().stream().filter(dialogData ->
+ dialogData.getBotAccount().equals(ScheduleServiceNew.getTheChannelBotAccount(channel))).findFirst().orElse(null);
+ if (datum == null) {
+ log.error("onNextRequiredEvent 没有找到推荐bot的话语:"+endData);
+ return new Response();
+ }
+ return dealRecommend(null, datum.getText(), path);
+ }
+ case "direct" :{
+ String data = stringRedisTemplate.opsForValue().get(SpiritRedisService.PREFIX_REDIS_DIRECT+customUserId());
+ String path;
+ CentralResponseVO centralResponse;
+ try {
+ path = OkHttp3Utils.doPostJsonStr(ScheduleServiceNew.BASE_AUDIO_URL+"/api/audio", data);
+ centralResponse = ScheduleServiceNew.objectMapper.readValue(data, CentralResponseVO.class);
+ } catch (Exception e) {
+ log.warn("onNextRequiredEvent 没有获取到TTS返回地址");
+ return buildTextResponse("主人晓悟加载数据失败了,您可以通过点击来进入游戏");
+ }
+ if (StringUtils.isBlank(path) || "null".equals(path)) {
+ log.error("onNextRequiredEvent 小度没有获取到音频链接");
+ return buildTextResponse("主人晓悟加载数据失败了,您可以通过点击来进入游戏");
+ }
+ String botAccount = centralResponse.getAipioneerUsername();
+ return openPlayPage(centralResponse.getPlotImgUrl(),ScheduleServiceNew.getWorkNameByBotAccount(botAccount),
+ dealAudioUrl(path, botAccount), DplbotServiceUtil.getTheActorsWithWords(centralResponse.getDialogs(), botAccount), botAccount);
+ }
+// case "payed" : {
+// log.info("success pay part");
+// String trace = getSessionAttribute(BACK_TRACE);
+// if (StringUtils.isNotBlank(trace)) {
+// String word = USER_SEND_FLOWER+USER_HISTORY.get(getUserId()).getUserBotId2Flowers().get(trace.substring(2));
+// log.info("flower num update:"+word);
+// ExecuteCommands executeCommands = new ExecuteCommands();
+// SetStateCommand stateCommand = new SetStateCommand();
+// stateCommand.setComponentId("pft");
+// stateCommand.setState("text");
+// stateCommand.setValue(word);
+// executeCommands.addCommand(stateCommand);
+// addDirective(executeCommands);
+// }
+// }
+ }
+ } catch (Exception e) {
+ log.error(ExceptionUtils.getStackTrace(e));
+ }
+ return new Response();
+ }
+
+ private Response dealScreenOutTimeResult(String data) {
+ try {
+ String[] arr = data.split("⧩");
+ JsonNode object = ScheduleServiceNew.objectMapper.readValue(arr[0], JsonNode.class);
+ String path = arr[1];
+ if (Boolean.parseBoolean(arr[2])) {
+ setSessionAttribute(DPL2.PRODUCT_END_MARK, "1");
+ }
+ String botAccount = object.get("aipioneerUsername").asText();
+ ArrayNode arrayNode = (ArrayNode) object.get("dialogs");
+ if (botAccount.equals(ScheduleServiceNew.getTheChannelBotAccount(channel))){
+ return dealRecommend(data, arrayNode.get(0).get("text").asText(), path);
+ }
+ setExpectSpeech(true);
+ return openPlayPage(object.get("plotImgUrl").asText(),ScheduleServiceNew.getWorkNameByBotAccount(botAccount), dealAudioUrl(path, botAccount),
+ DplbotServiceUtil.getTheActorsWithWords(arrayNode, botAccount), botAccount);
+ }catch (Exception e) {
+ log.error("dealScreenOutTimeResult error:"+e);
+ }
+ setExpectSpeech(true);
+ return buildTextResponse("主人晓悟加载数据失败了,请再说一遍吧");
+ }
+
+ private Response dealDefaultIntent(IntentRequest intentRequest, String userId, String word) {
+ if (word == null) {
+ Query query = intentRequest.getQuery();
+ if (query != null) word = query.getOriginal();
+ if (word == null){
+ log.info("小度没有传来任何话语");
+ return buildTextResponse(SORRY_UNCATCH);
+ }
+ }
+ String data = null;
+ CentralResponseVO centralResponse;
+ try {
+ data = RequestTerminal.requestTerminateTemp(word, userId, channel);
+ centralResponse = ScheduleServiceNew.objectMapper.readValue(data, CentralResponseVO.class);
+ } catch (Exception e) {
+ log.error("请求终端接口出错:{}, data:{}", e.toString(), data);
+ return buildTextResponse(SORRY_UNCATCH);
+ }
+ log.info("小悟返回:"+data);
+ if (StringUtils.isBlank(data)) {
+ return buildTextResponse(SORRY_UNCATCH);
+ }
+ try {
+ List commands = centralResponse.getCommands();
+ if (commands != null && commands.size() == 1) {
+ String txt = commands.get(0).getText();
+ int i;
+ if (StringUtils.isNotBlank(txt) && (i = txt.indexOf("☛")) != -1) {
+ int end = txt.indexOf("☚");
+ String command = txt.substring(i+1, end).trim();
+ if (StringUtils.isNotBlank(command)) {
+ if (command.contains("out")) {
+ log.info("小度,推荐bot退出:{},{}",word,userId);
+ return buildTextResponse("本技能暂不支持该功能,若您想要退技能,请说小度小度,退出");
+ }
+ String curFirstRowIndex = getSessionAttribute(CUR_FIRST_ROW_INDEX);
+ if (curFirstRowIndex != null) setSessionAttribute(CUR_FIRST_ROW_INDEX, null);
+ switch (command) {
+ case "refresh" : return homePageRefresh();
+ case "recommend": return dealRecommend(data, centralResponse.getDialogs().get(0).getText(), null);
+ case "history" : return dealHistoryIntent(1);
+ case "collect" : return dealOpenCollectIntent(1);
+ case "next" : return dealNextPageIntent();
+ case "before" : return dealLastPageIntent();
+ case "back" : return dealBackIntent();
+ case "load" : return load();
+ case "start" : return dealStartIntent(intentRequest);
+ case "openRank" : return dealRankIntent(1);
+ case "openNum" : return dealOpenNumIntent(end+1 == txt.length() ? "1" : txt.substring(end+1));
+ case "jump" : return dealJumpIntent(end+1 == txt.length() ? "1" : txt.substring(end+1));
+ case "store" : return dealCollectOrUnCollectIntent( true, end+1 == txt.length() ? null : txt.substring(end+1));
+ case "unStore" : return dealCollectOrUnCollectIntent( false, end+1 == txt.length() ? null : txt.substring(end+1));
+ case "flower" : return dealSendFlowerIntent(userId, end+1 == txt.length() ? "1" : txt.substring(end+1));
+ case "category" : return openCategory();
+ case "up" : return dealUpOrDownCommand(true, curFirstRowIndex);
+ case "down" : return dealUpOrDownCommand(false, curFirstRowIndex);
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ log.error("解析出错:"+e);
+ return new Response();
+ }
+ boolean endMark = false;
+ if ("exit".equalsIgnoreCase(centralResponse.getBotStatus())) {
+ String trace = getSessionAttribute(BACK_TRACE);
+ if (StringUtils.endsWith(trace, File.separator)) {
+ String botAccount = trace.substring(2, trace.length()-1);
+ if (!CollectionUtils.isEmpty(centralResponse.getDialogs())) {
+ final List recommendWord = new ArrayList<>(2);
+ List botDatas = centralResponse.getDialogs().stream()
+ .filter(dialogData -> {
+ if (botAccount.equals(dialogData.getBotAccount())) return true;
+ recommendWord.add(dialogData);
+ return false;
+ })
+ .collect(Collectors.toList());
+ if (botDatas.size() == 0) {
+ return dealBackIntent();
+ } else {
+ log.info("end recommend:"+recommendWord);
+ try {
+ CentralResponseVO vo = new CentralResponseVO();
+ vo.setDialogs(recommendWord);
+ vo.setAipioneerUsername(centralResponse.getAipioneerUsername());
+ stringRedisTemplate.opsForValue().set(SpiritRedisService.PREFIX_REDIS+userId+"_end",
+ ScheduleServiceNew.objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(vo),
+ 50, TimeUnit.SECONDS);
+ endMark = true;
+ } catch (Exception e) {
+ log.error("end recommend json error:"+e);
+ }
+ centralResponse.setDialogs(botDatas);
+ centralResponse.setAipioneerUsername(botDatas.get(0).getBotAccount());
+ }
+
+ } else {
+ return dealBackIntent();
+ }
+ } else {
+ return dealBackIntent();
+ }
+ }
+
+ String botAccount = centralResponse.getAipioneerUsername();
+ if (StringUtils.isBlank(botAccount)) {
+ log.warn("central response data botAccount is null:"+data);
+ setExpectSpeech(true);
+ return buildTextResponse("主人晓悟加载数据失败了,请再说一遍吧");
+ }
+ String path;
+ try {
+ path = OkHttp3Utils.doPostJsonStr(ScheduleServiceNew.BASE_AUDIO_URL+"/api/audio", data);
+// log.info("================path:{}, BASE_AUDIO_URL:{}",path, ScheduleServiceNew.BASE_AUDIO_URL);
+ } catch (Exception e) {
+ log.warn("没有获取到TTS返回地址");
+ return buildTextResponse(Constants.ErrorMsg.SORRY_UNCATCH);
+ }
+ if (StringUtils.isBlank(path) || "null".equals(path)) {
+ log.error("小度没有获取到音频链接");
+ return buildTextResponse(Constants.ErrorMsg.SORRY_UNCATCH);
+ }
+ if (!endMark && botAccount.equals(ScheduleServiceNew.getTheChannelBotAccount(channel))){
+ return dealRecommend(data, centralResponse.getDialogs().get(0).getText(), dealAudioUrl(path, botAccount));
+ }
+
+ String beforeBotAccount = getSessionAttribute("botAcc");
+ if (!botAccount.equals(beforeBotAccount)) {
+ DplbotServiceUtil.updateTheUserHistory(userId, botAccount, getAccessToken(), channel, getSessionAttribute("userId"));
+ }
+ if (Boolean.TRUE.equals(stringRedisTemplate.opsForValue().setIfPresent(SpiritRedisService.PREFIX_REDIS+userId,
+ new StringBuilder(data).append("⧩").append(path).append("⧩").append(endMark).toString(), 20, TimeUnit.SECONDS))) {
+ return new Response();
+ }
+ if (endMark) {
+ setSessionAttribute(DPL2.PRODUCT_END_MARK, "1");
+ }
+ return openPlayPage(centralResponse.getPlotImgUrl(),ScheduleServiceNew.getWorkNameByBotAccount(botAccount), dealAudioUrl(path, botAccount),
+ DplbotServiceUtil.getTheActorsWithWords(centralResponse.getDialogs(), botAccount), botAccount);
+ }
+
+ // =================== up/down page =================
+
+ private Response dealUpOrDownCommand(boolean up, String curFirstRowIndex) {
+ int i;
+ if (StringUtils.isBlank(curFirstRowIndex)) {
+ i = 1;
+ } else {
+ i = Integer.parseInt(curFirstRowIndex);
+ }
+ String trace = getSessionAttribute(BACK_TRACE);
+ if (trace == null || trace.length() < 2) {
+ return dealPageUpDown(up, i, 4);
+ } else if (StringUtils.endsWith(trace, File.separator)) {
+ return dealPageUpDown(up, i, 5);
+ } else if (trace.length() > 2){
+ return buildTextResponse("主人,晓悟认为您现在所在的页面不支持滑动,晓悟错了吗?");
+ }
+ char type = trace.charAt(1);
+ switch (type) {
+ case '1' :
+ case '2' : return dealPageUpDown(up, i, CO_HI_PAGE_SIZE);
+ case '4' :
+ case '5' : return dealPageUpDown(up, i, 3);
+ case '7' : return dealPageUpDown(up, i, 2);
+ default : return buildTextResponse("主人,晓悟认为您现在所在的页面不支持滑动,晓悟错了吗?");
+ }
+ }
+
+ private Response dealPageUpDown(boolean up, int curFirstRowIndex, int bound) {
+ int nextIndex;
+ if (up) {
+ nextIndex = curFirstRowIndex+1;
+ if (nextIndex > bound) nextIndex = bound;
+ } else {
+ nextIndex = curFirstRowIndex - 1;
+ if (nextIndex < 1) nextIndex = 1;
+ }
+ ExecuteCommands commands = new ExecuteCommands();
+ ScrollToElementCommand elementCommand = new ScrollToElementCommand();
+ elementCommand.setAlign(ScrollToIndexCommand.AlignType.FIRST);
+ elementCommand.setComponentId(SCROLL_ID);
+ elementCommand.setTargetComponentId(String.valueOf(nextIndex));
+ commands.addCommand(elementCommand);
+ addDirective(commands);
+ setSessionAttribute(CUR_FIRST_ROW_INDEX, String.valueOf(nextIndex));
+ return new Response();
+ }
+
+ // =================== home page refresh ================
+ private Response homePageRefresh() {
+ String trace = getSessionAttribute(BACK_TRACE);
+ if (trace == null || trace.length() < 2) {
+ return openRandomHome();
+ }
+ return buildTextResponse("主人,该页面不支持刷新");
+ }
+
+ // ==================== flower ==================
+
+ private Response dealSendFlowerIntent(String userId, String numStr) {
+ if (getAccessToken() == null) {
+ setExpectSpeech(true);
+ return buildTextResponse("主人,该功能需要登录,请说登录");
+ }
+ int num = DplbotServiceUtil.extractNum(numStr);
+ int unitPrice = Integer.parseInt(ScheduleServiceNew.FLOWER_UNIT_PRICE);
+ String amount = String.valueOf(unitPrice*num/100.0);
+ String orderId = userId +"_"+ System.currentTimeMillis();
+ String appUserId = getSessionAttribute("userId");
+ if (appUserId == null) {
+ appUserId = DplbotServiceUtil.getUsUserId(userId,getAccessToken(), channel);
+ if (appUserId == null) {
+ log.error("送花时获取用户app_user_id失败");
+ return buildTextResponse("不好意思主人,晓悟出了点问题,请再说一遍");
+ }
+ setSessionAttribute("userId", appUserId);
+ }
+ String botId;
+ String trace = getSessionAttribute(BACK_TRACE);
+ if (trace != null && trace.length() > 2) {
+ boolean inPlay;
+ if ((inPlay=StringUtils.endsWith(trace, File.separator))) {
+ botId = trace.substring(2, trace.length()-1);
+ }else {
+ botId = trace.substring(2);
+ }
+
+ XiaoDuOrderTB orderTB = buildBeforePayPojo(botId, appUserId, userId, unitPrice, num, orderId);
+ if (orderTB == null) {
+ return buildTextResponse("不好意思主人,晓悟出了点问题,请再说一遍");
+ }
+ XiaoDuOrderTbRepository repository = BaseHolder.getBean("xiaoDuOrderTbRepository");
+ XiaoDuOrderTB response = repository.save(orderTB);
+ if (response.getId() != null) {
+ String desc = new StringBuilder("感谢您赏赐给").append(orderTB.getWorkName())
+ .append("的").append(num).append("朵鲜花").toString();
+ Charge charge = new Charge(amount, orderId, "鲜花", desc);
+ charge.setToken(botId + File.separator + num + File.separator + (inPlay ? 1 : 0));
+ addDirective(charge);
+ return buildTextResponse(desc+",请扫描屏幕上的二维码完成支付");
+ } else {
+ log.warn("订单没有插入到xioadu_order_tb");
+ return buildTextResponse("不好意思主人,晓悟出了点问题,请再说一遍");
+ }
+ }else {
+ log.warn("页面不支持送花意图,trace:"+trace);
+ return buildTextResponse("不好意思主人,晓悟无法确定您的位置,不知到您要收藏什么作品");
+ }
+ }
+
+
+ private XiaoDuOrderTB buildBeforePayPojo(String botAccount, String appUserId, String userId, int unitPrice,
+ long number, String orderId) {
+ XiaoDuOrderTB xiaoDuOrderTB = new XiaoDuOrderTB();
+ buildPayPojoCommon(xiaoDuOrderTB, botAccount, appUserId, userId, unitPrice, number, orderId);
+ if (xiaoDuOrderTB.getWorkName() == null) {
+ log.warn("没有通过botAccount获取到作品名");
+ return null;
+ }
+ xiaoDuOrderTB.setDevice(1);
+ return xiaoDuOrderTB;
+ }
+
+ private void buildPayPojoCommon(XiaoDuOrderTB xiaoDuOrderTB, String botAccount, String appUserId, String userId, int unitPrice,
+ long number, String orderId) {
+ String workName = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
+ if (StringUtils.isBlank(workName)) return;
+ xiaoDuOrderTB.setWorkName(workName);
+ xiaoDuOrderTB.setAppUserId(appUserId);
+ xiaoDuOrderTB.setXiaoduUserId(userId);
+ xiaoDuOrderTB.setUnitPrice(unitPrice);
+ xiaoDuOrderTB.setNumber(number);
+ xiaoDuOrderTB.setIsBuy(false);
+ xiaoDuOrderTB.setStatus(false);
+ xiaoDuOrderTB.setChOrderId(orderId);
+ xiaoDuOrderTB.setTimeStamp(System.currentTimeMillis());
+ xiaoDuOrderTB.setChannelId(channel);
+ }
+
+ // ====================================collect unCollect ======================
+
+ private Response dealCollectOrUnCollectIntent(boolean collect, String workName) {
+ if (getAccessToken() == null) {
+ setExpectSpeech(true);
+ return buildTextResponse("主人,该功能需要登录,请说登录");
+ }
+// boolean inProductInfo = false;
+// boolean inPlayInfo = false;
+ String botAccount;
+ String trace = getSessionAttribute(BACK_TRACE);
+ if (trace == null || trace.length() <= 2) {
+ if (workName != null) {
+ workName = workName.replaceAll("[ \uD83C\uDD70\uD83C\uDD71]", "");
+ if (StringUtils.isBlank(workName)) {
+ setExpectSpeech(true);
+ return buildTextResponse("主人,您需要明确说出您要操作的作品名称");
+ }
+ botAccount = ScheduleServiceNew.getBotAccountByWorkname(workName);
+ if (StringUtils.isBlank(botAccount)) {
+ return buildTextResponse("不好意思主人,晓悟没有找到该作品");
+ }
+ } else {
+ setExpectSpeech(true);
+ return buildTextResponse("主人,您需要明确说出您要操作的作品名称");
+ }
+ } else {
+ if (StringUtils.endsWith(trace, File.separator)) {
+ botAccount = trace.substring(2, trace.length()-1);
+// inPlayInfo = true;
+ }
+ else {
+// inProductInfo = true;
+ botAccount = trace.substring(2);
+ }
+ }
+ try {
+ String appUserId = getSessionAttribute("userId");
+ if (appUserId == null) appUserId = DplbotServiceUtil.getUsUserId(customUserId(),getAccessToken(), channel);
+ boolean alreadyCollected = DplbotServiceUtil.doesUserCollectThisBot(botAccount, getAccessToken(), customUserId(),
+ channel, appUserId);
+ if (appUserId != null) {
+ if (alreadyCollected) {
+ if (collect) {
+ return buildTextResponse("主人,您已经收藏过该作品了");
+ } else {
+ boolean result = DplbotServiceUtil.userUnCollectTheBot(customUserId(), botAccount,
+ channel, appUserId, getAccessToken());
+ if (!result) {
+ return buildTextResponse("不好意思主人,晓悟出了点问题没有取消成功");
+ }
+ String botName = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
+// if (inProductInfo) {
+// sss
+// }
+ return buildTextResponse(String.format(UN_COLLECT_BOT_WORD_MG,botName));
+ }
+ } else {
+ if (collect) {
+ boolean result = DplbotServiceUtil.userCollectTheBot(customUserId(), botAccount, channel,
+ appUserId, getAccessToken());
+ if (!result) {
+ return buildTextResponse("不好意思主人,晓悟出了点问题没有收藏成功");
+ }
+ String botName = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
+// if (inProductInfo) {
+// sss
+// }
+ return buildTextResponse(String.format(COLLECT_BOT_WORD_MG,botName));
+ }else {
+ return buildTextResponse("主人,您还未收藏过该作品");
+ }
+ }
+ }else {
+ return buildTextResponse("不好意思主人,晓悟走神了,没能理解您的意思");
+ }
+ } catch (Exception e) {
+ log.error("收藏/取消收藏出错:{}",e.toString());
+ return buildTextResponse("不好意思主人,晓悟走神了,没能理解您的意思");
+ }
+ }
+
+ // ========================= jump =======================
+
+ private Response dealJumpIntent(String numStr) {
+ String trace = getSessionAttribute("trace");
+ if (trace == null || trace.length() < 2) {
+ return buildTextResponse("主人,当前的页面不能跳页");
+ }
+ int index = DplbotServiceUtil.extractNum(numStr);
+ if (index <= 0) index = 1;
+ String nextPageIndex = getSessionAttribute(NEXT_PAGE_INDEX);
+ if (StringUtils.isNotBlank(nextPageIndex) && String.valueOf(index+1).equals(nextPageIndex)) {
+ return buildTextResponse("主人,晓悟认为您现在就在第"+index+"页");
+ }
+ char pageSign = trace.charAt(1);
+ Response response;
+ switch (pageSign) {
+ case '1' : response = dealOpenCollectIntent(index);break;
+ case '2' : response = dealHistoryIntent(index);break;
+ case '4' : response = dealRankIntent(index);break;
+ case '5' : response = openCategoryProductList(getSessionAttribute(CATEGORY_NAME), index);break;
+ default : response = buildTextResponse("主人,当前的页面不能跳页");
+ }
+ return response;
+ }
+
+ // =========================next/pre page=======================
+
+ private Response dealNextPageIntent() {
+ String signPage = getSessionAttribute("trace");
+ if (signPage == null || signPage.length() < 2) {
+ return buildTextResponse("主人,小悟滑不动了,需要休息会");
+ }
+ char sign = signPage.charAt(1);
+ String nextPageIndex = getSessionAttribute(NEXT_PAGE_INDEX);
+ if (nextPageIndex == null) {
+ nextPageIndex = "2";
+ }
+ switch (sign) {
+ // collect
+ case '1': {
+ dealOpenCollectIntent(Integer.parseInt(nextPageIndex));
+ break;
+ }
+ // history
+ case '2': {
+ dealHistoryIntent(Integer.parseInt(nextPageIndex));
+ break;
+ }
+ // rank
+ case '4': {
+ dealRankIntent(Integer.parseInt(nextPageIndex));
+ break;
+ }
+ // category product list page
+ case '5':{
+ String category = getSessionAttribute("category");
+ if (category == null) category = "古风";
+ openCategoryProductList(category, Integer.parseInt(nextPageIndex));
+ break;
+ }
+ default:{
+ return buildTextResponse("主人,当前页面没有下一页");
+ }
+ }
+ return new Response();
+ }
+
+ private Response dealLastPageIntent() {
+ String signPage = getSessionAttribute("trace");
+ if (signPage == null || signPage.length() < 2) {
+ return buildTextResponse("主人,小悟滑不动了,需要休息会");
+ }
+ char sign = signPage.charAt(1);
+ String nextPageIndex = getSessionAttribute(NEXT_PAGE_INDEX);
+ if (nextPageIndex == null || "2".equals(nextPageIndex)) {
+ return buildTextResponse("主人,小悟没法再往前翻了");
+ }
+ switch (sign) {
+ // collect
+ case '1': {
+ dealOpenCollectIntent(Integer.parseInt(nextPageIndex)-2);
+ break;
+ }
+ // history
+ case '2': {
+ dealHistoryIntent(Integer.parseInt(nextPageIndex)-2);
+ break;
+ }
+ // rank
+ case '4': {
+ dealRankIntent(Integer.parseInt(nextPageIndex)-2);
+ break;
+ }
+ // category product list page
+ case '5':{
+ String category = getSessionAttribute("category");
+ if (category == null) category = "古风";
+ openCategoryProductList(category, Integer.parseInt(nextPageIndex)-2);
+ break;
+ }
+ default:{
+ return buildTextResponse("主人,当前页面没有上一页");
+ }
+ }
+ return new Response();
+ }
+
+ // ============ back intent===================================
+
+ private Response dealBackIntent() {
+ String trace = getSessionAttribute(BACK_TRACE);
+ char second;
+ String query;
+ if (trace == null || ((query=getQuery()) != null && query.contains("首"))) {
+ // home page
+ openRandomHome();
+ if (StringUtils.endsWith(trace,File.separator)) {
+ RequestTerminal.backRequestByChannel(customUserId(), channel);
+ }
+ return buildTextResponse("主人,已为您返回到首页");
+ }
+ else if (trace.length() <= 2) {
+ if (trace.charAt(1) == '5') {
+ return openCategory();
+ } else {
+ openRandomHome();
+ return buildTextResponse("主人,已为您返回到首页");
+ }
+ }
+ else if (StringUtils.endsWith(trace,File.separator)){
+ String botAccount = trace.substring(2, trace.length()-1);
+ dealOpenProductDetail(ScheduleServiceNew.getProjectByBotAccount(botAccount));
+ RequestTerminal.backRequestByChannel(customUserId(), channel);
+ return buildTextResponse("主人,已为您返回到作品介绍页");
+ } else {
+ second = trace.charAt(1);
+ switch (second){
+ // home page
+ case '0':{
+ openRandomHome();
+ return buildTextResponse("主人,已为您返回到首页");
+ }
+ case '1': {
+ //collect
+ String nextPageIndex = getSessionAttribute(NEXT_PAGE_INDEX);
+ if (nextPageIndex == null) {
+ nextPageIndex = "2";
+ }
+ dealOpenCollectIntent(Integer.parseInt(nextPageIndex)-1);
+ return buildTextResponse("主人,已为您返回到收藏页");
+ }
+ case '2': {
+ //history
+ String nextPageIndex = getSessionAttribute(NEXT_PAGE_INDEX);
+ if (nextPageIndex == null) {
+ nextPageIndex = "2";
+ }
+ dealHistoryIntent(Integer.parseInt(nextPageIndex)-1);
+ return buildTextResponse("主人,已为您返回到历史记录页");
+ }
+ case '4': {
+ //rank
+ String nextPageIndex = getSessionAttribute(NEXT_PAGE_INDEX);
+ if (nextPageIndex == null) {
+ nextPageIndex = "2";
+ }
+ dealRankIntent(Integer.parseInt(nextPageIndex)-1);
+ return buildTextResponse("主人,已为您返回到排行榜");
+ }
+ case '5':{
+ String category = getSessionAttribute("category");
+ if (category == null) {
+ openRandomHome();
+ return buildTextResponse("主人,已为您返回到首页");
+ } else {
+ String nextPageIndex = getSessionAttribute(NEXT_PAGE_INDEX);
+ if (nextPageIndex == null) {
+ nextPageIndex = "2";
+ }
+ openCategoryProductList(category, Integer.parseInt(nextPageIndex)-1);
+
+ return buildTextResponse("已为您返回到" + category + "类作品列表页");
+ }
+ }
+ }
+ }
+ return new Response();
+ }
+
+ // ======================== open num intent =================
+
+ private Response dealOpenNumIntent(String numStr) {
+ String trace = getSessionAttribute("trace");
+ int num = DplbotServiceUtil.extractNum(numStr);
+ if (trace == null || trace.charAt(1) == '0') {
+ return dealOpenNumInHome(num);
+ } else if (trace.length() > 2) {
+ return buildTextResponse("主人,小悟认为该页面不支持打开功能,您可以直接点击屏幕");
+ } else if (num <= 0) {
+ num = 1;
+ }
+ char page = trace.charAt(1);
+ Response response;
+ switch (page){
+ case '1': response = dealOpenNumCoHi(num, true); break;
+ case '2': response = dealOpenNumCoHi(num, false); break;
+ case '4': response = dealOpenNumRank(num); break;
+ case '6': response = dealOpenNumRecommend(num); break;
+ case '5': response = dealOpenCategoryProduct(num);break;
+ case '7': response = dealOpenCategory(num);break;
+ default:{
+ response = buildTextResponse("主人,对不起小悟没能理解,您可以直接点击屏幕上的按钮");
+ }
+ }
+ return response;
+ }
+
+ private Response dealOpenNumInHome(int num) {
+ if (num > 12) {
+ return buildTextResponse("主人,小悟没有找到该作品");
+ }
+ String actualIndex = getSessionAttribute(START_ACTUAL_INDEX);
+ if (StringUtils.isBlank(actualIndex)) {
+ actualIndex = "0";
+ }
+ List dataList = ScheduleServiceNew.getTheChannelAllProjectData(channel);
+ ProjectData data = dataList.get((Integer.parseInt(actualIndex)+num-1)%dataList.size());
+ if (!DplbotServiceUtil.doesUserPlayed(data.getBotAccount(), getUserId(),
+ getAccessToken(), getAccessToken() != null)) {
+ return dealOpenProductDetail(data);
+ } else {
+ return directInProduct(data.getName());
+ }
+ }
+
+ private Response directInProduct(final String productName) {
+ addDirective(new SendPart("direct"));
+ POOL.submit(() -> {
+ String enterProductWord = Constants.PRE_PRODUCT_PLAY + productName;
+ String data = null;
+ try {
+ data = RequestTerminal.requestTerminateTemp(enterProductWord, getUserId(), channel);
+ } catch (IOException e) {
+ log.error("请求终端接口出错:", e.toString());
+ }
+ if (data == null) {
+ return;
+ }
+ stringRedisTemplate.opsForValue().set(SpiritRedisService.PREFIX_REDIS_DIRECT+customUserId(),
+ data, 15, TimeUnit.SECONDS);
+ });
+ return buildTextResponse("主人,晓悟正在为您打开"+productName+",请您稍等");
+ }
+
+ private Response dealOpenNumCoHi(int num, boolean collect) {
+ UserBehaviorData data = DplbotServiceUtil.getRedisTemplate().opsForValue().get(customUserId());
+ if (data == null) {
+ data = DplbotServiceUtil.onLunchFillUserBehaviorDataInMaster(customUserId(), channel, getSessionAttribute("userId"), getAccessToken() != null);
+ if (data == null) return new Response();
+ }
+ Set> entry;
+ if (collect) {
+ entry = data.getUserBotId2Collected().entrySet();
+ } else {
+ entry = data.getUserBotId2History().entrySet();
+ }
+ if (num > entry.size()) {
+ return buildTextResponse("主人,小悟没有找到您的第"+num+"个记录");
+ }
+ TreeMap order = new TreeMap<>((o1, o2) -> (o1 < o2) ? 1 : ((o1.equals(o2)) ? 0 : -1));
+ for (Map.Entry item: entry) {
+ order.put(item.getValue(), item.getKey());
+ }
+ String productName = ScheduleServiceNew.getProjectByBotAccount(order.values()
+ .toArray(new String[]{})[num-1]).getName();
+ return directInProduct(productName);
+ }
+
+ private Response dealOpenNumRank(int num) {
+ List botData = ScheduleServiceNew.getTheChannelProjectsByWatch(channel);
+ if (num > botData.size()) {
+ return buildTextResponse("主人,小悟没有找到排名"+num+"的作品");
+ }
+ ProjectData data = botData.get(num-1);
+ if (!DplbotServiceUtil.doesUserPlayed(data.getBotAccount(), getUserId(),
+ getAccessToken(), getAccessToken() != null)) {
+ return dealOpenProductDetail(data);
+ } else {
+ return directInProduct(data.getName());
+ }
+ }
+
+ private Response dealOpenNumRecommend(int num) {
+ String nameList = getSessionAttribute(PRE_COLLE);
+ if (StringUtils.isBlank(nameList)) {
+ return buildTextResponse("主人,小悟不知道您要打开哪个作品,只能麻烦你亲自动手了");
+ }
+ String[] names = nameList.split(",");
+ if (num > names.length) {
+ return buildTextResponse("主人,这个数字超出了范围");
+ }
+ ProjectData data = ScheduleServiceNew.getProjectByName(names[num-1]);
+ if (!DplbotServiceUtil.doesUserPlayed(data.getBotAccount(), getUserId(),
+ getAccessToken(), getAccessToken() != null)) {
+ return dealOpenProductDetail(data);
+ } else {
+ return directInProduct(data.getName());
+ }
+ }
+
+ private Response dealOpenCategory(int num) {
+ if (num > ScheduleServiceNew.CATEGORY.size()) {
+ return buildTextResponse("主人,这个数字超出了范围");
+ }
+ return openCategoryProductList(ScheduleServiceNew.CATEGORY.get(num-1), 1);
+ }
+
+ private Response dealOpenCategoryProduct(int num) {
+ String categoryName = getSessionAttribute(CATEGORY_NAME);
+ if (StringUtils.isBlank(categoryName)) {
+ return buildTextResponse("主人,晓悟不知道您现在的位置,只能麻烦你亲自动手了");
+ }
+ List dataList = ScheduleServiceNew.category2Bots.get(categoryName);
+ if (num > dataList.size()) {
+ return buildTextResponse("主人,这个数字超出了范围");
+ }
+ ProjectData data = dataList.get(num-1);
+ if (!DplbotServiceUtil.doesUserPlayed(data.getBotAccount(), getUserId(),
+ getAccessToken(), getAccessToken() != null)) {
+ return dealOpenProductDetail(data);
+ } else {
+ return directInProduct(data.getName());
+ }
+ }
+
+ ///===============================页面==============================
+
+// private Response dealOpenHome() {
+// try {
+// JsonNode jsonNode = homePageData.deepCopy();
+// ObjectNode dataList = (ObjectNode) jsonNode.get("dataSource");
+// List botData = ScheduleServiceNew.getTheChannelAllProjectData(channel);
+//
+// ArrayNode arrayNode = ScheduleServiceNew.objectMapper.createArrayNode();
+// arrayNode.addAll(rowColumn4(botData, 0, 4).parallelStream().map(homePageData ->
+// ScheduleServiceNew.objectMapper.convertValue(homePageData, JsonNode.class))
+// .collect(Collectors.toList()));
+// dataList.set("contentList", arrayNode);
+// RenderDocument renderDocument = new RenderDocument(ScheduleServiceNew.objectMapper
+// .readValue(jsonNode.toPrettyString(), Document.class));
+// addDirective(renderDocument);
+// setSessionAttribute(PRE_COLLE,);
+// OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, Constants.WelcomeWord.WELCOME);
+// return new Response(outputSpeech);
+// } catch (Exception e) {
+// log.error("dealOpenHome error:"+e);
+// }
+// return new Response();
+// }
+
+ private Response openPlayPage(String backgroundImg, String title, String audio, List aws, String botAccount) {
+ try {
+ JsonNode jsonNode = playPageData.deepCopy();
+ ObjectNode dataList = (ObjectNode) jsonNode.get("dataSource");
+ dataList.set("contentList", ScheduleServiceNew.objectMapper.convertValue(aws, ArrayNode.class));
+ dataList.put("audio", audio);
+ if (StringUtils.isNotBlank(backgroundImg)) {
+ dataList.put("backgroundImg", backgroundImg);
+ }
+ if (title != null) {
+ dataList.put("headerTitle", title);
+ }
+ RenderDocument renderDocument = new RenderDocument(ScheduleServiceNew.objectMapper
+ .readValue(jsonNode.toPrettyString(), Document.class));
+ addDirective(renderDocument);
+
+ String trace = getSessionAttribute(BACK_TRACE);
+ if (trace == null || trace.length() != 2) trace = "00";
+ trace += botAccount + File.separator;
+ setSessionAttribute(BACK_TRACE, trace);
+ setSessionAttribute("botAcc", botAccount);
+ } catch (Exception e) {
+ log.error("openPlayPage error:"+e);
+ }
+ return new Response();
+ }
+
+ private Response openRandomHome() {
+ try {
+ JsonNode jsonNode = homePageData.deepCopy();
+ ObjectNode dataList = (ObjectNode) jsonNode.get("dataSource");
+ List botData = ScheduleServiceNew.getTheChannelAllProjectData(channel);
+ ArrayNode arrayNode = ScheduleServiceNew.objectMapper.createArrayNode();
+ int start;
+ arrayNode.addAll(rowColumn4Recur(botData, (start=RandomUtils.nextInt(0, botData.size()))).stream().map(homePageData ->
+ ScheduleServiceNew.objectMapper.convertValue(homePageData, JsonNode.class))
+ .collect(Collectors.toList()));
+ dataList.set("contentList", arrayNode);
+ RenderDocument renderDocument = new RenderDocument(ScheduleServiceNew.objectMapper
+ .readValue(jsonNode.toPrettyString(), Document.class));
+ addDirective(renderDocument);
+ setSessionAttribute(BACK_TRACE, null);
+ setSessionAttribute(START_ACTUAL_INDEX, String.valueOf(start));
+ return new Response();
+ } catch (Exception e) {
+ log.error("dealOpenHome error:"+e);
+ }
+ return new Response();
+ }
+
+ private Response dealRankIntent(int pageIndex) {
+ try {
+ JsonNode jsonNode = productListPageData.deepCopy();
+ ObjectNode dataList = (ObjectNode) jsonNode.get("dataSource");
+ List botData = ScheduleServiceNew.getTheChannelProjectsByWatch(channel);
+ int start = (pageIndex-1)*RE_RA_CA_PAGE_SIZE;
+ if (start >= botData.size()) {
+ return buildTextResponse("主人,没有更多了");
+ }
+ ArrayNode arrayNode = ScheduleServiceNew.objectMapper.createArrayNode();
+ arrayNode.addAll(rowColumn4(botData, start, 3).stream().map(homePageData ->
+ ScheduleServiceNew.objectMapper.convertValue(homePageData, JsonNode.class))
+ .collect(Collectors.toList()));
+ dataList.set("contentList", arrayNode);
+ dataList.put("headerTitle", "排行榜");
+ dataList.put("sideText", pageIndex + "/" +
+ (botData.size()/RE_RA_CA_PAGE_SIZE + (botData.size()%RE_RA_CA_PAGE_SIZE==0?0:1)));
+ dataList.put("rank", true);
+ RenderDocument renderDocument = new RenderDocument(ScheduleServiceNew.objectMapper
+ .readValue(jsonNode.toPrettyString(), Document.class));
+ addDirective(renderDocument);
+ setSessionAttribute(NEXT_PAGE_INDEX, String.valueOf(pageIndex+1));
+ setSessionAttribute(BACK_TRACE, "04");
+ return buildTextResponse("主人,正在为您打开排行榜,请稍等");
+ } catch (Exception e) {
+ log.error("dealRankIntent:"+e);
+ }
+ return new Response();
+ }
+
+ private Response openCategory() {
+ try {
+ RenderDocument render = new RenderDocument(categoryPage);
+ addDirective(render);
+ setSessionAttribute(BACK_TRACE,"07");
+ return buildTextResponse("主人,正在为您打开分类页,请稍等");
+ } catch (Exception e) {
+ log.error("dealOpenCategory:"+e);
+ }
+ return new Response();
+ }
+
+ private Response openCategoryProductList(String categoryName, int pageIndex) {
+ try {
+ if (StringUtils.isBlank(categoryName)) {
+ return buildTextResponse("主人,晓悟无法确定您现在的位置,只能麻烦您亲自动手了");
+ }
+ JsonNode jsonNode = productListPageData.deepCopy();
+ ObjectNode dataList = (ObjectNode) jsonNode.get("dataSource");
+ List botData = ScheduleServiceNew.category2Bots.get(categoryName);
+ int start = (pageIndex-1)*RE_RA_CA_PAGE_SIZE;
+ if (start >= botData.size()) {
+ return buildTextResponse("主人,没有更多了");
+ }
+
+ ArrayNode arrayNode = ScheduleServiceNew.objectMapper.createArrayNode();
+ arrayNode.addAll(rowColumn4(botData, start, 3).stream().map(homePageData ->
+ ScheduleServiceNew.objectMapper.convertValue(homePageData, JsonNode.class))
+ .collect(Collectors.toList()));
+ dataList.set("contentList", arrayNode);
+ dataList.put("headerTitle", categoryName);
+ dataList.put("sideText", pageIndex + "/" +
+ botData.size()/RE_RA_CA_PAGE_SIZE + (botData.size()%RE_RA_CA_PAGE_SIZE==0?0:1));
+ RenderDocument renderDocument = new RenderDocument(ScheduleServiceNew.objectMapper
+ .readValue(jsonNode.toPrettyString(), Document.class));
+ addDirective(renderDocument);
+ setSessionAttribute(NEXT_PAGE_INDEX, String.valueOf(pageIndex+1));
+ setSessionAttribute(BACK_TRACE, "75");
+ setSessionAttribute(CATEGORY_NAME, categoryName);
+ return buildTextResponse("主人,为您展示如下"+categoryName+"类型作品");
+ } catch (Exception e) {
+ log.error("dealRankIntent:"+e);
+ }
+ return new Response();
+ }
+
+ private Response dealRecommend(String data, String text, String path) {
+ try {
+ if (StringUtils.isBlank(path)) {
+ path = OkHttp3Utils.doPostJsonStr(ScheduleServiceNew.BASE_AUDIO_URL+"/api/audio", data);
+ if (StringUtils.isBlank(path) || "null".equals(path)) {
+ log.error("dealRecommend小度没有获取到音频链接");
+ return buildTextResponse(ErrorMsg.SORRY_UNCATCH);
+ }
+ path = dealAudioUrl(path, ScheduleServiceNew.getTheChannelBotAccount(channel));
+ }
+ List botNames = Utils.getRecommandBotNames(text);
+ AtomicInteger num = new AtomicInteger(1);
+ List botData = botNames.stream()
+ .map(s -> {
+ ProjectData bot = ScheduleServiceNew.getProjectByName(s);
+ if (bot == null) return null;
+ ProjectClickData clickData = new ProjectClickData();
+ clickData.setNum1(num.getAndIncrement());
+ clickData.setImageId1(Constants.PRE_PRODUCT_IMG + bot.getName());
+ clickData.setImageName1(bot.getName());
+ clickData.setImg1(bot.getBannerImgUrl());
+ return clickData;
+ })
+ .filter(Objects::nonNull).collect(Collectors.toList());
+ if (CollectionUtils.isEmpty(botData)) return new Response();
+ JsonNode jsonNode = recommendPageData.deepCopy();
+ ObjectNode dataList = (ObjectNode) jsonNode.get("dataSource");
+ ArrayNode arrayNode = ScheduleServiceNew.objectMapper.createArrayNode();
+ arrayNode.addAll(botData.stream().map(homePageData ->
+ ScheduleServiceNew.objectMapper.convertValue(homePageData, JsonNode.class))
+ .collect(Collectors.toList()));
+ dataList.set("contentList", arrayNode);
+ dataList.put("audio", path);
+ addDirective(new RenderDocument(ScheduleServiceNew.objectMapper
+ .readValue(jsonNode.toPrettyString(), Document.class)));
+ setSessionAttribute(PRE_COLLE, String.join(",",botNames));
+ setSessionAttribute(BACK_TRACE, "06");
+ } catch (Exception e) {
+ log.warn("dealRecommend:"+e);
+ }
+ return new Response();
+ }
+
+ private Response dealHistoryIntent(int indexPage) {
+ try {
+ CoHiPageData data = getDpl2History(customUserId(), indexPage);
+ if (data == null) {
+ return buildTextResponse("主人,没有找到您的游戏记录");
+ } else if (StringUtils.isBlank(data.getHeaderTitle())) {
+ return buildTextResponse("主人,没有更多了");
+ }
+ JsonNode jsonNode = colHisPageData.deepCopy();
+ ObjectNode root = (ObjectNode) jsonNode;
+ root.set("dataSource", ScheduleServiceNew.objectMapper.convertValue(data, JsonNode.class));
+
+ addDirective(new RenderDocument(ScheduleServiceNew.objectMapper
+ .readValue(jsonNode.toPrettyString(), Document.class)));
+ setSessionAttribute(BACK_TRACE, "02");
+ setSessionAttribute(NEXT_PAGE_INDEX, String.valueOf(indexPage+1));
+ return buildTextResponse("主人,正在为您打开历史记录,请稍等");
+ } catch (Exception e) {
+ log.error("dealHistoryIntent error:"+e);
+ }
+ return new Response();
+ }
+
+ private Response dealOpenCollectIntent(int indexPage) {
+ if (getAccessToken() == null) {
+ return buildTextResponse("主人,该功能需要登录,请说小度小度,登录");
+ } else {
+ try {
+ CoHiPageData data = getDpl2Collect(customUserId(), indexPage);
+ if (data == null) {
+ return new Response();
+ } else if (data.getHeaderTitle() == null) {
+ return buildTextResponse("主人,没有找到您的收藏记录");
+ }
+ JsonNode jsonNode = colHisPageData.deepCopy();
+ ObjectNode root = (ObjectNode) jsonNode;
+ root.set("dataSource", ScheduleServiceNew.objectMapper.convertValue(data, JsonNode.class));
+
+ addDirective(new RenderDocument(ScheduleServiceNew.objectMapper
+ .readValue(jsonNode.toPrettyString(), Document.class)));
+ setSessionAttribute(NEXT_PAGE_INDEX, String.valueOf(indexPage+1));
+ setSessionAttribute(BACK_TRACE, "01");
+ return buildTextResponse("主人,正在为您打开收藏列表,请稍等");
+ } catch (Exception e) {
+ log.error("dealOpenCollectIntent error:"+e);
+ }
+ return new Response();
+ }
+ }
+
+ private Response dealOpenProductDetail(ProjectData productDetail) {
+ try {
+ if (productDetail == null) {
+ log.warn("dealOpenProductDetail没有找到作品");
+ return new Response();
+ }
+ String accessToken = getAccessToken();
+ String userId = customUserId();
+ String productName = productDetail.getName();
+
+ ProjectDetailData data = new ProjectDetailData();
+
+ SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
+ String dateString = formatter.format(productDetail.getCreateTime());
+ data.setImgUrl(productDetail.getBannerImgUrl());
+ data.setWorkName(productDetail.getName());
+ data.setTime(PRODUCT_INTRO.CREATE_TIME + dateString);
+ data.setAuthor(PRODUCT_INTRO.AUTHOR + productDetail.getAuthorName());
+ data.setLabel(Constants.PRODUCT_INTRO.LABEL+String.join(PRODUCT_INTRO.SPACE, productDetail.getLabels()));
+ data.setIntro(productDetail.getIntro());
+ data.setId(Constants.PRE_ENTER_PRODUCT + productName);
+
+ // "start product" container button
+ // collectText, collectUrl, collectComId
+ String flowers;
+ boolean collect = false;
+ if (accessToken != null) {
+ Long flowerCount = DplbotServiceUtil.getUserSendFlowerNum(productDetail.getBotAccount(), userId,
+ channel,accessToken, getSessionAttribute("userId"));
+ flowers = USER_SEND_FLOWER+flowerCount;
+
+ // collection container button
+ collect = DplbotServiceUtil.didUserCollecThisProduct(productDetail.getBotAccount(), userId,
+ accessToken, getSessionAttribute("userId"));
+ data.setLogin(true);
+// if (collec) {
+// collectText = COLLECED;
+// collectUrl = COLLECTED_IMG_URL;
+// collectComId = UN_COLLEC_ID + productDetail.getBotAccount();
+// } else {
+// collectText = UN_COLLEC;
+// collectUrl = UN_COLLECTED_IMG_URL;
+// collectComId = COLLEC_ID + productDetail.getBotAccount();
+// }
+ } else {
+ flowers = FLOWER;
+ data.setLogin(false);
+
+// collectText = UN_COLLEC;
+// collectUrl = UN_COLLECTED_IMG_URL;
+// collectComId = FLOWER_LOAD;
+ }
+ data.setFlowerId(FLOWE + productDetail.getBotAccount());
+ data.setFlowText(flowers);
+ data.setCollect(collect);
+// data.setCollectImg(collectUrl);
+// data.setCollectId(collectComId);
+// data.setCollectText(collectText);
+
+ JsonNode jsonNode = productDetailPageData.deepCopy();
+ ObjectNode root = (ObjectNode) jsonNode;
+ root.set("dataSource", ScheduleServiceNew.objectMapper.convertValue(data, JsonNode.class));
+
+ addDirective(new RenderDocument(ScheduleServiceNew.objectMapper
+ .readValue(jsonNode.toPrettyString(), Document.class)));
+
+ String trace = getSessionAttribute(BACK_TRACE);
+ StringBuilder builder = new StringBuilder();
+ if (trace == null || trace.length() < 2) {
+ builder.append("00");
+ } else if (trace.length()>2) {
+ builder.append(trace, 0, 2);
+ } else {
+ builder.append(trace);
+ }
+
+ trace = builder.append(productDetail.getBotAccount()).toString();
+ setSessionAttribute(BACK_TRACE, trace);
+ } catch (Exception e) {
+ log.error("dealOpenProductDetail:"+e);
+ }
+ return new Response();
+ }
+
+ // ===================== load ====================
+
+ private Response load() {
+ Card card = new LinkAccountCard();
+ Response response = buildTextResponse(LOAD_INTRO);
+ response.setCard(card);
+ return response;
+ }
+
+ //===========================tools==================
+
+ private Response dealStartIntent(IntentRequest intentRequest) {
+ String trace = getSessionAttribute("trace");
+ if (trace != null && trace.length() > 2 && !StringUtils.endsWith(trace,File.separator)) {
+ String botId = trace.substring(2);
+ String enterName = "打开" + ScheduleServiceNew.getWorkNameByBotAccount(botId);
+ return dealDefaultIntent(intentRequest, customUserId(), enterName);
+ }
+ return new Response();
+ }
+
+ private CoHiPageData getDpl2Collect(String userId, int indexPage) {
+ UserBehaviorData behaviorData = DplbotServiceUtil.getRedisTemplate().opsForValue().get(userId);
+ if (behaviorData == null) {
+ return null;
+ }
+ Map userBotId2Collected = behaviorData.getUserBotId2Collected();
+ int bound = userBotId2Collected.size();
+ int start = (indexPage-1)*CO_HI_PAGE_SIZE;
+ if (start >= bound) {
+ if (bound == 0) {
+ return new CoHiPageData();
+ }
+ return null;
+ }
+ CoHiPageData pageData = new CoHiPageData();
+ pageData.setSideText(indexPage + "/" + (bound/CO_HI_PAGE_SIZE + (bound%CO_HI_PAGE_SIZE == 0 ? 0 : 1)));
+ pageData.setHeaderTitle("收藏夹");
+
+ TreeMap order = new TreeMap<>((o1, o2) -> (o1 < o2) ? 1 : ((o1.equals(o2)) ? 0 : -1));
+ for (Map.Entry entry: userBotId2Collected.entrySet()) {
+ order.put(entry.getValue(), entry.getKey());
+ }
+ int j = 0, end = start+CO_HI_PAGE_SIZE;
+ List dataList = new ArrayList<>(CO_HI_PAGE_SIZE);
+ for (Map.Entry entry: order.entrySet()) {
+ if (j == end) break;
+ if (j++ >= start) {
+ ProjectData productDetail = ScheduleServiceNew.getProjectByBotAccount(entry.getValue());
+ if (productDetail == null) continue;
+ SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
+ String lastTime = sdf.format(new java.sql.Date(entry.getKey()));
+ CoHiOnePageData onePageData = new CoHiOnePageData();
+ onePageData.setTime(lastTime);
+ onePageData.setId(Constants.PRE_ENTER_PRODUCT+productDetail.getName());
+ onePageData.setImageUrl(productDetail.getBannerImgUrl());
+ onePageData.setNum(j);
+ onePageData.setWorkIntro(StringUtils.isBlank(productDetail.getIntro()) ?
+ "作者太懒没写介绍" : productDetail.getIntro());
+ onePageData.setWorkName(productDetail.getName());
+ onePageData.setItemSeqId(j-start);
+ dataList.add(onePageData);
+ }
+ }
+ pageData.setContentList(dataList);
+ return pageData;
+ }
+
+ private CoHiPageData getDpl2History(String userId, int indexPage) {
+ UserBehaviorData behaviorData = DplbotServiceUtil.getRedisTemplate().opsForValue().get(userId);
+ if (behaviorData == null) {
+ return null;
+ } else {
+ try {
+ int bound = behaviorData.getUserBotId2History().size();
+ int start = (indexPage-1)*CO_HI_PAGE_SIZE;
+ if (start >= bound) {
+ if (bound == 0) {
+ return new CoHiPageData();
+ }
+ return null;
+ }
+ CoHiPageData pageData = new CoHiPageData();
+ pageData.setSideText(indexPage + "/" + (bound/CO_HI_PAGE_SIZE + (bound%CO_HI_PAGE_SIZE == 0 ? 0 : 1)));
+ pageData.setHeaderTitle("历史记录");
+
+ TreeMap order = new TreeMap<>((o1, o2) -> (o1 < o2) ? 1 : ((o1.equals(o2)) ? 0 : -1));
+ for (Map.Entry entry: behaviorData.getUserBotId2History().entrySet()) {
+ order.put(entry.getValue(), entry.getKey());
+ }
+ int j = 0, end = start+CO_HI_PAGE_SIZE;
+ List dataList = new ArrayList<>(CO_HI_PAGE_SIZE);
+ for (Map.Entry entry: order.entrySet()) {
+ if (j == end) break;
+ if (j++ >= start) {
+ ProjectData productDetail = ScheduleServiceNew.getProjectByBotAccount(entry.getValue());
+ if (productDetail == null) continue;
+ SimpleDateFormat sdf = new SimpleDateFormat("MM-dd HH:mm");
+ String lastTime = sdf.format(new java.sql.Date(entry.getKey()));
+ CoHiOnePageData onePageData = new CoHiOnePageData();
+ onePageData.setTime(lastTime);
+ onePageData.setId(Constants.PRE_ENTER_PRODUCT+productDetail.getName());
+ onePageData.setImageUrl(productDetail.getBannerImgUrl());
+ onePageData.setNum(j);
+ onePageData.setWorkIntro(StringUtils.isBlank(productDetail.getIntro()) ?
+ "作者太懒没写介绍" : productDetail.getIntro());
+ onePageData.setWorkName(productDetail.getName());
+ onePageData.setItemSeqId(j-start);
+ dataList.add(onePageData);
+ }
+ }
+ pageData.setContentList(dataList);
+ return pageData;
+ } catch (Exception e) {
+ log.error("getDpl2History:"+e);
+ }
+ }
+ return null;
+ }
+
+ private boolean isNoScreenRequest() {
+ return getSupportedInterfaces().getDisplay() == null;
+ }
+
+ private String dealAudioUrl(String path, String botAccount) {
+ if (path.startsWith("a")) {
+ return new StringBuilder(ScheduleServiceNew.CDN_HOST_URL).append("/api/audio/cache/").append(botAccount).append("/?filename=").append(path.substring(1)).append("&exist=1").toString();
+ }
+ return new StringBuilder(ScheduleServiceNew.CDN_HOST_URL).append("/api/audio/cache/").append(botAccount).append("/?filename=").append(path).toString();
+ }
+
+ private String customUserId() {
+ if (customUserId == null) {
+ try {
+ customUserId = PREFIX_USERID+ URLEncoder.encode(getUserId(), "UTF-8");
+ } catch (Exception e) {
+ log.error("xiaodu userid encode error:{}, {}",e, getUserId());
+ customUserId = PREFIX_USERID+ getUserId().replaceAll("/", "");
+ }
+ }
+ return customUserId;
+ }
+
+ private List rowColumn4Recur(List botData, int startInc) {
+ HomePageData pageData;
+ ProjectData item;
+ int endExc = startInc+16;
+ List data = new ArrayList<>(4);
+ int row = 0;
+ while (startInc < endExc) {
+ pageData = new HomePageData();
+ for (int j = 1; j < 5; startInc++,j++) {
+ item = botData.get(startInc%botData.size());
+ if (j == 1) {
+ pageData.setImageId1(Constants.PRE_PRODUCT_IMG + item.getName());
+ pageData.setImageName1(item.getName());
+ pageData.setImg1(item.getBannerImgUrl());
+ pageData.setNum1(j+row*4);
+ } else if (j == 2) {
+ pageData.setImageId2(Constants.PRE_PRODUCT_IMG + item.getName());
+ pageData.setImageName2(item.getName());
+ pageData.setImg2(item.getBannerImgUrl());
+ pageData.setNum2(j+row*4);
+ } else if (j == 3) {
+ pageData.setImageId3(Constants.PRE_PRODUCT_IMG + item.getName());
+ pageData.setImageName3(item.getName());
+ pageData.setImg3(item.getBannerImgUrl());
+ pageData.setNum3(j+row*4);
+ } else {
+ pageData.setImageId4(Constants.PRE_PRODUCT_IMG + item.getName());
+ pageData.setImageName4(item.getName());
+ pageData.setImg4(item.getBannerImgUrl());
+ pageData.setNum4(j+row*4);
+ }
+ }
+ pageData.setItemSeqId(++row);
+ data.add(pageData);
+ }
+ return data;
+ }
+
+ // 从botData列表startInc开始到endExc结束,一行有4个,一共row行
+ private List rowColumn4(List botData, int startInc, int row) {
+ int onceEndExc;
+ HomePageData pageData;
+ ProjectData item;
+ int endExc = startInc+row*4 >= botData.size() ? botData.size() : startInc+row*4;
+ List data = new ArrayList<>(row);
+ int curItemIndex = 0;
+ while (startInc < endExc) {
+ onceEndExc = startInc + 4 >= endExc ? endExc : startInc + 4;
+ pageData = new HomePageData();
+ for (int j = 1; startInc < onceEndExc; startInc++,j++) {
+ item = botData.get(startInc);
+ if (j == 1) {
+ pageData.setImageId1(Constants.PRE_PRODUCT_IMG + item.getName());
+ pageData.setImageName1(item.getName());
+ pageData.setImg1(item.getBannerImgUrl());
+ pageData.setNum1(startInc+1);
+ } else if (j == 2) {
+ pageData.setImageId2(Constants.PRE_PRODUCT_IMG + item.getName());
+ pageData.setImageName2(item.getName());
+ pageData.setImg2(item.getBannerImgUrl());
+ pageData.setNum2(startInc+1);
+ } else if (j == 3) {
+ pageData.setImageId3(Constants.PRE_PRODUCT_IMG + item.getName());
+ pageData.setImageName3(item.getName());
+ pageData.setImg3(item.getBannerImgUrl());
+ pageData.setNum3(startInc+1);
+ } else {
+ pageData.setImageId4(Constants.PRE_PRODUCT_IMG + item.getName());
+ pageData.setImageName4(item.getName());
+ pageData.setImg4(item.getBannerImgUrl());
+ pageData.setNum4(startInc+1);
+ }
+ }
+ pageData.setItemSeqId(++curItemIndex);
+ data.add(pageData);
+ }
+ return data;
+ }
+
+ private Response buildTextResponse(String text) {
+ OutputSpeech outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, text);
+ return new Response(outputSpeech);
+ }
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/CentralResponseVO.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/CentralResponseVO.java
new file mode 100644
index 0000000..d42604e
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/CentralResponseVO.java
@@ -0,0 +1,25 @@
+package ai.qiwu.com.xiaoduhome.dpl2.model;
+
+import ai.qiwu.com.xiaoduhome.pojo.DialogData;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * painter
+ * 20-8-29 下午3:17
+ */
+@Getter
+@Setter
+@JsonIgnoreProperties(ignoreUnknown = true)
+@NoArgsConstructor
+public class CentralResponseVO {
+ private String botStatus;
+ private String aipioneerUsername;
+ private String plotImgUrl;
+ private List dialogs;
+ private List commands;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/CoHiOnePageData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/CoHiOnePageData.java
new file mode 100644
index 0000000..67f9ab3
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/CoHiOnePageData.java
@@ -0,0 +1,22 @@
+package ai.qiwu.com.xiaoduhome.dpl2.model;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * painter
+ * 20-8-27 下午5:21
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+public class CoHiOnePageData {
+ private String id;
+ private Integer num;
+ private String imageUrl;
+ private String workName;
+ private String workIntro;
+ private String time;
+ private Integer itemSeqId;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/CoHiPageData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/CoHiPageData.java
new file mode 100644
index 0000000..6d4b872
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/CoHiPageData.java
@@ -0,0 +1,20 @@
+package ai.qiwu.com.xiaoduhome.dpl2.model;
+
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * painter
+ * 20-8-27 下午5:20
+ */
+@Getter
+@Setter
+@NoArgsConstructor
+public class CoHiPageData {
+ private String sideText;
+ private String headerTitle;
+ private List contentList;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/HomePageData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/HomePageData.java
new file mode 100644
index 0000000..bcc9cb7
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/HomePageData.java
@@ -0,0 +1,34 @@
+package ai.qiwu.com.xiaoduhome.dpl2.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * painter
+ * 20-8-25 下午6:54
+ */
+@Getter
+@Setter
+public class HomePageData {
+ private Integer itemSeqId;
+
+ private Integer num1;
+ private String imageId1;
+ private String imageName1;
+ private String img1;
+
+ private Integer num2 = 0;
+ private String imageId2 = "";
+ private String imageName2 = "";
+ private String img2 = "";
+
+ private Integer num3 = 0;
+ private String imageId3 = "";
+ private String imageName3 = "";
+ private String img3 = "";
+
+ private Integer num4 = 0;
+ private String imageId4 = "";
+ private String imageName4 = "";
+ private String img4 = "";
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/ProjectClickData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/ProjectClickData.java
new file mode 100644
index 0000000..ae6abce
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/ProjectClickData.java
@@ -0,0 +1,17 @@
+package ai.qiwu.com.xiaoduhome.dpl2.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * painter
+ * 20-8-27 下午3:39
+ */
+@Getter
+@Setter
+public class ProjectClickData {
+ private Integer num1;
+ private String imageId1;
+ private String imageName1;
+ private String img1;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/ProjectDetailData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/ProjectDetailData.java
new file mode 100644
index 0000000..82a5382
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/dpl2/model/ProjectDetailData.java
@@ -0,0 +1,27 @@
+package ai.qiwu.com.xiaoduhome.dpl2.model;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * painter
+ * 20-8-27 下午8:31
+ */
+@Getter
+@Setter
+public class ProjectDetailData {
+ private String imgUrl;
+ private String workName;
+ private String time;
+ private String label;
+ private String author;
+ private String intro;
+ private String id;
+ private String flowerId;
+// private String collectId;
+// private String collectImg;
+// private String collectText;
+ private Boolean collect;
+ private Boolean login;
+ private String flowText;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/GameProjectTb.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/GameProjectTb.java
deleted file mode 100755
index 5116496..0000000
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/GameProjectTb.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package ai.qiwu.com.xiaoduhome.entity.primary;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-import org.springframework.data.jpa.domain.support.AuditingEntityListener;
-
-import javax.persistence.*;
-import java.util.Date;
-
-/**
- * @author 苗权威
- * @dateTime 19-8-14 下午8:29
- */
-@Entity
-@Table(name = "game_project_tb")
-@Getter
-@Setter
-@ToString
-public class GameProjectTb {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- @Column
- private String intro;
-
- @Column
- private String name;
-
- @Column
- private Long watch;
-
-// @Column(name = "work_type")
-// private Long workType;
-
- @Column(name = "banner_img_url")
- private String bannerImgUrl;
-
- @Column(name = "apply_status")
- private Integer applyStatus;
-
- @Column(name = "bot_account")
- private String botAccount;
-
- @Column(name = "user_nickname")
- private String authorName;
-
- @Column
- private Float score;
-}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/OnProductDetail.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/OnProductDetail.java
deleted file mode 100755
index 3894308..0000000
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/OnProductDetail.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package ai.qiwu.com.xiaoduhome.entity.primary;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-import javax.persistence.*;
-import java.sql.Timestamp;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author 苗权威
- * @dateTime 19-8-16 下午6:26
- */
-@Entity
-@Table(name = "game_project_tb")
-@Getter
-@Setter
-@ToString
-public class OnProductDetail {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- @Column
- private String intro;
-
- @Column
- private String name;
-
- @Column
- private Long watch;
-
- @Column
- private Float score;
-
- @Column(name = "work_type")
- private Long workType;
-
- @Column(name = "banner_img_url")
- private String bannerImgUrl;
-
- @Column(name = "apply_status")
- private Integer applyStatus;
-
- @Column(name = "user_nickname")
- private String authorName;
-
- @Column(name = "bot_account")
- private String botAccount;
-
- @Column(name = "gmt_create")
- private Timestamp createTime;
-
- @Transient
- private List labels;
-}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/ProjectLabel.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/ProjectLabel.java
deleted file mode 100755
index a8733f4..0000000
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/ProjectLabel.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package ai.qiwu.com.xiaoduhome.entity.primary;
-
-import lombok.Getter;
-import lombok.Setter;
-import lombok.ToString;
-
-import javax.persistence.*;
-
-/**
- * @author 苗权威
- * @dateTime 19-8-15 下午3:55
- */
-@Entity
-@Table(name = "game_project_label_tb")
-@Getter
-@Setter
-@ToString
-public class ProjectLabel {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private Long id;
-
- @Column
- private String name;
-
- @Column(name = "project_id")
- private Long productId;
-}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuCollectTB.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuCollectTB.java
index c2ca11c..7830667 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuCollectTB.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuCollectTB.java
@@ -2,6 +2,7 @@ package ai.qiwu.com.xiaoduhome.entity.secondary;
import lombok.Getter;
import lombok.Setter;
+import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@@ -14,6 +15,7 @@ import java.sql.Timestamp;
@Entity
@Table(name = "xiaodu_collect_tb")
@EntityListeners(AuditingEntityListener.class)
+@DynamicUpdate
public class XiaoDuCollectTB {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryTB.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryTB.java
index 602f5f7..1e47826 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryTB.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuHistoryTB.java
@@ -3,6 +3,7 @@ package ai.qiwu.com.xiaoduhome.entity.secondary;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
+import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@@ -20,6 +21,7 @@ import java.util.Date;
@Entity
@Table(name = "xiaodu_history_tb")
@EntityListeners(AuditingEntityListener.class)
+@DynamicUpdate
public class XiaoDuHistoryTB {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuOrderTB.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuOrderTB.java
index a2ebb20..f6b2e28 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuOrderTB.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/secondary/XiaoDuOrderTB.java
@@ -2,6 +2,7 @@ package ai.qiwu.com.xiaoduhome.entity.secondary;
import lombok.Getter;
import lombok.Setter;
+import org.hibernate.annotations.DynamicUpdate;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@@ -19,6 +20,7 @@ import java.util.Date;
@EntityListeners(AuditingEntityListener.class)
@Getter
@Setter
+@DynamicUpdate
public class XiaoDuOrderTB {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/ActorWithWord.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/ActorWithWord.java
index 6333edf..5be3f72 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/ActorWithWord.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/ActorWithWord.java
@@ -1,5 +1,6 @@
package ai.qiwu.com.xiaoduhome.pojo;
+import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@@ -11,7 +12,10 @@ import lombok.ToString;
@Getter
@Setter
@ToString
+@JsonInclude(JsonInclude.Include.NON_NULL)
public class ActorWithWord {
private String actor;
+ private String asideImg;
private String text;
+ private Integer itemSeqId;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java
index 912d3b8..2adb434 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/UserBehaviorData.java
@@ -23,9 +23,9 @@ public class UserBehaviorData {
// 用户是否收藏该作品
private volatile Map userBotId2Collected = new HashMap<>();
// 标记清除,每半小时标记一次
- private volatile Integer mark = 1;
+// private volatile Integer mark = 1;
private volatile String jytUserId;
- private volatile String channel;
+// private volatile String channel;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ProjectData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ProjectData.java
index 07f4b7a..ef7e5a2 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ProjectData.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/pojo/data/ProjectData.java
@@ -18,6 +18,7 @@ import java.util.List;
@EqualsAndHashCode
public class ProjectData {
private String name;
+ private String showedWorkName;
private String intro;
private String authorName;
private Boolean free;
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AllOnProductInfoRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AllOnProductInfoRepository.java
deleted file mode 100755
index 2ff2f29..0000000
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AllOnProductInfoRepository.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package ai.qiwu.com.xiaoduhome.repository.primary;
-
-import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-
-/**
- * @author 苗权威
- * @dateTime 19-8-16 下午6:26
- */
-@Repository
-public interface AllOnProductInfoRepository extends JpaRepository {
-
- List findAllByApplyStatusAndScoreNot(Integer applyStatus, Float score);
-
- List findAllByApplyStatusAndWorkType(Integer applyStatus, Long workType);
-
- @Query(value = "select name from game_project_tb where apply_status=1 and work_type=27",nativeQuery = true)
- List findNameByApplyStatusAndWorkType(Integer applyStatus, Long workType);
-}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java
deleted file mode 100755
index d1a6273..0000000
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/GameProjectTbRepository.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package ai.qiwu.com.xiaoduhome.repository.primary;
-
-import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.query.Param;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-
-/**
- * @author 苗权威
- * @dateTime 19-8-14 下午9:05
- */
-@Repository
-public interface GameProjectTbRepository extends JpaRepository {
-
- List findFirst8ByApplyStatusOrderByWatchDesc(Integer applyStatus);
-
- @Query(value = "select * from game_project_tb where apply_status=1 and score != 0 order by watch desc limit 8", nativeQuery = true)
- List findFirst8();
-
- @Query(value = "select id,intro,name,watch,banner_img_url,apply_status,bot_account,user_nickname,score from game_project_tb where apply_status = 1 and score != 0 and id >= (select floor(RAND()*(select MAX(id) from game_project_tb))) order by id limit 8", nativeQuery = true)
- List recommendList();
-
- @Query(value = "select p.bot_account from game_project_tb as p,game_project_label_tb as l where l.name=?1 and p.apply_status=1 and p.id = l.project_id",nativeQuery = true)
- List categoryProList(String category);
-
- @Query(value = "select id,intro,name,watch,banner_img_url,apply_status,bot_account,user_nickname,score from game_project_tb where apply_status = 1 order by watch desc limit ?1,8", nativeQuery = true)
- List postRankBot(Integer begin);
-
- @Query(value = "select bot_account from game_project_tb where apply_status=1 and work_type=27",nativeQuery = true)
- List getAllOnTableProductIds();
-}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/ProjectLabelRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/ProjectLabelRepository.java
deleted file mode 100755
index 69ffa1d..0000000
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/ProjectLabelRepository.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package ai.qiwu.com.xiaoduhome.repository.primary;
-
-import ai.qiwu.com.xiaoduhome.entity.primary.ProjectLabel;
-import org.springframework.data.jpa.repository.JpaRepository;
-import org.springframework.data.jpa.repository.Query;
-import org.springframework.data.repository.query.Param;
-import org.springframework.stereotype.Repository;
-
-import java.util.List;
-
-/**
- * @author 苗权威
- * @dateTime 19-8-15 下午4:03
- */
-@Repository
-public interface ProjectLabelRepository extends JpaRepository {
-
- @Query(value = "SELECT name FROM game_project_label_tb WHERE project_id = :productId", nativeQuery = true)
- List productLabels(@Param("productId") Long productId);
-}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java
index ac91f8e..3cc7c3e 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotServiceBoth.java
@@ -71,10 +71,9 @@ import static ai.qiwu.com.xiaoduhome.common.Constants.ErrorMsg.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.PRODUCT_INTRO.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.WelcomeWord.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.BEARER;
-import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.FLOWER_INTERFACE;
+import static ai.qiwu.com.xiaoduhome.controller.XiaoDuHomeController.*;
import static ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil.POOL;
import static ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil.USER_HISTORY;
-import static ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew.curTime;
/**
* @author mqw
@@ -262,7 +261,7 @@ public class DplBotServiceBoth extends BaseBot {
if (data.equals("out")) {
String idleNum = stringRedisTemplate.opsForValue().get(redisIdleId);
boolean firstIdle;
- if ((firstIdle = StringUtils.isBlank(idleNum)) || idleNum.equals("1")) {
+ if ((firstIdle = StringUtils.isBlank(idleNum)) || "1".equals(idleNum)) {
try {
Thread.sleep(2000);
} catch (Exception e){}
@@ -394,12 +393,12 @@ public class DplBotServiceBoth extends BaseBot {
DplbotServiceUtil.updateTheUserBehaviorDataMark(userId, botAccount, getAccessToken(), getSessionAttribute("userId"), channelId);
String productName = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
if (StringUtils.isBlank(productName)) productName = "交游天下";
- PlayDocument document = PlayUtils.getPlayDocument(productName, DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs")),
+ PlayDocument document = PlayUtils.getPlayDocument(productName, DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs"), botAccount),
dealAudioUrl(path), botAccount);
RenderDocument render = new RenderDocument(document);
addDirective(render);
- DplbotServiceUtil.updateTheUserHistory(userId, botAccount, getAccessToken(), channelId);
+ DplbotServiceUtil.updateTheUserHistory(userId, botAccount, getAccessToken(), channelId, null);
String trace = getSessionAttribute(BACK_TRACE);
if (trace == null || trace.length() != 2) trace = "00";
trace = new StringBuilder(trace).append(botAccount).append(File.separator).toString();
@@ -409,7 +408,7 @@ public class DplBotServiceBoth extends BaseBot {
String productName = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
if (StringUtils.isBlank(productName)) productName = "交游天下";
PlayDocument document = PlayUtils.getPlayDocument(productName,
- DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs")), dealAudioUrl(path), botAccount);
+ DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs"), botAccount), dealAudioUrl(path), botAccount);
RenderDocument render = new RenderDocument(document);
addDirective(render);
@@ -577,73 +576,73 @@ public class DplBotServiceBoth extends BaseBot {
return new StringBuilder(cdnUrl).append("/api/audio/cache/").append(botAccount).append("/?filename=").append(path).toString();
}
- private Response dealNoScreenSendFlowerIntent(String userId, String channelId) {
- if (getAccessToken() == null) {
- return buildErrorResponse("该功能需要登录");
- }
- String num = getSlot("sys.number");
- OutputSpeech outputSpeech;
- String confirmationStatus = getIntent().getConfirmationStatus().name();
- log.info("槽位确认状态:{}",confirmationStatus);
- if ("NONE".equals(confirmationStatus)) {
- if (num == null) {
- log.info("确认送花个数");
- ask("sys.number");
- outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "请问您要送几朵花");
- setExpectSpeech(true);
- } else {
- log.info("确认最终送花意图");
- setConfirmIntent();
- outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText,
- new StringBuilder("您要送").append(num).append("朵花是吗").toString());
- setExpectSpeech(true);
- }
- return new Response(outputSpeech);
- } else if ("CONFIRMED".equals(confirmationStatus)) {
- log.info("确认");
- int unitPrice = Integer.parseInt(ScheduleServiceNew.FLOWER_UNIT_PRICE);
- String amount = String.valueOf(unitPrice*Integer.parseInt(num)/100.0);
- String orderId = userId + System.currentTimeMillis();
- String appUserId = getSessionAttribute("userId");
- if (appUserId == null) {
- appUserId = DplbotServiceUtil.getUsUserId(userId,getAccessToken(), channelId);
- if (appUserId == null) {
- log.error("送花时获取用户app_user_id失败");
- return buildErrorResponse("不好意思出了点问题,请再说一遍吧");
- }
- }
- String botId = getSessionAttribute("botAcc");
- if (StringUtils.isNotBlank(botId)) {
- XiaoDuOrderTbRepository repository = BaseHolder.getBean("xiaoDuOrderTbRepository");
- XiaoDuOrderTB tb= buildNoScreenBeforePayPojo(botId, appUserId, userId, unitPrice, Integer.parseInt(num), orderId);
- if (tb == null) {
- log.warn("buildNoScreenBeforePayPojo return null");
- return new Response();
- }
- XiaoDuOrderTB response = repository.save(tb);
-
- if (response.getId() != null) {
- String desc = new StringBuilder("感谢您赏赐给该作品的").append(num).append("朵鲜花").toString();
- String name = ScheduleService.PRODUCT_ID_DETAIL.get(botId).getName();
- if (name != null) desc = new StringBuilder("感谢您赏赐给").append(name)
- .append("的").append(num).append("朵鲜花").toString();
- Charge charge = new Charge(amount, orderId, num+"朵鲜花", desc);
- charge.setToken(new StringBuilder(botId).append(File.separator).append(num).toString());
- addDirective(charge);
- return buildErrorResponse("请到小度APP上完成支付");
- } else {
- log.error("订单没有插入到xioadu_order_tb");
- return buildErrorResponse(ERROR_SEND_FLOWER);
- }
- }else {
- log.error("无法获取到botID");
- return buildErrorResponse("只能在作品里才可以送花");
- }
- } else {
- log.info("否定");
- return buildErrorResponse("好的,已为您终止");
- }
- }
+// private Response dealNoScreenSendFlowerIntent(String userId, String channelId) {
+// if (getAccessToken() == null) {
+// return buildErrorResponse("该功能需要登录");
+// }
+// String num = getSlot("sys.number");
+// OutputSpeech outputSpeech;
+// String confirmationStatus = getIntent().getConfirmationStatus().name();
+// log.info("槽位确认状态:{}",confirmationStatus);
+// if ("NONE".equals(confirmationStatus)) {
+// if (num == null) {
+// log.info("确认送花个数");
+// ask("sys.number");
+// outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "请问您要送几朵花");
+// setExpectSpeech(true);
+// } else {
+// log.info("确认最终送花意图");
+// setConfirmIntent();
+// outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText,
+// new StringBuilder("您要送").append(num).append("朵花是吗").toString());
+// setExpectSpeech(true);
+// }
+// return new Response(outputSpeech);
+// } else if ("CONFIRMED".equals(confirmationStatus)) {
+// log.info("确认");
+// int unitPrice = Integer.parseInt(ScheduleServiceNew.FLOWER_UNIT_PRICE);
+// String amount = String.valueOf(unitPrice*Integer.parseInt(num)/100.0);
+// String orderId = userId + System.currentTimeMillis();
+// String appUserId = getSessionAttribute("userId");
+// if (appUserId == null) {
+// appUserId = DplbotServiceUtil.getUsUserId(userId,getAccessToken(), channelId);
+// if (appUserId == null) {
+// log.error("送花时获取用户app_user_id失败");
+// return buildErrorResponse("不好意思出了点问题,请再说一遍吧");
+// }
+// }
+// String botId = getSessionAttribute("botAcc");
+// if (StringUtils.isNotBlank(botId)) {
+// XiaoDuOrderTbRepository repository = BaseHolder.getBean("xiaoDuOrderTbRepository");
+// XiaoDuOrderTB tb= buildNoScreenBeforePayPojo(botId, appUserId, userId, unitPrice, Integer.parseInt(num), orderId);
+// if (tb == null) {
+// log.warn("buildNoScreenBeforePayPojo return null");
+// return new Response();
+// }
+// XiaoDuOrderTB response = repository.save(tb);
+//
+// if (response.getId() != null) {
+// String desc = new StringBuilder("感谢您赏赐给该作品的").append(num).append("朵鲜花").toString();
+// String name = ScheduleService.PRODUCT_ID_DETAIL.get(botId).getName();
+// if (name != null) desc = new StringBuilder("感谢您赏赐给").append(name)
+// .append("的").append(num).append("朵鲜花").toString();
+// Charge charge = new Charge(amount, orderId, num+"朵鲜花", desc);
+// charge.setToken(new StringBuilder(botId).append(File.separator).append(num).toString());
+// addDirective(charge);
+// return buildErrorResponse("请到小度APP上完成支付");
+// } else {
+// log.error("订单没有插入到xioadu_order_tb");
+// return buildErrorResponse(ERROR_SEND_FLOWER);
+// }
+// }else {
+// log.error("无法获取到botID");
+// return buildErrorResponse("只能在作品里才可以送花");
+// }
+// } else {
+// log.info("否定");
+// return buildErrorResponse("好的,已为您终止");
+// }
+// }
private Play buildNoScreenPlayDirec(String audioUrl, AudioPlayerDirective.PlayBehaviorType type) {
return new Play(type, audioUrl, 0);
@@ -690,7 +689,8 @@ public class DplBotServiceBoth extends BaseBot {
log.error("小度没有获取到音频链接");
return buildErrorResponse(ErrorMsg.SORRY_UNCATCH);
}
- PlayDocument document = PlayUtils.getPlayDocument(productName, DplbotServiceUtil.getTheActorsWithWords(JSON.parseObject(data).getJSONArray("dialogs")),
+ PlayDocument document = PlayUtils.getPlayDocument(productName,
+ DplbotServiceUtil.getTheActorsWithWords(JSON.parseObject(data).getJSONArray("dialogs"), botID),
dealAudioUrl(path), botID);
RenderDocument render = new RenderDocument(document);
this.setSessionAttribute(PRE_COLLE, null);
@@ -851,7 +851,7 @@ public class DplBotServiceBoth extends BaseBot {
}
String botID = ScheduleServiceNew.getBotAccountByWorkname(productName);
PlayDocument document = PlayUtils.getPlayDocument(productName,
- DplbotServiceUtil.getTheActorsWithWords(JSON.parseObject(data).getJSONArray("dialogs")),
+ DplbotServiceUtil.getTheActorsWithWords(JSON.parseObject(data).getJSONArray("dialogs"), botID),
dealAudioUrl(path), botID);
RenderDocument render = new RenderDocument(document);
@@ -881,10 +881,11 @@ public class DplBotServiceBoth extends BaseBot {
}
} else if ("loadingPage".equals(componentId)) {
RenderDocument renderDocument = new RenderDocument(LunchUtils.getLunchDocument());
-// this.addDirective(new PushStack());
addDirective(renderDocument);
-// addDirective(new SendPart("lunch"));
return new Response();
+
+// this.addDirective(new PushStack());
+// addDirective(new SendPart("lunch"));
} else if (PRE_COLLE.equals(componentPrefix)) {
boolean isUnCollect = "Un".equals(componentId.substring(5,7));
final String botId = componentId.substring(7);
@@ -1089,47 +1090,47 @@ public class DplBotServiceBoth extends BaseBot {
return response;
}
- private Integer getUserSendFlowerNum(String productId, String accessToken) {
- HashMap params = new HashMap<>();
- params.put("module", "works");
- params.put("aipioneerUsername", productId);
- HashMap headers = new HashMap<>();
- headers.put("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
- headers.put("Authorization", new StringBuilder(BEARER).append(accessToken).toString());
- CodeMsgData response;
- try {
- String flowerRes = OkHttp3Utils.doGet(FLOWER_INTERFACE, params, headers);
- response = JSON.parseObject(flowerRes, CodeMsgData.class);
- } catch (IOException e) {
- log.error("请求用户送花数出错");
- return null;
- }
- log.info("调用获取用户送花数接口结果:{}", response);
- if (response == null || response.getCode() != 1) return null;
- return response.getData().getCount();
- }
+// private Integer getUserSendFlowerNum(String productId, String accessToken) {
+// HashMap params = new HashMap<>();
+// params.put("module", "works");
+// params.put("aipioneerUsername", productId);
+// HashMap headers = new HashMap<>();
+// headers.put("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
+// headers.put("Authorization", new StringBuilder(BEARER).append(accessToken).toString());
+// CodeMsgData response;
+// try {
+// String flowerRes = OkHttp3Utils.doGet(FLOWER_INTERFACE, params, headers);
+// response = JSON.parseObject(flowerRes, CodeMsgData.class);
+// } catch (IOException e) {
+// log.error("请求用户送花数出错");
+// return null;
+// }
+// log.info("调用获取用户送花数接口结果:{}", response);
+// if (response == null || response.getCode() != 1) return null;
+// return response.getData().getCount();
+// }
- private List getUserProductList(String accessToken) {
- HashMap params = new HashMap<>();
- params.put("module", "works");
- HashMap headers = new HashMap<>();
- headers.put("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
- headers.put("Authorization", new StringBuilder(BEARER).append(accessToken).toString());
- UserCollecResult result;
- try {
- String resStr = OkHttp3Utils.doGet(XIAOWU_API.USER_CLOOEC_LIST, params, headers);
- result = JSON.parseObject(resStr, UserCollecResult.class);
- } catch (Exception e) {
- log.error("调用获取用户收藏作品列表接口出错:{}", e.toString());
- return null;
- }
- if (result.getCode() == 1) return result.getData();
- else {
- log.error("获取用户收藏作品列表出错,错误码:{}, 错误信息:{}", result.getCode(), result.getMsg());
- return null;
- }
- }
+// private List getUserProductList(String accessToken) {
+// HashMap params = new HashMap<>();
+// params.put("module", "works");
+// HashMap headers = new HashMap<>();
+// headers.put("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
+// headers.put("Authorization", new StringBuilder(BEARER).append(accessToken).toString());
+// UserCollecResult result;
+// try {
+// String resStr = OkHttp3Utils.doGet(XIAOWU_API.USER_CLOOEC_LIST, params, headers);
+// result = JSON.parseObject(resStr, UserCollecResult.class);
+// } catch (Exception e) {
+// log.error("调用获取用户收藏作品列表接口出错:{}", e.toString());
+// return null;
+// }
+// if (result.getCode() == 1) return result.getData();
+// else {
+// log.error("获取用户收藏作品列表出错,错误码:{}, 错误信息:{}", result.getCode(), result.getMsg());
+// return null;
+// }
+// }
private static String correctName(String name) {
int brace = name.indexOf("{");
@@ -1286,7 +1287,7 @@ public class DplBotServiceBoth extends BaseBot {
if (trace == null || trace.length() < 2) {
return buildErrorResponse("小悟跳不动了");
}
- int index = extractNum(numStr);
+ int index = DplbotServiceUtil.extractNum(numStr);
char pageSign = trace.charAt(1);
Response response;
switch (pageSign) {
@@ -1378,7 +1379,7 @@ public class DplBotServiceBoth extends BaseBot {
if (getAccessToken() == null) {
return buildErrorResponse("该功能需要登录,请说小度小度,登录");
}
- int num = extractNum(numStr);
+ int num = DplbotServiceUtil.extractNum(numStr);
int unitPrice = Integer.parseInt(ScheduleServiceNew.FLOWER_UNIT_PRICE);
String amount = String.valueOf(unitPrice*num/100.0);
String orderId = userId +"_"+ System.currentTimeMillis();
@@ -1765,7 +1766,7 @@ public class DplBotServiceBoth extends BaseBot {
private Response dealOpenNumIntent(String numStr, String channelId) {
String trace = getSessionAttribute("trace");
- int num = extractNum(numStr);
+ int num = DplbotServiceUtil.extractNum(numStr);
log.info("dealOpenNumIntent num:"+num);
if (trace == null || trace.charAt(1) == '0') {
return dealOpenNumInHome(num);
@@ -1794,28 +1795,6 @@ public class DplBotServiceBoth extends BaseBot {
return str.replaceAll("[ \uD83C\uDD70\uD83C\uDD71]", "");
}
- private Integer extractNum(String numStr) {
- numStr = numStr.replaceAll("[ \uD83C\uDD70\uD83C\uDD71]", "");
- int num;
- try {
- num = Integer.parseInt(numStr);
- return num;
- } catch (Exception e) {
- int i;
- if ((i=numStr.indexOf("第")) != -1) {
- String str = numStr.substring(i+1, numStr.length()-1);
- try {
- num = Integer.parseInt(str);
- } catch (Exception e1) {
- num = Utils.changeHanToNum(str);
- }
- } else {
- num = Utils.changeHanToNum(numStr);
- }
- }
- return num;
- }
-
private Response dealOpenCollectIntent(String channelId) {
if (getAccessToken() == null) {
return buildErrorResponse("该功能需要登录,请说小度小度,登录");
@@ -2155,12 +2134,12 @@ public class DplBotServiceBoth extends BaseBot {
DplbotServiceUtil.updateTheUserBehaviorDataMark(userId, botAccount, getAccessToken(), getSessionAttribute("userId"), channelId);
String productName = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
if (StringUtils.isBlank(productName)) productName = "交游天下";
- PlayDocument document = PlayUtils.getPlayDocument(productName, DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs")),
+ PlayDocument document = PlayUtils.getPlayDocument(productName, DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs"), botAccount),
dealAudioUrl(path), botAccount);
RenderDocument render = new RenderDocument(document);
addDirective(render);
- DplbotServiceUtil.updateTheUserHistory(userId, botAccount, getAccessToken(), channelId);
+ DplbotServiceUtil.updateTheUserHistory(userId, botAccount, getAccessToken(), channelId, null);
String trace = getSessionAttribute(BACK_TRACE);
if (trace == null || trace.length() != 2) trace = "00";
trace = new StringBuilder(trace).append(botAccount).append(File.separator).toString();
@@ -2207,7 +2186,7 @@ public class DplBotServiceBoth extends BaseBot {
// ScheduleService.getAsideImgUrl(botAccount, aside),
// data.getAudio(), text);
PlayDocument document = PlayUtils.getPlayDocument(productName,
- DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs")), dealAudioUrl(path), botAccount);
+ DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs"), botAccount), dealAudioUrl(path), botAccount);
RenderDocument render = new RenderDocument(document);
addDirective(render);
@@ -2531,13 +2510,13 @@ public class DplBotServiceBoth extends BaseBot {
}
private Response dealOpenNumCategory(int num) {
- if (num > ScheduleServiceNew.CATEGORY.length) return buildErrorResponse(num+"超出了范围");
- RecommandDocument document = RecommendUtil.getCategory(0, ScheduleServiceNew.CATEGORY[num-1]);
+ if (num > ScheduleServiceNew.CATEGORY.size()) return buildErrorResponse(num+"超出了范围");
+ RecommandDocument document = RecommendUtil.getCategory(0, ScheduleServiceNew.CATEGORY.get(num-1));
if (document == null) return new Response();
RenderDocument render = new RenderDocument(document);
addDirective(render);
setSessionAttribute(BACK_TRACE, "75");
- setSessionAttribute("category", ScheduleServiceNew.CATEGORY[num-1]);
+ setSessionAttribute("category", ScheduleServiceNew.CATEGORY.get(num-1));
return new Response();
}
@@ -2742,7 +2721,7 @@ public class DplBotServiceBoth extends BaseBot {
xiaoDuOrderTB.setIsBuy(false);
xiaoDuOrderTB.setStatus(false);
xiaoDuOrderTB.setChOrderId(orderId);
- xiaoDuOrderTB.setTimeStamp(curTime);
+ xiaoDuOrderTB.setTimeStamp(System.currentTimeMillis());
xiaoDuOrderTB.setChannelId(channel);
}
@@ -2872,7 +2851,7 @@ public class DplBotServiceBoth extends BaseBot {
JSONObject object = JSON.parseObject(data);
String botId = object.getString("aipioneerUsername");
PlayDocument document = PlayUtils.getPlayDocument(ScheduleServiceNew.getWorkNameByBotAccount(botId),
- DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs")), dealAudioUrl(path), botId);
+ DplbotServiceUtil.getTheActorsWithWords(object.getJSONArray("dialogs"), botId), dealAudioUrl(path), botId);
RenderDocument render = new RenderDocument(document);
this.setSessionAttribute(PRE_COLLE, null);
String trace = getSessionAttribute(BACK_TRACE);
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java
index 2435719..a768795 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplbotServiceUtil.java
@@ -4,51 +4,49 @@ import ai.qiwu.com.xiaoduhome.common.*;
import ai.qiwu.com.xiaoduhome.common.temple.CollectHistoryDocument;
import ai.qiwu.com.xiaoduhome.common.temple.CollectHistoryUtils;
import ai.qiwu.com.xiaoduhome.entity.primary.AppFavoriteTB;
-import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuCollectTB;
import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryBotIdTime;
import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryTB;
import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuOrderTB;
import ai.qiwu.com.xiaoduhome.pojo.*;
import ai.qiwu.com.xiaoduhome.pojo.data.ProjectData;
-import ai.qiwu.com.xiaoduhome.pojo.data.UpdateUserCollectData;
import ai.qiwu.com.xiaoduhome.pojo.pageData.HistoryData;
import ai.qiwu.com.xiaoduhome.repository.primary.AppFavoriteTBRepository;
-import ai.qiwu.com.xiaoduhome.repository.primary.AppFlowerTBTintRepository;
import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuCollectRepository;
import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryTBRepository;
import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuOrderTbRepository;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
-import com.alibaba.fastjson.TypeReference;
import com.baidu.dueros.data.request.pay.event.ChargeEvent;
import com.baidu.dueros.data.request.pay.event.Payload;
import com.baidu.dueros.data.response.directive.pay.Charge;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ArrayNode;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.apache.commons.lang3.math.NumberUtils;
+import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.util.CollectionUtils;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.net.URLEncoder;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import static ai.qiwu.com.xiaoduhome.common.Constants.CO_HI_PAGE_SIZE;
import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.*;
-import static ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew.curTime;
/**
* @author 苗权威
@@ -56,17 +54,10 @@ import static ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew.curTime;
*/
@Slf4j
public class DplbotServiceUtil {
- final static String HOST_UTL;
- private final static String HOST_UTL_TEMP;
- static {
- HOST_UTL = Config.getProperty("requestHost", "http://didi-gz5.jiaoyou365.com:18082/");
- HOST_UTL_TEMP = Config.getProperty("requestHostTemp", "https://didi-gz5.jiaoyou365.com/temp/");
- log.info("hostUrl:"+HOST_UTL);
- log.info("hostUrl:"+HOST_UTL_TEMP);
- }
+ private static RedisTemplate redisTemplate;
private static final int CORE = Runtime.getRuntime().availableProcessors();
- static final ThreadPoolExecutor POOL = new ThreadPoolExecutor(CORE+1, 1500,
+ public static final ThreadPoolExecutor POOL = new ThreadPoolExecutor(CORE+1, 1500,
3000, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<>(CORE), new ThreadPoolExecutor.CallerRunsPolicy());
static final ConcurrentHashMap USER_HISTORY = new ConcurrentHashMap<>();
@@ -85,20 +76,16 @@ public class DplbotServiceUtil {
}
}
- private static void getUserSendFlowerInfo(String userId, String jytUserId) {
- UserBehaviorData data = USER_HISTORY.computeIfAbsent(userId, s -> new UserBehaviorData());
- AppFlowerTBTintRepository repository = BaseHolder.getBean("appFlowerTBTintRepository");
- for (OnProductDetail detail: ScheduleService.getAllOnProduct()) {
- long sum = 0;
- List nums = repository.getFlowerNumByUserIdAndBotAccount(jytUserId, detail.getBotAccount());
- for (Long num: nums) sum += num;
- if (sum != 0) data.getUserBotId2Flowers().put(detail.getBotAccount(), sum);
+ public static RedisTemplate getRedisTemplate() {
+ if (redisTemplate == null) {
+ redisTemplate = BaseHolder.getBean("userBehaviorTemplate");
}
+ return redisTemplate;
}
- static String getUsUserId(String userId, String accessToken, String channelId) {
- log.info("getUsUserId: userid:{}, USER_HISTORY:{}",userId,USER_HISTORY);
- UserBehaviorData data = USER_HISTORY.get(userId);
+ public static String getUsUserId(String userId, String accessToken, String channelId) {
+ log.info("getUsUserId: userid:{}",userId);
+ UserBehaviorData data = getRedisTemplate().opsForValue().get(userId);
String jytId;
if (data == null) {
log.info("getUsUserId: data is null");
@@ -108,15 +95,16 @@ public class DplbotServiceUtil {
} else if (StringUtils.isBlank(data.getJytUserId())) {
jytId = getUserIdByToken(accessToken, channelId, userId);
data.setJytUserId(jytId);
+ getRedisTemplate().opsForValue().set(userId, data, 1, TimeUnit.HOURS);
}
return data.getJytUserId();
}
- static String getUserIdByToken(String accessToken, String channelId, String userId) {
+ public static String getUserIdByToken(String accessToken, String channelId, String userId) {
try {
HashMap headers = new HashMap<>();
- headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
- headers.put("Authorization", new StringBuilder(BEARER).append(accessToken).toString());
+ headers.put("App-Channel-Id", "xiaodu-speaker-api-test");
+ headers.put("Authorization", BEARER + accessToken);
String str = OkHttp3Utils.doGet(USER_ID_BY_TOKEN, new HashMap<>(), headers);
log.info("getUserIdByToken:{}",str);
UserInfoByTokenResult info = JSON.parseObject(str, UserInfoByTokenResult.class);
@@ -148,105 +136,105 @@ public class DplbotServiceUtil {
// });
// }
- static void onLunchFillUserBehaviorData(final String userId, final String channelId, final String jytUserId, final Boolean alreadyLoaded) {
+ public static void onLunchFillUserBehaviorData(final String userId, final String channelId, final String jytUserId, final Boolean alreadyLoaded) {
POOL.submit(() -> {
onLunchFillUserBehaviorDataInMaster(userId, channelId, jytUserId, alreadyLoaded);
});
}
- static UserBehaviorData onLunchFillUserBehaviorDataInMaster(final String userId, final String channelId,
+ public static UserBehaviorData onLunchFillUserBehaviorDataInMaster(final String userId, final String channelId,
final String jytUserId, final Boolean alreadyLoaded) {
- Map params = new HashMap<>();
- params.put("userId", userId);
- params.put("channelId", channelId);
- params.put("jytUserId", jytUserId);
- boolean success = false;
- if (!alreadyLoaded || StringUtils.isNotBlank(jytUserId)) {
- try {
- String response = OkHttp3Utils.doGet(HOST_UTL+"/audio_box/behavior", params);
- if (StringUtils.isNotBlank(response)) {
- JSONObject result = JSON.parseObject(response);
- if (NumberUtils.INTEGER_ONE.equals(result.getInteger("code"))) {
- result = result.getJSONObject("data");
- Map botAccount2HistoryTime = JSON.parseObject(result.getJSONObject("history").toJSONString(), new TypeReference>(){});
- Map botAccount2Flowers = JSON.parseObject(result.getJSONObject("flowers").toJSONString(), new TypeReference>(){});
- Map botAccount2FavoriteTime = JSON.parseObject(result.getJSONObject("favorite").toJSONString(), new TypeReference>(){});
- UserBehaviorData data = new UserBehaviorData();
- if (!CollectionUtils.isEmpty(botAccount2HistoryTime)) data.setUserBotId2History(botAccount2HistoryTime);
- if (!CollectionUtils.isEmpty(botAccount2FavoriteTime)) data.setUserBotId2Collected(botAccount2FavoriteTime);
- if (!CollectionUtils.isEmpty(botAccount2Flowers)) data.setUserBotId2Flowers(botAccount2Flowers);
- data.setJytUserId(jytUserId);
- data.setChannel(channelId);
- log.info("UserBehaviorData:"+data);
- log.info("userId;"+userId);
- success = true;
- USER_HISTORY.put(userId, data);
- log.info("USER_HISTORY:"+USER_HISTORY);
- return data;
- }
- }
- } catch (Exception e) {
- log.warn("onLunchFillUserBehaviorDataInMaster,获取用户信息失败:"+userId);
+// Map params = new HashMap<>();
+// params.put("userId", userId);
+// params.put("channelId", channelId);
+// params.put("jytUserId", jytUserId);
+// boolean success = false;
+// if (!alreadyLoaded || StringUtils.isNotBlank(jytUserId)) {
+// try {
+// String response = OkHttp3Utils.doGet(HOST_UTL+"audio_box/behavior", params);
+// if (StringUtils.isNotBlank(response)) {
+// JSONObject result = JSON.parseObject(response);
+// if (NumberUtils.INTEGER_ONE.equals(result.getInteger("code"))) {
+// result = result.getJSONObject("data");
+// Map botAccount2HistoryTime = JSON.parseObject(result.getJSONObject("history").toJSONString(), new TypeReference>(){});
+// Map botAccount2Flowers = JSON.parseObject(result.getJSONObject("flowers").toJSONString(), new TypeReference>(){});
+// Map botAccount2FavoriteTime = JSON.parseObject(result.getJSONObject("favorite").toJSONString(), new TypeReference>(){});
+// UserBehaviorData data = new UserBehaviorData();
+// if (!CollectionUtils.isEmpty(botAccount2HistoryTime)) data.setUserBotId2History(botAccount2HistoryTime);
+// if (!CollectionUtils.isEmpty(botAccount2FavoriteTime)) data.setUserBotId2Collected(botAccount2FavoriteTime);
+// if (!CollectionUtils.isEmpty(botAccount2Flowers)) data.setUserBotId2Flowers(botAccount2Flowers);
+// data.setJytUserId(jytUserId);
+//// data.setChannel(channelId);
+// log.info("userId:{},UserBehaviorData:{}",userId,data);
+// success = true;
+//// USER_HISTORY.put(userId, data);
+// getRedisTemplate().opsForValue().set(userId, data, 1, TimeUnit.HOURS);
+//// log.info("USER_HISTORY:"+USER_HISTORY);
+// return data;
+// }
+// }
+// } catch (Exception e) {
+// log.warn("onLunchFillUserBehaviorDataInMaster,获取用户信息失败:"+userId);
+// }
+// } else {
+// log.warn("用户已登陆但jytUserId却为null");
+// }
+// if (!success) {
+// log.warn("未从gameditor处获取到信息,查询数据库信息");
+// }
+ XiaoDuHistoryTBRepository historyTBRepository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
+ XiaoDuCollectRepository collectRepository = BaseHolder.getBean("xiaoDuCollectRepository");
+ XiaoDuOrderTbRepository orderTbRepository = BaseHolder.getBean("xiaoDuOrderTbRepository");
+ List historyTBS = historyTBRepository.getByXiaoduUserIdAndChannelId(userId, channelId);
+ List collectTBS = collectRepository.getByXiaoduUserIdAndChannelId(userId, channelId);
+ List orderTBS = orderTbRepository.getByXiaoduUserIdAndChannelIdAndStatus(userId, channelId, true);
+ UserBehaviorData data = new UserBehaviorData();
+ String jytId = jytUserId;
+ if (!CollectionUtils.isEmpty(historyTBS)) {
+ Map map = new HashMap<>();
+ for (XiaoDuHistoryTB xiaoDuHistoryTB: historyTBS) {
+ if (StringUtils.isBlank(jytId)) jytId = xiaoDuHistoryTB.getJytUserId();
+ String botAccount = ScheduleServiceNew.getBotAccountByWorkname(xiaoDuHistoryTB.getWorkName());
+ if (StringUtils.isNotBlank(botAccount)) map.put(botAccount, xiaoDuHistoryTB.getUpdateTime().getTime());
+ else log.warn("onLunchFillUserBehaviorDataInMaster: 历史数据库存储信息与缓存不一致");
}
- } else {
- log.warn("用户已登陆但jytUserId却为null");
- }
- if (!success) {
- log.warn("未从gameditor处获取到信息,查询数据库信息");
- XiaoDuHistoryTBRepository historyTBRepository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
- XiaoDuCollectRepository collectRepository = BaseHolder.getBean("xiaoDuCollectRepository");
- XiaoDuOrderTbRepository orderTbRepository = BaseHolder.getBean("xiaoDuOrderTbRepository");
- List historyTBS = historyTBRepository.getByXiaoduUserIdAndChannelId(userId, channelId);
- List collectTBS = collectRepository.getByXiaoduUserIdAndChannelId(userId, channelId);
- List orderTBS = orderTbRepository.getByXiaoduUserIdAndChannelIdAndStatus(userId, channelId, true);
- UserBehaviorData data = new UserBehaviorData();
- String jytId = jytUserId;
- if (!CollectionUtils.isEmpty(historyTBS)) {
+ data.setUserBotId2History(map);
+ }
+ if (alreadyLoaded) {
+ if (!CollectionUtils.isEmpty(collectTBS)) {
Map map = new HashMap<>();
- for (XiaoDuHistoryTB xiaoDuHistoryTB: historyTBS) {
- if (StringUtils.isBlank(jytId)) jytId = xiaoDuHistoryTB.getJytUserId();
- String botAccount = ScheduleServiceNew.getBotAccountByWorkname(xiaoDuHistoryTB.getWorkName());
- if (StringUtils.isNotBlank(botAccount)) map.put(botAccount, xiaoDuHistoryTB.getUpdateTime().getTime());
- else log.warn("onLunchFillUserBehaviorDataInMaster: 历史数据库存储信息与缓存不一致");
+ for (XiaoDuCollectTB xiaoDuCollectTB: collectTBS) {
+ if (StringUtils.isBlank(jytId)) jytId = xiaoDuCollectTB.getJytUserId();
+ String botAccount = ScheduleServiceNew.getBotAccountByWorkname(xiaoDuCollectTB.getWorkName());
+ if (StringUtils.isNotBlank(botAccount)) map.put(botAccount, xiaoDuCollectTB.getCreateTime().getTime());
+ else log.warn("onLunchFillUserBehaviorDataInMaster: 收藏数据库存储信息与缓存不一致");
}
- data.setUserBotId2History(map);
+ data.setUserBotId2Collected(map);
}
- if (alreadyLoaded) {
- if (!CollectionUtils.isEmpty(collectTBS)) {
- Map map = new HashMap<>();
- for (XiaoDuCollectTB xiaoDuCollectTB: collectTBS) {
- if (StringUtils.isBlank(jytId)) jytId = xiaoDuCollectTB.getJytUserId();
- String botAccount = ScheduleServiceNew.getBotAccountByWorkname(xiaoDuCollectTB.getWorkName());
- if (StringUtils.isNotBlank(botAccount)) map.put(botAccount, xiaoDuCollectTB.getCreateTime().getTime());
- else log.warn("onLunchFillUserBehaviorDataInMaster: 收藏数据库存储信息与缓存不一致");
- }
- data.setUserBotId2Collected(map);
- }
- if (!CollectionUtils.isEmpty(orderTBS)) {
- Map map = new HashMap<>();
- for (XiaoDuOrderTB xiaoDuOrderTB: orderTBS) {
- if (StringUtils.isBlank(jytId)) jytId = xiaoDuOrderTB.getAppUserId();
- String botAccount = ScheduleServiceNew.getBotAccountByWorkname(xiaoDuOrderTB.getWorkName());
- if (StringUtils.isNotBlank(botAccount)) map.put(botAccount, xiaoDuOrderTB.getNumber());
- else log.warn("onLunchFillUserBehaviorDataInMaster: 送花数据库存储信息与缓存不一致");
- }
- data.setUserBotId2Flowers(map);
+ if (!CollectionUtils.isEmpty(orderTBS)) {
+ Map map = new HashMap<>();
+ for (XiaoDuOrderTB xiaoDuOrderTB: orderTBS) {
+ if (StringUtils.isBlank(jytId)) jytId = xiaoDuOrderTB.getAppUserId();
+ String botAccount = ScheduleServiceNew.getBotAccountByWorkname(xiaoDuOrderTB.getWorkName());
+ if (StringUtils.isNotBlank(botAccount)) map.put(botAccount, xiaoDuOrderTB.getNumber());
+ else log.warn("onLunchFillUserBehaviorDataInMaster: 送花数据库存储信息与缓存不一致");
}
- data.setJytUserId(jytId);
+ data.setUserBotId2Flowers(map);
}
- data.setChannel(channelId);
- log.info("UserBehaviorData:"+data);
- USER_HISTORY.put(userId, data);
- return data;
+ data.setJytUserId(jytId);
}
- return null;
+// data.setChannel(channelId);
+ log.info("UserBehaviorData:"+data);
+ getRedisTemplate().opsForValue().set(userId, data, 1, TimeUnit.HOURS);
+ return data;
+// return null;
}
public static ThreadPoolExecutor getPOOL() {
return POOL;
}
- static String getDPLTemple(String path) {
+ public static String getDPLTemple(String path) {
String temple = null;
try {
temple = getJsonFromName(path);
@@ -268,10 +256,10 @@ public class DplbotServiceUtil {
return builder.toString();
}
- static boolean doesUserCollectThisBot(String botID, String accessToken, String userId, String channelId, String jytUserId) {
+ public static boolean doesUserCollectThisBot(String botID, String accessToken, String userId, String channelId, String jytUserId) {
boolean collected = false;
if (accessToken != null) {
- UserBehaviorData userData = USER_HISTORY.get(userId);
+ UserBehaviorData userData = getRedisTemplate().opsForValue().get(userId);
if (userData == null) {
log.info("doesUserCollectThisBot: data is null");
if (StringUtils.isBlank(jytUserId)) jytUserId = getUserIdByToken(accessToken, channelId, userId);
@@ -289,11 +277,11 @@ public class DplbotServiceUtil {
return text.substring(i1+1, i2);
}
- static Long getUserSendFlowerNum(String botAccount, String userID, String channelId, String accessToken, String jytUserId) {
+ public static Long getUserSendFlowerNum(String botAccount, String userID, String channelId, String accessToken, String jytUserId) {
if (accessToken != null) {
- UserBehaviorData data = USER_HISTORY.get(userID);
+ UserBehaviorData data = getRedisTemplate().opsForValue().get(userID);
if (data == null) {
- log.info("getUserSendFlowerNum: data is null");
+ log.warn("getUserSendFlowerNum: data is null");
if (StringUtils.isBlank(jytUserId)) jytUserId = getUserIdByToken(accessToken, channelId, userID);
data = onLunchFillUserBehaviorDataInMaster(userID, channelId, jytUserId, true);
if (data == null) return 0L;
@@ -305,22 +293,21 @@ public class DplbotServiceUtil {
return 0L;
}
- static boolean didUserCollecThisProduct(String botAccount, String userID,
+ public static boolean didUserCollecThisProduct(String botAccount, String userID,
String jytUserId, String channelId) {
- UserBehaviorData data = USER_HISTORY.get(userID);
+ UserBehaviorData data = getRedisTemplate().opsForValue().get(userID);
if (data == null) {
log.info("didUserCollecThisProduct: data is null");
data = onLunchFillUserBehaviorDataInMaster(userID, channelId, jytUserId, true);
}
if (data == null) return false;
- Long time = data.getUserBotId2Collected().get(botAccount);
- return time != null;
+ return data.getUserBotId2Collected().containsKey(botAccount);
}
- static boolean userUnCollectTheBot(final String userId, final String botAccount, String channelId,
+ public static boolean userUnCollectTheBot(final String userId, final String botAccount, String channelId,
String jytUserId, String accessToken) {
if (StringUtils.isAnyBlank(channelId, botAccount, userId)) return false;
- UserBehaviorData behaviorData = USER_HISTORY.get(userId);
+ UserBehaviorData behaviorData = getRedisTemplate().opsForValue().get(userId);
if (behaviorData == null) {
log.info("userUnCollectTheBot: data is null");
if (StringUtils.isBlank(jytUserId)) jytUserId = getUserIdByToken(accessToken, channelId, userId);
@@ -334,10 +321,11 @@ public class DplbotServiceUtil {
if (StringUtils.isBlank(jytUserId)) jytUserId = getUserIdByToken(accessToken, channelId, userId);
if (StringUtils.isBlank(jytUserId)) return false;
}
- updateTheUserCollectDataImmediately(jytUserId, channelId, botAccount, false);
- noticeOtherServer(3, botAccount, null, false, userId, jytUserId, channelId, true);
+// updateTheUserCollectDataImmediately(jytUserId, channelId, botAccount, false);
+// noticeOtherServer(3, botAccount, null, false, userId, jytUserId, channelId, true);
final String jytId = jytUserId;
POOL.submit(() -> updateCollectTable(false, userId, channelId, botAccount, jytId));
+ getRedisTemplate().opsForValue().set(userId, behaviorData, 1, TimeUnit.HOURS);
return true;
}
return false;
@@ -378,9 +366,9 @@ public class DplbotServiceUtil {
}
}
- static boolean userCollectTheBot(String userId, String botAccount, String channelId, String jytUserId, String accessToken) {
+ public static boolean userCollectTheBot(String userId, String botAccount, String channelId, String jytUserId, String accessToken) {
if (StringUtils.isAnyBlank(botAccount, channelId, userId)) return false;
- UserBehaviorData behaviorData = USER_HISTORY.get(userId);
+ UserBehaviorData behaviorData = getRedisTemplate().opsForValue().get(userId);
if (behaviorData == null) {
log.info("userCollectTheBot: data is null");
if (StringUtils.isBlank(jytUserId)) jytUserId = getUserIdByToken(accessToken, channelId, userId);
@@ -388,14 +376,14 @@ public class DplbotServiceUtil {
}
if (behaviorData != null) {
if (behaviorData.getUserBotId2Collected().containsKey(botAccount)) return true;
- behaviorData.getUserBotId2Collected().put(botAccount, curTime);
+ behaviorData.getUserBotId2Collected().put(botAccount, System.currentTimeMillis());
if (StringUtils.isBlank(jytUserId)) {
jytUserId = behaviorData.getJytUserId();
if (StringUtils.isBlank(jytUserId)) jytUserId = getUserIdByToken(accessToken, channelId, userId);
if (StringUtils.isBlank(jytUserId)) return false;
}
- updateTheUserCollectDataImmediately(jytUserId, channelId, botAccount, true);
- noticeOtherServer(3, botAccount, ScheduleServiceNew.curTime, true, userId, jytUserId, channelId, true);
+// updateTheUserCollectDataImmediately(jytUserId, channelId, botAccount, true);
+// noticeOtherServer(3, botAccount, ScheduleServiceNew.curTime, true, userId, jytUserId, channelId, true);
final String jytId = jytUserId;
POOL.submit(() -> updateCollectTable(true, userId, channelId, botAccount, jytId));
return true;
@@ -460,8 +448,8 @@ public class DplbotServiceUtil {
return xiaoDuOrderTB;
}
- static boolean doesUserPlayed(String botAccount, String userId, String channelId, Boolean loaded) {
- UserBehaviorData data = USER_HISTORY.get(userId);
+ public static boolean doesUserPlayed(String botAccount, String userId, String channelId, Boolean loaded) {
+ UserBehaviorData data = getRedisTemplate().opsForValue().get(userId);
if (data == null) {
log.info("doesUserPlayed: data is null");
data = onLunchFillUserBehaviorDataInMaster(userId, channelId, null, loaded);
@@ -469,65 +457,98 @@ public class DplbotServiceUtil {
return data != null && data.getUserBotId2History().containsKey(botAccount);
}
- static void updateTheUserHistory(final String userId,final String botAccount, final String accessToken,
- final String channelId) {
+ public static void updateUserFlower(String userId, int flowerNum, String channelId,
+ String jytUserId, String accessToken, String botAccount) {
+ UserBehaviorData data = getRedisTemplate().opsForValue().get(userId);
+ if (data == null) {
+ log.info("updateUserFlower: data is null");
+ if (StringUtils.isBlank(jytUserId)) jytUserId = getUserIdByToken(accessToken, channelId, userId);
+ data = onLunchFillUserBehaviorDataInMaster(userId, channelId, jytUserId, true);
+ if (data == null) {
+ log.error("没有获取到用户数据信息,导致更新用户送花缓存数据失败");
+ return;
+ }
+ }
+ Long before = data.getUserBotId2Flowers().get(botAccount);
+ if (before == null) {
+ before = 0L;
+ }
+ data.getUserBotId2Flowers().put(botAccount, before+flowerNum);
+ getRedisTemplate().opsForValue().set(userId, data, 1, TimeUnit.HOURS);
+ }
+
+ public static void updateTheUserHistory(final String userId,final String botAccount, final String accessToken,
+ final String channelId, final String jytUserId) {
POOL.submit(() -> {
- UserBehaviorData data = USER_HISTORY.get(userId);
+ UserBehaviorData data = getRedisTemplate().opsForValue().get(userId);
if (data == null) {
log.info("updateTheUserHistory: data is null");
- String jytUserId = null;
+ String appUserId = jytUserId;
boolean loaded = StringUtils.isNotBlank(accessToken);
- if (loaded) {
- jytUserId = getUserIdByToken(accessToken, channelId, userId);
+ if (StringUtils.isBlank(appUserId)) {
+ if (loaded) {
+ appUserId = getUserIdByToken(accessToken, channelId, userId);
+ }
}
- onLunchFillUserBehaviorDataInMaster(userId, channelId, jytUserId, loaded);
- } else {
- data.getUserBotId2History().put(botAccount, curTime);
+ data = onLunchFillUserBehaviorDataInMaster(userId, channelId, appUserId, loaded);
+ if (data == null) return;
}
- });
- }
+ data.getUserBotId2History().put(botAccount, System.currentTimeMillis());
+ getRedisTemplate().opsForValue().set(userId, data, 1, TimeUnit.HOURS);
- static void updateTheUserCollectData(final String userId, String channelId) {
- UserBehaviorData data = USER_HISTORY.remove(userId);
- if (data != null) {
- try {
- UpdateUserCollectData collectData = new UpdateUserCollectData();
- collectData.setChannel(channelId);
- collectData.setUserId(URLEncoder.encode(userId, "UTF-8"));
- collectData.setCollectInfo(data.getUserBotId2Collected());
- OkHttp3Utils.doPutAsy(HOST_UTL+"audio_box/update", JSON.toJSONString(collectData));
- } catch (Exception e) {
- log.warn("更新历史记录信息出错:"+userId);
+ XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
+ String botName = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
+ XiaoDuHistoryTB tb = repository.getByXiaoduUserIdAndChannelIdAndWorkName(userId, channelId, botName);
+ if (tb == null) {
+ tb = new XiaoDuHistoryTB();
+ tb.setChannelId(channelId);
+ tb.setJytUserId(jytUserId);
+ tb.setXiaoduUserId(userId);
+ tb.setWorkName(botName);
}
- }
+ repository.save(tb);
+ });
}
- private static void updateTheUserCollectDataImmediately(String userId, String channelId, String botAccount, boolean collect) {
- try {
- String name = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
- CollectInfo info = new CollectInfo();
- info.setUserId(userId);
- info.setChannelId(channelId);
- info.setWorkName(name);
- if (collect) {
- OkHttp3Utils.doPostAsy(HOST_UTL_TEMP+"audio_box/collect", JSON.toJSONString(info));
- log.info("test ansy");
- } else {
- OkHttp3Utils.doDelAsy(HOST_UTL_TEMP+"audio_box/collect", JSON.toJSONString(info));
- log.info("test ansy");
- }
- } catch (Exception e) {
- log.warn("更新历史记录信息出错:"+userId);
- }
- }
+// static void updateTheUserCollectData(final String userId, String channelId) {
+// UserBehaviorData data = USER_HISTORY.remove(userId);
+// if (data != null) {
+// try {
+// UpdateUserCollectData collectData = new UpdateUserCollectData();
+// collectData.setChannel(channelId);
+// collectData.setUserId(URLEncoder.encode(userId, "UTF-8"));
+// collectData.setCollectInfo(data.getUserBotId2Collected());
+// OkHttp3Utils.doPutAsy(HOST_UTL+"audio_box/update", JSON.toJSONString(collectData));
+// } catch (Exception e) {
+// log.warn("更新历史记录信息出错:"+userId);
+// }
+// }
+// }
+
+// private static void updateTheUserCollectDataImmediately(String userId, String channelId, String botAccount, boolean collect) {
+// try {
+// String name = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
+// CollectInfo info = new CollectInfo();
+// info.setUserId(userId);
+// info.setChannelId(channelId);
+// info.setWorkName(name);
+// if (collect) {
+// OkHttp3Utils.doPostAsy(HOST_UTL+"audio_box/collect", JSON.toJSONString(info));
+// } else {
+// OkHttp3Utils.doDelAsy(HOST_UTL+"audio_box/collect", JSON.toJSONString(info));
+// }
+// } catch (Exception e) {
+// log.warn("更新历史记录信息出错:"+userId);
+// }
+// }
- static Boolean dealChargeCallback(ChargeEvent chargeEvent, final String userId, final String accessToken,
+ public static Boolean dealChargeCallback(ChargeEvent chargeEvent, final String userId, final String accessToken,
final String jytUserId, String workName, String channelId) {
Payload payload = chargeEvent.getPayload();
final String chOrderId = chargeEvent.getSellerOrderId();
String[] tokens = chargeEvent.getToken().split(File.separator);
final String botAccount = tokens[0];
- if (payload.getPurchaseResult().equals("SUCCESS")) {
+ if ("SUCCESS".equals(payload.getPurchaseResult())) {
// createTimestamp字段与baiduOrderReferenceId字段与之后百度方进行结算使用,
// 现在createTimestamp由于百度方的bug需等到九月份才能获取到
final String baiduOrderReferenceId = payload.getBaiduOrderReferenceId();
@@ -536,10 +557,10 @@ public class DplbotServiceUtil {
POOL.submit(() -> {
XiaoDuOrderTbRepository repository = BaseHolder.getBean("xiaoDuOrderTbRepository");
- Long id = 0L;
+// Long id = 0L;
try {
- XiaoDuOrderTB tb = repository.getByChOrderId(chOrderId);
- id = tb.getId();
+// XiaoDuOrderTB tb = repository.getByChOrderId(chOrderId);
+// id = tb.getId();
repository.updateAterSeccessPayed(baiduOrderReferenceId,chOrderId, createTimestamp);
} catch (Exception e) {
// StringWriter writer = new StringWriter();
@@ -560,15 +581,15 @@ public class DplbotServiceUtil {
log.error("小度无屏在向app-flower_tb插入数据时没有获取到此用户登录的userID,数据信息:botAccount:{},num:{},xiaoduUserId:{}",
botAccount,num,userId);
}
- SendFlowerVO vo = new SendFlowerVO();
- vo.setBotAccount(botAccount);
- vo.setChannelId(channelId);
- vo.setName(workName);
- vo.setNum(Long.parseLong(num));
- vo.setUnitPrice(Double.parseDouble(Config.getProperty("unitPrice", Constants.UNIT_PRICE))/100);
- vo.setOrderId(id);
- vo.setUserId(appUserId);
- OkHttp3Utils.doPostJsonStr(HOST_UTL+"/audio_box/flower", JSON.toJSONString(vo));
+// SendFlowerVO vo = new SendFlowerVO();
+// vo.setBotAccount(botAccount);
+// vo.setChannelId(channelId);
+// vo.setName(workName);
+// vo.setNum(Long.parseLong(num));
+// vo.setUnitPrice(Double.parseDouble(Config.getProperty("unitPrice", Constants.UNIT_PRICE))/100);
+// vo.setOrderId(id);
+// vo.setUserId(appUserId);
+// OkHttp3Utils.doPostJsonStr(HOST_UTL+"audio_box/flower", JSON.toJSONString(vo));
} catch (Exception e) {
log.error("像app_flower_tb中添加数据失败,{},数据信息:botAccount:{},num:{},xiaoduUserId:{}",
e.toString(),botAccount,num,userId);
@@ -589,19 +610,23 @@ public class DplbotServiceUtil {
final String accessToken, final String jytUserId, final String channel) {
POOL.submit(() -> {
if (StringUtils.isAnyBlank(botAccount, userId)) return;
- UserBehaviorData data = USER_HISTORY.get(userId);
+// UserBehaviorData data = USER_HISTORY.get(userId);
+ UserBehaviorData data = getRedisTemplate().opsForValue().get(userId);
if (data != null) {
- data.setMark(1);
- data.getUserBotId2History().put(botAccount, curTime);
- noticeOtherServer(1, botAccount, ScheduleServiceNew.curTime, false, userId, jytUserId, channel, accessToken!= null);
+// data.setMark(1);
+ data.getUserBotId2History().put(botAccount, System.currentTimeMillis());
+// noticeOtherServer(1, botAccount, ScheduleServiceNew.curTime, false, userId, jytUserId, channel, accessToken!= null);
} else {
log.info("updateTheUserBehaviorDataMark: data is null");
data = onLunchFillUserBehaviorDataInMaster(userId, channel, jytUserId, accessToken != null);
if (data != null) {
- data.getUserBotId2History().put(botAccount, curTime);
- noticeOtherServer(1, botAccount, ScheduleServiceNew.curTime, false, userId, jytUserId, channel, accessToken!= null);
+ data.getUserBotId2History().put(botAccount, System.currentTimeMillis());
+// noticeOtherServer(1, botAccount, ScheduleServiceNew.curTime, false, userId, jytUserId, channel, accessToken!= null);
}
}
+ if (data != null) {
+ getRedisTemplate().opsForValue().set(userId, data, 1, TimeUnit.HOURS);
+ }
XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
String botName = ScheduleServiceNew.getWorkNameByBotAccount(botAccount);
XiaoDuHistoryTB tb = repository.getByXiaoduUserIdAndChannelIdAndWorkName(userId, channel, botName);
@@ -770,16 +795,19 @@ public class DplbotServiceUtil {
return actorList;
}
- static List getTheActorsWithWords(JSONArray array) {
+ static List getTheActorsWithWords(JSONArray array, String botAccount) {
if (array != null && array.size() > 0) {
JSONObject job;
ActorWithWord aw;
List list= new ArrayList<>();
+ int i = 1;
for (Object ob: array) {
job = (JSONObject)ob;
aw = new ActorWithWord();
aw.setActor(job.getString("npcName"));
+ aw.setAsideImg(ScheduleServiceNew.getAsideImgUrl(botAccount, aw.getActor()));
aw.setText(job.getString("text").replaceAll("\\{/.*?/}|\uD83C\uDD70|\uD83C\uDD71", ""));
+ aw.setItemSeqId(i++);
list.add(aw);
}
return list;
@@ -787,6 +815,40 @@ public class DplbotServiceUtil {
return null;
}
+ public static List getTheActorsWithWords(ArrayNode array, String botAccount) {
+ if (array != null && array.size() > 0) {
+ ActorWithWord aw;
+ List list= new ArrayList<>();
+ int i = 1;
+ for (Iterator it = array.elements(); it.hasNext(); ) {
+ JsonNode ob = it.next();
+ aw = new ActorWithWord();
+ aw.setActor(ob.get("npcName").asText());
+ aw.setAsideImg(ScheduleServiceNew.getAsideImgUrl(botAccount, aw.getActor()));
+ aw.setText(ob.get("text").asText().replaceAll("\\{/.*?/}|\uD83C\uDD70|\uD83C\uDD71", ""));
+ aw.setItemSeqId(i++);
+ list.add(aw);
+ }
+ return list;
+ }
+ return null;
+ }
+
+ public static List getTheActorsWithWords(List dialogs, final String botAccount) {
+ if (!CollectionUtils.isEmpty(dialogs)) {
+ AtomicInteger integer = new AtomicInteger(1);
+ return dialogs.parallelStream().map(dialogData -> {
+ ActorWithWord aw = new ActorWithWord();
+ aw.setActor(dialogData.getNpcName());
+ aw.setAsideImg(ScheduleServiceNew.getAsideImgUrl(botAccount, dialogData.getNpcName()));
+ aw.setText(dialogData.getText().replaceAll("\\{/.*?/}|\uD83C\uDD70|\uD83C\uDD71|\\^", ""));
+ aw.setItemSeqId(integer.getAndIncrement());
+ return aw;
+ }).collect(Collectors.toList());
+ }
+ return null;
+ }
+
public static String[] seperateActorWord(String text, Pattern pattern) {
String[] actorWords = pattern.split(text);
if (StringUtils.startsWith(text.trim(), "【")) {
@@ -815,7 +877,7 @@ public class DplbotServiceUtil {
return;
}
}
- behaviorData.setMark(1);
+// behaviorData.setMark(1);
if (behaviorData.getJytUserId() == null) behaviorData.setJytUserId(data.getJytUserId());
switch (type) {
case 1 : behaviorData.getUserBotId2History().put(data.getBotAccount(), data.getTimeOrCount()); break;
@@ -834,4 +896,38 @@ public class DplbotServiceUtil {
public static void printCache() {
log.info("history cache:"+USER_HISTORY);
}
+
+ public static Integer extractNum(String numStr) {
+ numStr = numStr.replaceAll("[ \uD83C\uDD70\uD83C\uDD71]", "");
+ int num = 1;
+ try {
+ num = Integer.parseInt(numStr);
+ return num;
+ } catch (Exception e) {
+ int i;
+ if ((i=numStr.indexOf("第")) != -1) {
+ String str = numStr.substring(i+1, numStr.length()-1);
+ try {
+ num = Integer.parseInt(str);
+ } catch (Exception e1) {
+ num = Utils.changeHanToNum(str);
+ }
+ } else {
+ num = Utils.changeHanToNum(numStr);
+ }
+ }
+ return num;
+ }
+
+ public static void main(String[] args) throws IOException {
+// String accesstoken = "349616e0-f039-4ad6-81be-344c2d53dd47";
+// String accesstoken = "6fcf70d5-3611-4fc0-8a0b-491532526afc";
+// HashMap headers = new HashMap<>();
+// headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
+// headers.put("Authorization", BEARER + accesstoken);
+// String str = OkHttp3Utils.doGet(USER_ID_BY_TOKEN, new HashMap<>(), headers);
+// System.out.println(str);
+
+ System.out.println("手机号验证码获取token时^只传了".replaceAll("\\{/.*?/}|\uD83C\uDD70|\uD83C\uDD71|\\^", ""));
+ }
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/LoadBySMS.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/LoadBySMS.java
index 568ffdf..17c8090 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/LoadBySMS.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/LoadBySMS.java
@@ -121,7 +121,7 @@ public class LoadBySMS {
*/
public boolean requireCodeToken(String phoneNumber, String captcha) throws IOException {
HashMap headers = new HashMap<>();
- headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
+ headers.put("App-Channel-Id", "xiaodu-speaker-api-test");
headers.put("Content-Type", "application/json;charset=utf-8");
headers.put("Authorization", Utils.tokenAuthorization(phoneNumber, captcha));
String tokenStr = OkHttp3Utils.doGet(XIAOWU_API.SDK_TOKEN, new HashMap<>(), headers);
@@ -143,7 +143,7 @@ public class LoadBySMS {
*/
private Integer getCaptchaRequest(String authorization) throws IOException {
HashMap headers = new HashMap<>();
- headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
+ headers.put("App-Channel-Id", "xiaodu-speaker-api-test");
headers.put("Content-Type", "application/json;charset=utf-8");
headers.put("Authorization", authorization);
String smsStr = OkHttp3Utils.doGet(XIAOWU_API.CAPTCHA_SMS, new HashMap<>(), headers);
@@ -186,7 +186,7 @@ public class LoadBySMS {
public static TokenResponse getTokenByRefreshToken(String refreshToken) {
HashMap headers = new HashMap<>();
- headers.put("App-Channel-Id", "JIAOYOUTIANXIA");
+ headers.put("App-Channel-Id", "xiaodu-speaker-api-test");
headers.put("Content-Type", "application/json;charset=utf-8");
headers.put("Authorization", XIAOWU_API.BEARER+refreshToken);
String smsStr = null;
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java
index ffec877..8c02577 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/RequestTerminal.java
@@ -17,7 +17,7 @@ import java.util.HashMap;
* @dateTime 19-6-29 下午3:49
*/
@Slf4j
-class RequestTerminal {
+public class RequestTerminal {
static String requestTerminateUrl(String userWord, String userId, String channel, String baseHostUrl) throws IOException {
SpiritTerminateRequest requestPojo = new SpiritTerminateRequest();
@@ -32,7 +32,7 @@ class RequestTerminal {
return OkHttp3Utils.doPostJsonStrForCentralWithUidParam(baseHostUrl, requestJsonStr, headers, userId);
}
- static String requestTerminateTemp(String userWord, String userId, String channel) throws IOException {
+ public static String requestTerminateTemp(String userWord, String userId, String channel) throws IOException {
SpiritTerminateRequest requestPojo = new SpiritTerminateRequest();
requestPojo.setUid(userId);
requestPojo.setMsg(userWord);
@@ -132,15 +132,11 @@ class RequestTerminal {
OkHttp3Utils.backPostAsync(Constants.INTERFACE_DI, requestJsonStr, type);
}
- public static void main(String[] args) throws IOException {
- String url = "http://didi-gz5.jiaoyou365.com:18082/api/works";
- HashMap params = new HashMap<>();
- params.put("include", "npcHeadImgUrl");
- params.put("aipioneerUsername","948644704");
- String str = OkHttp3Utils.doGet(url, params);
- AsideImageResponse response = JSON.parseObject(str, AsideImageResponse.class);
- System.out.println(response.getData().getNpcHeadImgUrl());
-
-// requestTerminate("有科幻类的吗", "2352521agag");
+ public static void backRequestByChannel(String userId, String channel) {
+ SpiritTerminateRequest requestPojo = new SpiritTerminateRequest();
+ requestPojo.setUid(userId);
+ requestPojo.setMsg("退出");
+ String requestJsonStr = JSON.toJSONString(requestPojo);
+ OkHttp3Utils.backPostAsyncByChannel(ScheduleServiceNew.BASE_HOST_URL+"?uid="+userId, requestJsonStr, channel);
}
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
deleted file mode 100755
index 295657c..0000000
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
+++ /dev/null
@@ -1,355 +0,0 @@
-package ai.qiwu.com.xiaoduhome.service;
-
-import ai.qiwu.com.xiaoduhome.common.BaseHolder;
-import ai.qiwu.com.xiaoduhome.common.Config;
-import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
-import ai.qiwu.com.xiaoduhome.common.temple.onLunch.LunchUtils;
-import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommendUtil;
-import ai.qiwu.com.xiaoduhome.entity.primary.GameProjectTb;
-import ai.qiwu.com.xiaoduhome.entity.primary.OnProductDetail;
-import ai.qiwu.com.xiaoduhome.entity.secondary.XiaoDuHistoryTB;
-import ai.qiwu.com.xiaoduhome.pojo.UserBehaviorData;
-import ai.qiwu.com.xiaoduhome.pojo.playAside.AsideImageResponse;
-import ai.qiwu.com.xiaoduhome.repository.primary.AllOnProductInfoRepository;
-import ai.qiwu.com.xiaoduhome.repository.primary.GameProjectTbRepository;
-import ai.qiwu.com.xiaoduhome.repository.primary.ProjectLabelRepository;
-import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryTBRepository;
-import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuOrderTbRepository;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
-import com.alibaba.fastjson.JSONObject;
-import lombok.extern.slf4j.Slf4j;
-import okhttp3.OkHttpClient;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.springframework.beans.factory.InitializingBean;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-import org.springframework.util.CollectionUtils;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static ai.qiwu.com.xiaoduhome.common.Constants.DPL_COMPONENT_ID.DEFAULT_ASIDE_IMG_URL;
-import static ai.qiwu.com.xiaoduhome.common.Constants.RE_RA_CA_PAGE_SIZE;
-import static ai.qiwu.com.xiaoduhome.common.Constants.UNIT_PRICE;
-import static ai.qiwu.com.xiaoduhome.common.Constants.XIAOWU_API.ASIDE_IMG_URL;
-
-/**
- * @author 苗权威
- * @dateTime 19-8-14 下午8:56
- */
-@Slf4j
-//@Component
-public class ScheduleService implements InitializingBean {
- private static volatile int allProductCount;
- private static volatile int rankPageSize;
- private static volatile List RANKING_LIST = new ArrayList<>();
- private static volatile List RECOMMEND_LIST = new ArrayList<>();
- private static volatile List ALL_ON_PRODUCT = new ArrayList<>();
- private static volatile List RANK_ORDER_IDs = new ArrayList<>();
- static volatile HashMap PRODUCT_NAME_DETAIL = new HashMap<>();
- static volatile HashMap PRODUCT_ID_DETAIL = new HashMap<>();
-
- private static final List EXCEPT_BOT_ACCOUNT = new ArrayList<>();
-
- static final String[] CATEGORY = {"古风", "儿童", "科幻", "占星", "恋爱", "灾难", "架空", "经营", "冒险", "武侠"};
- private static final String[] CATEGORY_CHARAC={"gufeng","child","kehuan","zhanxing","lianai","zainan","jiakong","jingying","maoxian","wuxia"};
-
- private static volatile HashMap> CATEGORY_PRODUCT_ID_LIST = new HashMap<>();
-
- private final GameProjectTbRepository gameProjectTbRepository;
-
- private final ProjectLabelRepository projectLabelRepository;
-
- private final AllOnProductInfoRepository allOnProductInfoRepository;
-
- private final XiaoDuHistoryTBRepository xiaoDuHistoryTBRepository;
-
- private final XiaoDuOrderTbRepository xiaoDuOrderTbRepository;
-
- public static volatile Map channelId2RecommendBotAcc = new HashMap<>();
-
- public static volatile Map> channel2Bots = new HashMap<>();
- public static volatile Map> jiaoyouChannel2Bots = new HashMap<>();
-
-// public static volatile String STORY_WELCOME_WORD = "欢迎来到晓悟智能故事频道。与可爱的角色们自由对话,畅游不同的故事世界。我们新上线的遇见伽利略,你可以说打开遇见伽利略。或者说,推荐其它作品。";// 智能故事
-// public static volatile String NOVEL_WELCOME_WORD = "欢迎来到晓悟智能小说频道。与剧情人物自由对话,带您体验不同的人生和情怀。向您推荐新上线的求生记,您可以说打开求生记。或者说,推荐其它作品。";// 智能小说
-// public static volatile String JIAOYOU_WELCOME_WORD = "欢迎来到晓悟智能小说频道。与剧情人物自由对话,带您体验不同的人生和情怀。向您推荐新上线的求生记,您可以说打开求生记。或者说,推荐其它作品。";// 智能小说
-
- @Autowired
- public ScheduleService(GameProjectTbRepository gameProjectTbRepository,
- ProjectLabelRepository projectLabelRepository,
- AllOnProductInfoRepository allOnProductInfoRepository,
- XiaoDuHistoryTBRepository xiaoDuHistoryTBRepository,
- XiaoDuOrderTbRepository xiaoDuOrderTbRepository) {
- this.gameProjectTbRepository = gameProjectTbRepository;
- this.projectLabelRepository = projectLabelRepository;
- this.allOnProductInfoRepository = allOnProductInfoRepository;
- this.xiaoDuHistoryTBRepository = xiaoDuHistoryTBRepository;
- this.xiaoDuOrderTbRepository = xiaoDuOrderTbRepository;
- }
-
-// @Scheduled(cron = "* */10 * * * ?")
-// public void updateTheWelcomeName() {
-// DplbotServiceUtil.POOL.submit(() -> {
-// List onlinedProject = allOnProductInfoRepository.findAllByApplyStatusAndWorkType(1,27L);
-//
-// });
-// }
-
-// @Scheduled(cron = "0 0 17 * * ?")
- public void initAllOnTableProductInfo() {
- new Thread(() -> {
- ALL_ON_PRODUCT = allOnProductInfoRepository.findAllByApplyStatusAndScoreNot(1, 0f);
- allProductCount = ALL_ON_PRODUCT.size();
- rankPageSize = allProductCount / RE_RA_CA_PAGE_SIZE + (allProductCount%RE_RA_CA_PAGE_SIZE == 0 ? 0:1);
- TreeMap rankOrder = new TreeMap<>((o1, o2) -> o1-o2 < 0 ? 1 :(o1.equals(o2) ? 0 : -1));
- HashMap nd = new HashMap<>();
- HashMap id = new HashMap<>();
- for (OnProductDetail item : ALL_ON_PRODUCT) {
- String productName = item.getName();
- String botAccount = item.getBotAccount();
- List labels = projectLabelRepository.productLabels(item.getId());
- //PRODUCT_LABELS.put(productName, labels);
- item.setLabels(labels);
- nd.put(productName, item);
- id.put(botAccount, item);
- rankOrder.put(item.getWatch(), item);
- }
- PRODUCT_NAME_DETAIL = nd;
- PRODUCT_ID_DETAIL = id;
- RANK_ORDER_IDs = new ArrayList<>(rankOrder.values());
- RecommendUtil.setRankDocument(null);
- //log.info("作品详细信息:{}", PRODUCT_NAME_DETAIL);
- }).start();
- //log.error("更新推荐页出错:{}", e.getMessage());
- }
-
-// @Scheduled(cron = "0 0 19 * * ?")
- public void initRankingList() {
- new Thread(() -> {
- RANKING_LIST = gameProjectTbRepository.findFirst8();
- LunchUtils.setLunchDocument(LunchUtils.buildLunchDocument());
- //log.info("排行榜:{}", RANKING_LIST);
- }).start();
- //log.error("更新排行榜出错:{}", e.getMessage());
- }
-
-// @Scheduled(cron = "0 0 */2 * * ?")
- public void initRecommendList() {
- new Thread(() -> {
- RECOMMEND_LIST = gameProjectTbRepository.recommendList();
- LunchUtils.setLunchDocument(LunchUtils.buildLunchDocument());
- //log.info("推荐:{}", RECOMMEND_LIST);
- }).start();
- //log.error("更新推荐页出错:{}", e.getMessage());
- }
-
-// @Scheduled(cron = "0 0 1 * * ?")
- public void initProductList() {
- new Thread(() -> {
- HashMap> ci = new HashMap<>();
- for (String category: CATEGORY) {
- //List list = gameProjectTbRepository.categoryProject(category);
- List idList = gameProjectTbRepository.categoryProList(category);
- ci.put(category, idList);
- //CATEGORY_PRODUCT_LIST.put(category, list);
- //log.info("分类{},作品列表{}", category, list);
- }
- CATEGORY_PRODUCT_ID_LIST = ci;
- }).start();
- //log.error("更新分类作品列表出错:{}", e.getMessage());
- }
-
-// @Scheduled(cron = "0 0 2 * * ?")
- public void deleteOverTimeHistory() {
- new Thread(() -> {
- xiaoDuHistoryTBRepository.deletePasted(System.currentTimeMillis()-259200000);//3 days
- //xiaoDuHistoryTBRepository.deletePasted(System.currentTimeMillis()-300000);
- List userIds = xiaoDuHistoryTBRepository.getAllUser();
- for (String userId: userIds) {
-// xiaoDuHistoryTBRepository.deleteOverTime(userId);
- }
- }).start();
- //log.error("清理历史记录数据库出错:{}", e.toString());
- }
-
-// @Scheduled(cron = "0 0 3 * * ?")
- public void deleteUnPayedOrder() {
- new Thread(() -> {
- long boundTime = System.currentTimeMillis()-600000;
- xiaoDuOrderTbRepository.deleteOverTimeOrder(boundTime);
- }).start();
- }
-
-// @Scheduled(cron = "0 0 */1 * * ?")
- public void shuffleAllProList() {
- new Thread(() -> {
- Collections.shuffle(ALL_ON_PRODUCT);
- }).start();
- }
-
-// @Scheduled(cron = "0 */20 * * * ?")
- public void getAllChannelRecommendBotAccount() {
- String response = null;
- int count = 1;
- Map map = new HashMap<>();
- do {
- try {
- response = OkHttp3Utils.doGet("http://didi-gz3.jiaoyou365.com:8070/api/sdk/botConfig/all");
- JSONArray array = JSONObject.parseArray(response);
- if (array != null) {
- for (Object o: array) {
- JSONObject object = (JSONObject) o;
- if (Boolean.FALSE.equals(object.getBoolean("auth"))) {
- map.put(object.getString("appChannelId"), object.getString("recommendBotAccount"));
- }
- }
- }
- } catch (Exception e) {
- log.error("getAllChannelRecommendBotAccount:{}",e);
- }
- if (StringUtils.isBlank(response)) {
- try {
- Thread.sleep(count*5);
- } catch (Exception e) {}
- log.warn("第"+count+"次获取channelId失败");
- }
- count++;
- } while (StringUtils.isBlank(response) && count < 5);
- if (map.size() != 0) {
- channelId2RecommendBotAcc = map;
- }
- log.info("channelId2RecommendBotAcc:"+channelId2RecommendBotAcc);
- }
-
-// @Scheduled(cron = "0 */30 * * * ?")
- public void getChannelAllBots() {
- String response;
- JSONObject jsonObject;
- int count = 1;
- boolean success = false;
- do {
- try {
- response = OkHttp3Utils.doGet("http://didi-gz3.jiaoyou365.com:18082/api/data/audio/list");
- jsonObject = JSON.parseObject(response).getJSONObject("data");
- Map> map = jsonObject.toJavaObject(Map.class);
- if (map != null && map.size() != 0) {
- channel2Bots = map;
- success = true;
- } else {
- log.info("getChannelAllBots failed count="+count);
- Thread.sleep(count*5);
- }
- } catch (Exception e) {
- log.warn("getChannelAllBots: "+e);
- }
- count++;
- } while (!success && count < 5);
- log.info("getChannelAllBots:"+channel2Bots);
- }
-
-// @Scheduled(cron = "0 */30 * * * ?")
- public void getJiaoYouChannelRecordBots() {
- String response;
- JSONObject jsonObject;
- int count = 1;
- boolean success = false;
- do {
- try {
- response = OkHttp3Utils.doGet("http://didi-gz3.jiaoyou365.com:18082/api/data/audio/list/jiaoyou");
- jsonObject = JSON.parseObject(response).getJSONObject("data");
- Map> map = jsonObject.toJavaObject(Map.class);
- if (map != null && map.size() != 0) {
- List jiaoyouList = map.get("jiaoyou-audio-adult-test");
- if (!CollectionUtils.isEmpty(jiaoyouList)) map.get("jiaoyou-audio-adult-test").add("遇见伽利略");
- List xiaoaiJiaoyouList = map.get("xiaoai-jiaoyou-audio-adult-test");
- if (!CollectionUtils.isEmpty(xiaoaiJiaoyouList)) map.get("xiaoai-jiaoyou-audio-adult-test").add("遇见伽利略");
- jiaoyouChannel2Bots = map;
- success = true;
- } else {
- log.info("getChannelAllBots failed count="+count);
- Thread.sleep(count*5);
- }
- } catch (Exception e) {
- log.warn("getChannelAllBots: "+e);
- }
- count++;
- } while (!success && count < 5);
- log.info("getChannelAllBots:"+jiaoyouChannel2Bots);
- }
-
- @Override
- public void afterPropertiesSet() throws Exception {
- initAllOnTableProductInfo();
- initRecommendList();
- initRankingList();
- initProductList();
- deleteOverTimeHistory();
- deleteUnPayedOrder();
-// tian();
- getAllChannelRecommendBotAccount();
- getChannelAllBots();
- getJiaoYouChannelRecordBots();
- }
-
- private void tian(){
- EXCEPT_BOT_ACCOUNT.add("4151097686");
- EXCEPT_BOT_ACCOUNT.add("6823941516");
- EXCEPT_BOT_ACCOUNT.add("2850282206");
- EXCEPT_BOT_ACCOUNT.add("3528512723");
- EXCEPT_BOT_ACCOUNT.add("743677363");
- }
-
- public static List getRANK_ORDER_IDs() {
- return RANK_ORDER_IDs;
- }
-
- public static HashMap getProductIdDetail() {
- return PRODUCT_ID_DETAIL;
- }
-
- public static HashMap getProductNameDetail() {
- return PRODUCT_NAME_DETAIL;
- }
-
- public static List getRankingList() {
- return RANKING_LIST;
- }
-
- public static List getRecommendList() {
- return RECOMMEND_LIST;
- }
-
- static List getExceptBotAccount() {
- return EXCEPT_BOT_ACCOUNT;
- }
-
- public static List getAllOnProduct() {
- return ALL_ON_PRODUCT;
- }
-
- public static int getAllProductCount() {
- return allProductCount;
- }
-
- public static String[] getCATEGORY() {
- return CATEGORY;
- }
-
- public static String[] getCategoryCharac() {
- return CATEGORY_CHARAC;
- }
-
- public static HashMap> getCategoryProductIdList() {
- return CATEGORY_PRODUCT_ID_LIST;
- }
-
- public static int getRankPageSize() {
- return rankPageSize;
- }
-}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleServiceNew.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleServiceNew.java
index 7324f90..ef170ef 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleServiceNew.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleServiceNew.java
@@ -8,6 +8,9 @@ import ai.qiwu.com.xiaoduhome.pojo.data.ProjectDataResult;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.InitializingBean;
@@ -37,11 +40,11 @@ public class ScheduleServiceNew implements InitializingBean {
public static volatile List serverAddresses = new ArrayList<>();
- static final String FLOWER_UNIT_PRICE = Config.getProperty("unitPrice", UNIT_PRICE);
+ public static final String FLOWER_UNIT_PRICE = Config.getProperty("unitPrice", UNIT_PRICE);
- static volatile Long curTime = System.currentTimeMillis();
+// static volatile Long curTime = System.currentTimeMillis();
- public static final String[] CATEGORY = {"古风", "言情", "灾难", "冒险", "武侠", "穿越", "答题", "经营"};
+ public static final List CATEGORY = Arrays.asList("古风", "言情", "灾难", "冒险", "武侠", "穿越", "答题", "经营");
public static final String[] CATEGORY_CHARAC={"gufeng","yanqing","zainan","maoxian","wuxia", "chuanyue", "dati", "jingying"};
public static volatile Map> category2Bots = new HashMap<>();
@@ -64,8 +67,26 @@ public class ScheduleServiceNew implements InitializingBean {
public static volatile String CDN_HOST_URL;
public static volatile String OLD_CDN_HOST_URL;
- static {
+ private static volatile String HOST_UTL;
+ private static volatile String CENTRAL_HOST;
+
+ public static final ObjectMapper objectMapper;
+ public static final Set LOAD_AUTH_CALLBACK_URL;
+
+ static {
+ HOST_UTL = Config.getProperty("requestHost");
+ CENTRAL_HOST = Config.getProperty("centralHost");
+
+ LOAD_AUTH_CALLBACK_URL = new HashSet<>();
+ LOAD_AUTH_CALLBACK_URL.add("https://xiaodu.baidu.com/saiya/auth/3a0610f8af67a3c92d803a80a1c8976c");
+ LOAD_AUTH_CALLBACK_URL.add("https://xiaodu-dbp.baidu.com/saiya/auth/3a0610f8af67a3c92d803a80a1c8976c");
+ LOAD_AUTH_CALLBACK_URL.add("https://xiaodu.baidu.com/saiya/auth/4fbc7b9112e3a43dc7dbf43fd556929e");
+ LOAD_AUTH_CALLBACK_URL.add("https://xiaodu-dbp.baidu.com/saiya/auth/4fbc7b9112e3a43dc7dbf43fd556929e");
+
+ objectMapper = new ObjectMapper();
+ objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false);
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
}
@Override
@@ -73,6 +94,7 @@ public class ScheduleServiceNew implements InitializingBean {
getAllProjects();
getOtherServerAddress();
getJiaoYouChannelRecordBots();
+
BASE_HOST_URL = Config.getProperty("baseHostUrl");
BASE_AUDIO_URL = Config.getProperty("baseAudioUrl");
CDN_HOST_URL = Config.getProperty("cdnHostUrl");
@@ -91,7 +113,7 @@ public class ScheduleServiceNew implements InitializingBean {
private void getAllProjects() {
new Thread(() -> {
try {
- String response = OkHttp3Utils.doGet(DplbotServiceUtil.HOST_UTL+"/audio_box/project");
+ String response = OkHttp3Utils.doGet(HOST_UTL+"audio_box/project");
if (StringUtils.isNotBlank(response)) {
ProjectDataResult result = JSON.parseObject(response, ProjectDataResult.class);
if (new Integer(1).equals(result.getCode())) {
@@ -126,12 +148,13 @@ public class ScheduleServiceNew implements InitializingBean {
} catch (Exception e) {
log.warn("ScheduleServiceNew#getAllProjects获取所有作品信息失败:"+e);
}
+
String response = null;
int count = 1;
Map map = new HashMap<>();
do {
try {
- response = OkHttp3Utils.doGet("http://didi-gz5.jiaoyou365.com:8070/api/sdk/botConfig/all");
+ response = OkHttp3Utils.doGet(CENTRAL_HOST+"/api/sdk/botConfig/all");
JSONArray array = JSONObject.parseArray(response);
if (array != null) {
for (Object o: array) {
@@ -164,11 +187,11 @@ public class ScheduleServiceNew implements InitializingBean {
}).start();
}
- @Scheduled(cron = "0 */2 * * * ?")
- public void updateTheCurTime() {
-// log.info("updateTheCurTime start");
- curTime = System.currentTimeMillis();
- }
+// @Scheduled(cron = "0 */2 * * * ?")
+// public void updateTheCurTime() {
+//// log.info("updateTheCurTime start");
+// curTime = System.currentTimeMillis();
+// }
private void getOtherServerAddress() {
String servers = Config.getProperty("serverAddress");
@@ -178,67 +201,72 @@ public class ScheduleServiceNew implements InitializingBean {
}
}
- @Scheduled(initialDelay = 3600000, fixedRate = 3600000)
- public void clearUserBehaviorData() {
- log.info("clearUserBehaviorData start");
- List needClear = new ArrayList<>();
- for (String userId: DplbotServiceUtil.USER_HISTORY.keySet()) {
- UserBehaviorData data = DplbotServiceUtil.USER_HISTORY.get(userId);
- if (data != null) {
- if (data.getMark() == 1) data.setMark(0);
- else {
- needClear.add(userId);
- }
- }
- }
- for (String userId: needClear) {
- log.info("clearUserBehaviorData:"+needClear);
- DplbotServiceUtil.USER_HISTORY.remove(userId);
- }
- }
+// @Scheduled(initialDelay = 3600000, fixedRate = 3600000)
+// public void clearUserBehaviorData() {
+// log.info("clearUserBehaviorData start");
+// List needClear = new ArrayList<>();
+// for (String userId: DplbotServiceUtil.USER_HISTORY.keySet()) {
+// UserBehaviorData data = DplbotServiceUtil.USER_HISTORY.get(userId);
+// if (data != null) {
+// if (data.getMark() == 1) data.setMark(0);
+// else {
+// needClear.add(userId);
+// }
+// }
+// }
+// for (String userId: needClear) {
+// log.info("clearUserBehaviorData:"+needClear);
+// DplbotServiceUtil.USER_HISTORY.remove(userId);
+// }
+// }
@Scheduled(cron = "0 0 11,16,22 * * ?")
public void getJiaoYouChannelRecordBots() {
- log.info("getJiaoYouChannelRecordBots start");
- String response;
- JSONObject jsonObject;
- int count = 1;
- boolean success = false;
- do {
- try {
- response = OkHttp3Utils.doGet("http://192.168.0.148:18082/api/data/audio/list/jiaoyou");
- jsonObject = JSON.parseObject(response).getJSONObject("data");
- Map> map = jsonObject.toJavaObject(Map.class);
- if (map != null && map.size() != 0) {
- List jiaoyouList = map.get("jiaoyou-audio-adult-test");
- if (!CollectionUtils.isEmpty(jiaoyouList)) map.get("jiaoyou-audio-adult-test").add("遇见伽利略");
- List xiaoaiJiaoyouList = map.get("xiaoai-jiaoyou-audio-adult-test");
- if (!CollectionUtils.isEmpty(xiaoaiJiaoyouList)) map.get("xiaoai-jiaoyou-audio-adult-test").add("遇见伽利略");
- jiaoyouChannel2Bots = map;
- success = true;
- } else {
- log.info("getChannelAllBots failed count="+count);
- Thread.sleep(count*5);
+ DplbotServiceUtil.POOL.submit(() -> {
+ log.info("getJiaoYouChannelRecordBots start");
+ String response;
+ JSONObject jsonObject;
+ int count = 1;
+ boolean success = false;
+ do {
+ try {
+ response = OkHttp3Utils.doGet(HOST_UTL+"api/data/audio/list/jiaoyou");
+ jsonObject = JSON.parseObject(response).getJSONObject("data");
+ Map> map = jsonObject.toJavaObject(Map.class);
+ if (map != null && map.size() != 0) {
+ List jiaoyouList = map.get("jiaoyou-audio-adult-test");
+ if (!CollectionUtils.isEmpty(jiaoyouList)) map.get("jiaoyou-audio-adult-test").add("遇见伽利略");
+ List xiaoaiJiaoyouList = map.get("xiaoai-jiaoyou-audio-adult-test");
+ if (!CollectionUtils.isEmpty(xiaoaiJiaoyouList)) map.get("xiaoai-jiaoyou-audio-adult-test").add("遇见伽利略");
+ jiaoyouChannel2Bots = map;
+ success = true;
+ } else {
+ log.info("getChannelAllBots failed count="+count);
+ Thread.sleep(count*5);
+ }
+ } catch (Exception e) {
+ log.warn("getChannelAllBots: "+e);
}
- } catch (Exception e) {
- log.warn("getChannelAllBots: "+e);
- }
- count++;
- } while (!success && count < 5);
- log.info("getChannelAllBots:"+jiaoyouChannel2Bots);
+ count++;
+ } while (!success && count < 5);
+ log.info("getChannelAllBots:"+jiaoyouChannel2Bots);
+ });
}
- static String getWorkNameByBotAccount(String botAccount) {
+ public static String getWorkNameByBotAccount(String botAccount) {
if (StringUtils.isNotBlank(botAccount)) {
ProjectData data = botAccount2Project.get(botAccount);
if (data != null) {
+ if (StringUtils.isNotBlank(data.getShowedWorkName())) {
+ return data.getShowedWorkName();
+ }
return data.getName();
}
}
return null;
}
- static String getBotAccountByWorkname(String workName) {
+ public static String getBotAccountByWorkname(String workName) {
if (StringUtils.isNotBlank(workName)) {
ProjectData data = name2Project.get(workName);
if (data != null) {
@@ -248,12 +276,16 @@ public class ScheduleServiceNew implements InitializingBean {
return null;
}
- static ProjectData getProjectByName(String name) {
+ public static ProjectData getProjectByName(String name) {
return name2Project.get(name);
}
- static ProjectData getProjectByBotAccount(String botAccount) {
- return botAccount2Project.get(botAccount);
+ public static ProjectData getProjectByBotAccount(String botAccount) {
+ ProjectData data = botAccount2Project.get(botAccount);
+ if (StringUtils.isNotBlank(data.getShowedWorkName())) {
+ return name2Project.get(data.getShowedWorkName());
+ }
+ return data;
}
public static List getTheChannelAllProjectData(String channel) {
@@ -284,6 +316,7 @@ public class ScheduleServiceNew implements InitializingBean {
public static String getTheChannelBotAccount(String channel) {
return channelId2RecommendBotAcc.get(channel);
+// return null;
}
public static void main(String[] args) throws IOException {
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/InitialData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/InitialData.java
index 6338ae9..a8475cf 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/InitialData.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/InitialData.java
@@ -27,10 +27,10 @@ import java.util.Map;
//@Component
@Slf4j
public class InitialData implements InitializingBean {
- @Value("${csvDic}")
+// @Value("${csvDic}")
private String csvDic;
- @Value("${csvChildDic}")
+// @Value("${csvChildDic}")
private String csvChildDic;
static volatile Map>> recordMap;
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/SpiritRedisService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/SpiritRedisService.java
index af61dac..78f6b46 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/SpiritRedisService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/SpiritRedisService.java
@@ -4,7 +4,6 @@ import ai.qiwu.com.xiaoduhome.common.Constants;
import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import ai.qiwu.com.xiaoduhome.common.Utils;
import ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil;
-import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
import ai.qiwu.com.xiaoduhome.xiaoai.common.RequestTerminal;
import ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants;
@@ -42,6 +41,8 @@ import java.util.stream.Collectors;
import static ai.qiwu.com.xiaoduhome.common.Constants.WelcomeWord.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.WelcomeWord.SKILL_DEFAULT;
+import static ai.qiwu.com.xiaoduhome.controller.XiaoDuHomeController.WELCOME_NOVEL;
+import static ai.qiwu.com.xiaoduhome.controller.XiaoDuHomeController.WELCOME_SMART;
import static ai.qiwu.com.xiaoduhome.spirit.InitialData.*;
import static ai.qiwu.com.xiaoduhome.spirit.InitialData.botAccount2ItsCache;
import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.ERROR_MSG.SORRY_REPEAT;
@@ -53,10 +54,10 @@ import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.ERROR_MSG.SOR
@Service
@Slf4j
public class SpiritRedisService {
- @Value("${csvDic}")
+// @Value("${csvDic}")
private String csvDic;
- @Value("${csvChildDic}")
+// @Value("${csvChildDic}")
private String csvChildDic;
// public static volatile Integer mark = 1;
@@ -149,15 +150,15 @@ public class SpiritRedisService {
if (Boolean.TRUE.equals(stringRedisTemplate.hasKey(redisId))) {
String data = stringRedisTemplate.opsForValue().get(redisId);
String redisIdleId = PREFIX_REDIS_IDLE+userId;
- if (data !=null && data.equals("out")) {
+ if ("out".equals(data)) {
String idleNum = stringRedisTemplate.opsForValue().get(redisIdleId);
boolean firstIdle;
- if ((firstIdle = StringUtils.isBlank(idleNum)) || idleNum.equals("1")) {
+ if ((firstIdle = StringUtils.isBlank(idleNum)) || "1".equals(idleNum)) {
try {
Thread.sleep(1000);
} catch (Exception e){}
data = stringRedisTemplate.opsForValue().get(redisId);
- if (StringUtils.isNotBlank(data) && !data.equals("out")) {
+ if (StringUtils.isNotBlank(data) && !"out".equals(data)) {
stringRedisTemplate.delete(redisIdleId);
stringRedisTemplate.delete(redisId);
return buildAudioTaskResult(Arrays.asList(data.split(",")), intentId);
@@ -238,7 +239,7 @@ public class SpiritRedisService {
if (resStr == null) {
return null;
}
- log.info("天猫精灵晓悟返回:"+resStr);
+// log.info("天猫精灵晓悟返回:"+resStr);
TaskResult taskResult = null;
try {
JSONObject object = JSON.parseObject(resStr);
@@ -250,7 +251,7 @@ public class SpiritRedisService {
txt = ((JSONObject) ob).getString("text");
int i;
if (StringUtils.isNotBlank(txt) && (i=txt.indexOf("out")) != -1) {
- log.info("天猫,推荐bot退出:{},{}",userWord,userId);
+// log.info("天猫,推荐bot退出:{},{}",userWord,userId);
String content = txt.substring(i+3, txt.indexOf("☚")).trim();
String byeWord = null;
String skillName = null;
@@ -325,7 +326,7 @@ public class SpiritRedisService {
// }
// }
String path = OkHttp3Utils.doPostJsonStr(audioUrl+"/api/audio", resStr);
- if (StringUtils.isBlank(path) || path.equals("null")) {
+ if (StringUtils.isBlank(path) || "null".equals(path)) {
log.error("没有获取到TTS返回的路径path");
return buildTextTaskResult(SORRY_REPEAT,intentId);
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/SpiritService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/SpiritService.java
index c542174..7af15f8 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/SpiritService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/spirit/SpiritService.java
@@ -43,10 +43,10 @@ import static ai.qiwu.com.xiaoduhome.xiaoai.service.XiaoAiService.OUTTIME_TYPE_0
@Slf4j
public class SpiritService {
- @Value("${csvDic}")
+// @Value("${csvDic}")
private String csvDic;
- @Value("${csvChildDic}")
+// @Value("${csvChildDic}")
private String csvChildDic;
private static final String AB_REGEX = "\uD83C\uDD70(.*?)\uD83C\uDD71";
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiService.java
index 4061db1..ce13247 100755
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiService.java
@@ -2,6 +2,7 @@ package ai.qiwu.com.xiaoduhome.xiaoai.service;
import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil;
+import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
import ai.qiwu.com.xiaoduhome.xiaoai.common.*;
import ai.qiwu.com.xiaoduhome.xiaoai.model.request.XiaoAiRequest;
import ai.qiwu.com.xiaoduhome.xiaoai.model.response.XiaoAiResponse;
@@ -18,19 +19,15 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
-import java.io.File;
import java.net.URLEncoder;
import java.util.*;
import java.util.concurrent.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.WelcomeWord.*;
-import static ai.qiwu.com.xiaoduhome.service.ScheduleService.channel2Bots;
-import static ai.qiwu.com.xiaoduhome.service.ScheduleService.jiaoyouChannel2Bots;
+import static ai.qiwu.com.xiaoduhome.controller.XiaoDuHomeController.*;
import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.ERROR_MSG.SORRY_REPEAT;
import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.PREFIX_USERID;
import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.TTS.WAIT_WORD_3;
@@ -283,7 +280,7 @@ public class XiaoAiService {
case 5 : {
welcomeWord = WELCOME_FORMAT;
try {
- List botList = jiaoyouChannel2Bots.get("xiaoai-jiaoyou-audio-adult-test");
+ List botList = ScheduleServiceNew.jiaoyouChannel2Bots.get("xiaoai-jiaoyou-audio-adult-test");
String name = botList.get(Integer.parseInt(num)%botList.size());
welcomeWord = String.format(welcomeWord, name,name);
} catch (Exception e) {
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiServiceRedis.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiServiceRedis.java
index 042284d..72c783b 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiServiceRedis.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiServiceRedis.java
@@ -34,7 +34,7 @@ import java.util.List;
import java.util.concurrent.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.WelcomeWord.*;
-import static ai.qiwu.com.xiaoduhome.service.ScheduleService.jiaoyouChannel2Bots;
+import static ai.qiwu.com.xiaoduhome.controller.XiaoDuHomeController.*;
import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.ERROR_MSG.SORRY_REPEAT;
import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.PREFIX_USERID;
import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.TTS.WELCOME_WORD_DEFAULT;
@@ -258,10 +258,10 @@ public class XiaoAiServiceRedis {
log.info("超时redis获取信息:"+data);
if (StringUtils.isNotBlank(data)) {
String redisIdleId = SpiritRedisService.PREFIX_REDIS_IDLE+userId;
- if (data.equals("out")) {
+ if ("out".equals(data)) {
String idleNum = stringRedisTemplate.opsForValue().get(redisIdleId);
boolean firstIdle;
- if ((firstIdle = StringUtils.isBlank(idleNum)) || idleNum.equals("1")) {
+ if ((firstIdle = StringUtils.isBlank(idleNum)) || "1".equals(idleNum)) {
try {
Thread.sleep(1500);
} catch (Exception e){}
@@ -370,9 +370,7 @@ public class XiaoAiServiceRedis {
if (userId == null) {
userId = request.getContext().getDevice_id();
if (userId != null) userId = Utils.modifyDeviceId(userId);
- }
- if (userId == null) {
- userId = Utils.useIPAsItsID();
+ else userId = Utils.useIPAsItsID();
}
try {
return PREFIX_USERID+ URLEncoder.encode(userId, "UTF-8");
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiTestService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiTestService.java
index 5220933..1536269 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiTestService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiTestService.java
@@ -3,7 +3,6 @@ package ai.qiwu.com.xiaoduhome.xiaoai.service;
import ai.qiwu.com.xiaoduhome.common.Constants;
import ai.qiwu.com.xiaoduhome.common.OkHttp3Utils;
import ai.qiwu.com.xiaoduhome.service.DplbotServiceUtil;
-import ai.qiwu.com.xiaoduhome.service.ScheduleService;
import ai.qiwu.com.xiaoduhome.service.ScheduleServiceNew;
import ai.qiwu.com.xiaoduhome.xiaoai.common.RequestTerminal;
import ai.qiwu.com.xiaoduhome.xiaoai.common.RequestWordNullException;
@@ -40,12 +39,9 @@ import java.util.concurrent.*;
import static ai.qiwu.com.xiaoduhome.common.Constants.TTS_DIDI3_GET_XIAOAI;
import static ai.qiwu.com.xiaoduhome.common.Constants.TTS_DIDI4_GET_XIAOAI;
import static ai.qiwu.com.xiaoduhome.common.Constants.WelcomeWord.*;
-import static ai.qiwu.com.xiaoduhome.service.ScheduleService.channel2Bots;
-import static ai.qiwu.com.xiaoduhome.service.ScheduleService.jiaoyouChannel2Bots;
import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.ERROR_MSG.SORRY_REPEAT;
import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.PREFIX_USERID;
import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.TTS.WAIT_WORD_3;
-import static ai.qiwu.com.xiaoduhome.xiaoai.common.XiaoAiConstants.TTS.WELCOME_WORD_DEFAULT;
/**
* @author 苗权威
@@ -361,65 +357,6 @@ public class XiaoAiTestService {
}
/**
- * 处理启动意图,返回欢迎语
- * @param request 请求信息
- * @return 响应信息
- */
- private XiaoAiResponse dealWithLaunchRequest(XiaoAiRequest request) {
-// if (deviceId == null) {
-// deviceId = getUserId(request);
-// log.info("didi-gz3 deviceId:"+deviceId);
-// }
- LAST_OUTTIME_RESULT.remove(getUserId(request));
- LAST_OUTTIME_MARK.remove(getUserId(request));
-// LAST_AUDIO_PLAY.remove(getUserId(request));
-
- String welcomeWord = null;
- String num = RandomStringUtils.randomNumeric(3);
- Integer type = request.getType();
- switch (type) {
- case 1 : {
- welcomeWord = WELCOME_SMART_FORMAT_AI;
- try {
- List botList = channel2Bots.get("xiaoai-jiaoyou-audio-child-test");
- String name = botList.get(Integer.parseInt(num)%botList.size());
- welcomeWord = String.format(welcomeWord, name,name);
- } catch (Exception e) {
- log.error("onLaunch welcomeWord type:{}, error:{}", type, e);
- welcomeWord = WELCOME_SMART;
- }
- break;
- }
- case 2 : {
- welcomeWord = WELCOME_NOVEL_FORMAT;
- try {
- List botList = channel2Bots.get("xiaoai-jiaoyou-audio-adult-test");
- String name = botList.get(Integer.parseInt(num)%botList.size());
- welcomeWord = String.format(welcomeWord, name,name);
- } catch (Exception e) {
- log.error("onLaunch welcomeWord type:{}, error:{}", type, e);
- welcomeWord = WELCOME_NOVEL;
- }
- break;
- }
- case 5 : {
- welcomeWord = WELCOME_FORMAT;
- try {
- List