Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
search
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
search
Commits
3558e93f
Commit
3558e93f
authored
Aug 19, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
56674fac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
24 deletions
+30
-24
HouseCollectTask.java
...va/com/egolm/search/schedules/house/HouseCollectTask.java
+23
-23
application.yml
src/main/resources/application.yml
+7
-1
No files found.
src/main/java/com/egolm/search/schedules/house/HouseCollectTask.java
View file @
3558e93f
package
com
.
egolm
.
search
.
schedules
.
house
;
import
java.io.InputStream
;
import
java.util.Date
;
import
java.util.stream.Collectors
;
import
javax.annotation.PostConstruct
;
import
org.apache.solr.client.solrj.impl.HttpSolrClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.Resource
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -33,6 +32,27 @@ public class HouseCollectTask extends AbstractSolrApi{
@Value
(
"${solr.house.offset-minute-for-minute}"
)
private
Long
offsetMinuteForMinute
;
@Value
(
"${sql.house.create-index-query}"
)
private
String
createIndexQueryFilePath
;
@Value
(
"${sql.house.delete-index-query}"
)
private
String
deleteIndexQueryFilePath
;
@Value
(
"${sql.house.update-index-query}"
)
private
String
updateIndexQueryFilePath
;
private
String
createIndexQuerySql
;
private
String
updateIndexQuerySql
;
private
String
deleteIndexQuerySql
;
@PostConstruct
public
void
init
()
{
createIndexQuerySql
=
FileUtil
.
fileToString
(
createIndexQueryFilePath
);
updateIndexQuerySql
=
FileUtil
.
fileToString
(
deleteIndexQueryFilePath
);
deleteIndexQuerySql
=
FileUtil
.
fileToString
(
updateIndexQueryFilePath
);
}
@Scheduled
(
cron
=
"${solr.house.cron-for-day}"
)
public
void
dayExecute
()
{
Date
date
=
new
Date
(
System
.
currentTimeMillis
()
-
(
offsetMinuteForDay
*
60L
*
1000L
));
...
...
@@ -59,25 +79,5 @@ public class HouseCollectTask extends AbstractSolrApi{
public
HttpSolrClient
getSolrClient
()
{
return
solrClient
;
}
static
{
try
{
Resource
createIndexQuerySqlResource
=
new
ClassPathResource
(
"sql/house/create-index-query.sql"
);
Resource
updateIndexQuerySqlResource
=
new
ClassPathResource
(
"sql/house/update-index-query.sql"
);
Resource
deleteIndexQuerySqlResource
=
new
ClassPathResource
(
"sql/house/delete-index-query.sql"
);
InputStream
createIndexQuerySqlStream
=
createIndexQuerySqlResource
.
getInputStream
();
InputStream
updateIndexQuerySqlStream
=
updateIndexQuerySqlResource
.
getInputStream
();
InputStream
deleteIndexQuerySqlStream
=
deleteIndexQuerySqlResource
.
getInputStream
();
createIndexQuerySql
=
new
String
(
FileUtil
.
streamToBytes
(
createIndexQuerySqlStream
));
updateIndexQuerySql
=
new
String
(
FileUtil
.
streamToBytes
(
updateIndexQuerySqlStream
));
deleteIndexQuerySql
=
new
String
(
FileUtil
.
streamToBytes
(
deleteIndexQuerySqlStream
));
}
catch
(
Throwable
e
)
{
throw
new
RuntimeException
(
"索引更新查询[SQL]加载错误"
,
e
);
}
}
private
static
final
String
createIndexQuerySql
;
private
static
final
String
updateIndexQuerySql
;
private
static
final
String
deleteIndexQuerySql
;
}
src/main/resources/application.yml
View file @
3558e93f
...
...
@@ -2,4 +2,10 @@ server:
port
:
9090
spring
:
profiles
:
active
:
dev
\ No newline at end of file
active
:
dev
sql.house
:
create-index-query
:
sql/house/create-index-query.sql
delete-index-query
:
sql/house/delete-index-query.sql
update-index-query
:
sql/house/update-index-query.sql
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment