Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
pdstask
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
曲欣亮
pdstask
Commits
ec131bc9
Commit
ec131bc9
authored
Jul 09, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parents
Pipeline
#146
canceled with stages
Changes
14
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
709 additions
and
0 deletions
+709
-0
.gitignore
.gitignore
+6
-0
pom.xml
pom.xml
+101
-0
PDSApplication.java
src/main/java/com/egolm/pds/PDSApplication.java
+42
-0
DataSourceConfig.java
src/main/java/com/egolm/pds/config/DataSourceConfig.java
+44
-0
HttpUtil.java
src/main/java/com/egolm/pds/config/HttpUtil.java
+190
-0
PdsProductsUpdateTask.java
...in/java/com/egolm/pds/schedule/PdsProductsUpdateTask.java
+106
-0
TestController.java
src/main/java/com/egolm/pds/schedule/TestController.java
+43
-0
PdsService.java
src/main/java/com/egolm/pds/schedule/service/PdsService.java
+58
-0
.gitignore
src/main/resources/.gitignore
+1
-0
application-dev.yml
src/main/resources/application-dev.yml
+28
-0
application-pro.yml
src/main/resources/application-pro.yml
+29
-0
application.yml
src/main/resources/application.yml
+6
-0
log4j.properties
src/main/resources/log4j.properties
+4
-0
logback.xml
src/main/resources/logback.xml
+51
-0
No files found.
.gitignore
0 → 100644
View file @
ec131bc9
/target/
/.settings/
/.classpath
/.project
/application.properties
/bin/
pom.xml
0 → 100644
View file @
ec131bc9
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.egolm
</groupId>
<artifactId>
pdstask
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<properties>
<start-class>
com.egolm.sso.SSOApplication
</start-class>
</properties>
<parent>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-parent
</artifactId>
<version>
2.1.0.RELEASE
</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.cloud
</groupId>
<artifactId>
spring-cloud-dependencies
</artifactId>
<version>
Finchley.SR2
</version>
<type>
pom
</type>
<scope>
import
</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-web
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-jdbc
</artifactId>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-devtools
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
<version>
1.2.38
</version>
</dependency>
<dependency>
<groupId>
com.alibaba
</groupId>
<artifactId>
druid
</artifactId>
<version>
1.1.17
</version>
</dependency>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
</dependency>
<dependency>
<groupId>
com.microsoft.sqlserver
</groupId>
<artifactId>
mssql-jdbc
</artifactId>
</dependency>
<dependency>
<groupId>
com.egolm
</groupId>
<artifactId>
common
</artifactId>
<version>
0.0.1-RELEASE
</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<artifactId>
maven-compiler-plugin
</artifactId>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
</configuration>
</plugin>
<plugin>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-maven-plugin
</artifactId>
<configuration>
<mainClass>
${start-class}
</mainClass>
<layout>
ZIP
</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>
repackage
</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
src/main/java/com/egolm/pds/PDSApplication.java
0 → 100644
View file @
ec131bc9
package
com
.
egolm
.
pds
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration
;
import
org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoConfiguration
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
@EnableScheduling
@EnableTransactionManagement
@SpringBootApplication
(
exclude
={
RedisAutoConfiguration
.
class
,
RedisRepositoriesAutoConfiguration
.
class
})
public
class
PDSApplication
{
private
static
ApplicationContext
applicationContext
;
public
static
void
main
(
String
[]
args
)
{
applicationContext
=
SpringApplication
.
run
(
PDSApplication
.
class
,
args
);
}
public
static
ApplicationContext
getApplicationContext
()
{
return
applicationContext
;
}
public
static
Object
getBean
(
String
name
){
return
getApplicationContext
().
getBean
(
name
);
}
public
static
<
T
>
T
getBean
(
Class
<
T
>
clazz
){
return
getApplicationContext
().
getBean
(
clazz
);
}
public
static
<
T
>
T
getBean
(
String
name
,
Class
<
T
>
clazz
){
return
getApplicationContext
().
getBean
(
name
,
clazz
);
}
}
src/main/java/com/egolm/pds/config/DataSourceConfig.java
0 → 100644
View file @
ec131bc9
package
com
.
egolm
.
pds
.
config
;
import
javax.sql.DataSource
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.boot.jdbc.DataSourceBuilder
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Primary
;
import
org.springframework.jdbc.datasource.DataSourceTransactionManager
;
import
org.springframework.transaction.PlatformTransactionManager
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.common.jdbc.dialect.SqlServerDialect
;
@Configuration
public
class
DataSourceConfig
{
@Bean
@Primary
@ConfigurationProperties
(
prefix
=
"spring.datasource"
)
public
DataSource
getDataSource
()
{
return
DataSourceBuilder
.
create
().
type
(
DruidDataSource
.
class
).
build
();
}
@Bean
@Primary
public
PlatformTransactionManager
getTransactionManager
(
DataSource
dataSource
)
{
return
new
DataSourceTransactionManager
(
dataSource
);
}
@Bean
@Primary
public
JdbcTemplate
getJdbcTemplate
(
DataSource
dataSource
)
{
JdbcTemplate
jdbcTemplate
=
new
JdbcTemplate
();
jdbcTemplate
.
setDataSource
(
dataSource
);
jdbcTemplate
.
setDialect
(
new
SqlServerDialect
());
jdbcTemplate
.
setSql_level
(
3
);
return
jdbcTemplate
;
}
}
\ No newline at end of file
src/main/java/com/egolm/pds/config/HttpUtil.java
0 → 100644
View file @
ec131bc9
package
com
.
egolm
.
pds
.
config
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
import
com.egolm.common.FileUtil
;
public
class
HttpUtil
{
public
static
String
get
(
String
requestUrl
,
Map
<
String
,
String
>
headers
)
{
HttpURLConnection
connection
=
null
;
try
{
URL
getUrl
=
new
URL
(
requestUrl
);
connection
=
(
HttpURLConnection
)
getUrl
.
openConnection
();
connection
.
setRequestMethod
(
"GET"
);
connection
.
setRequestProperty
(
"Accept-Charset"
,
"utf-8"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
if
(
headers
!=
null
)
{
for
(
String
key
:
headers
.
keySet
())
{
connection
.
setRequestProperty
(
key
,
headers
.
get
(
key
));
}
}
connection
.
connect
();
return
responseBody
(
connection
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
connection
.
disconnect
();
}
}
private
static
String
responseBody
(
HttpURLConnection
connection
)
{
try
{
byte
[]
bytes
=
FileUtil
.
streamToBytes
(
connection
.
getInputStream
());
String
strHtml
=
null
;
Map
<
String
,
List
<
String
>>
responseHeaders
=
connection
.
getHeaderFields
();
List
<
String
>
contentTypes
=
responseHeaders
.
get
(
"Content-Type"
);
String
responseCharsetName
=
null
;
String
contentType
=
(
contentTypes
!=
null
&&
contentTypes
.
size
()
>
0
)
?
contentTypes
.
get
(
0
)
:
""
;
String
[]
typeArray
=
contentType
.
split
(
";"
);
for
(
String
type
:
typeArray
)
{
if
(
type
.
startsWith
(
"charset="
))
{
responseCharsetName
=
type
.
split
(
"="
,
2
)[
1
];
}
else
if
(
type
.
startsWith
(
"encoding="
))
{
responseCharsetName
=
type
.
split
(
"="
,
2
)[
1
];
}
}
if
(
responseCharsetName
==
null
||
responseCharsetName
.
trim
().
length
()
==
0
)
{
strHtml
=
new
String
(
bytes
,
"utf-8"
);
String
regex
=
"charset=([^\"'>]+)"
;
Pattern
pattern
=
Pattern
.
compile
(
regex
);
Matcher
matcher
=
pattern
.
matcher
(
strHtml
);
while
(
matcher
.
find
())
{
String
metaCharsetName
=
matcher
.
group
(
1
);
if
(
metaCharsetName
!=
null
&&
metaCharsetName
.
trim
().
length
()
!=
0
)
{
responseCharsetName
=
metaCharsetName
;
}
}
}
if
(
responseCharsetName
==
null
||
responseCharsetName
.
trim
().
length
()
==
0
)
{
return
strHtml
;
}
else
{
return
new
String
(
bytes
,
responseCharsetName
);
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
static
String
post
(
String
requestUrl
,
Map
<
String
,
String
>
parameters
,
Map
<
String
,
String
>
headers
)
{
return
post
(
requestUrl
,
parameters
,
headers
,
null
);
}
public
static
String
post
(
String
requestUrl
,
Map
<
String
,
String
>
parameters
,
Map
<
String
,
String
>
headers
,
Map
<
String
,
File
>
attachments
)
{
HttpURLConnection
connection
=
null
;
try
{
Data
data
=
new
Data
();
String
BOUNDARY
=
"----WebKitFormBoundaryT1HoybnYeFOGFlBR"
;
StringBuffer
ParamBuffer
=
new
StringBuffer
();
if
(
parameters
!=
null
)
{
for
(
String
key
:
parameters
.
keySet
())
{
ParamBuffer
.
append
(
"--"
+
BOUNDARY
+
"\r\n"
);
ParamBuffer
.
append
(
"Content-Disposition: form-data; name=\""
+
key
+
"\"\r\n"
);
ParamBuffer
.
append
(
"\r\n"
);
ParamBuffer
.
append
(
parameters
.
get
(
key
)
+
"\r\n"
);
}
}
ParamBuffer
.
append
(
"--"
+
BOUNDARY
+
"\r\nContent-Disposition: form-data; name=\"----------------------------------\"\r\n\r\n-------------------------\r\n"
);
String
ParamBufferString
=
ParamBuffer
.
toString
();
data
.
add
(
ParamBufferString
.
getBytes
());
if
(
attachments
!=
null
)
{
for
(
String
name
:
attachments
.
keySet
())
{
StringBuffer
FileBuffer
=
new
StringBuffer
();
File
file
=
attachments
.
get
(
name
);
FileBuffer
.
append
(
"--"
+
BOUNDARY
+
"\r\n"
);
FileBuffer
.
append
(
"Content-Disposition: form-data; name=\""
+
name
+
"\"; filename=\""
+
file
.
getName
()
+
"\""
+
"\r\n"
);
FileBuffer
.
append
(
"Content-Type: application/octet-stream"
+
"\r\n"
);
FileBuffer
.
append
(
"\r\n"
);
String
FileBufferString
=
FileBuffer
.
toString
();
data
.
add
(
FileBufferString
.
getBytes
());
data
.
add
(
file
);
String
FileEnd
=
"\r\n"
;
data
.
add
(
FileEnd
.
getBytes
());
}
}
StringBuffer
EndBuffer
=
new
StringBuffer
(
"\r\n--"
+
BOUNDARY
+
"--\r\n"
);
String
EndBufferString
=
EndBuffer
.
toString
();
data
.
add
(
EndBufferString
.
getBytes
());
URL
url
=
new
URL
(
requestUrl
);
connection
=
(
HttpURLConnection
)
url
.
openConnection
();
connection
.
setRequestMethod
(
"POST"
);
connection
.
setRequestProperty
(
"Accept-Charset"
,
"utf-8"
);
connection
.
setRequestProperty
(
"Content-Type"
,
"multipart/form-data; boundary="
+
BOUNDARY
);
connection
.
setRequestProperty
(
"Content-Length"
,
String
.
valueOf
(
data
.
length
()));
if
(
headers
!=
null
)
{
for
(
String
key
:
headers
.
keySet
())
{
connection
.
setRequestProperty
(
key
,
headers
.
get
(
key
));
}
}
connection
.
setDoOutput
(
true
);
OutputStream
out
=
connection
.
getOutputStream
();
out
.
write
(
data
.
bytes
());
out
.
close
();
return
responseBody
(
connection
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
finally
{
connection
.
disconnect
();
}
}
public
static
class
Data
{
private
byte
[][]
ds
=
new
byte
[
0
][
0
];
public
void
add
(
File
file
)
throws
IOException
{
FileInputStream
fis
=
new
FileInputStream
(
file
);
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
(
1000
);
byte
[]
b
=
new
byte
[
1000
];
int
n
;
while
((
n
=
fis
.
read
(
b
))
!=
-
1
)
{
bos
.
write
(
b
,
0
,
n
);
}
fis
.
close
();
bos
.
close
();
add
(
bos
.
toByteArray
());
}
public
void
add
(
byte
[]
data
)
{
int
length
=
ds
.
length
;
byte
[][]
ds_tmp
=
new
byte
[
length
+
1
][];
for
(
int
i
=
0
;
i
<
length
;
i
++)
{
ds_tmp
[
i
]
=
ds
[
i
];
}
ds_tmp
[
length
]
=
data
;
ds
=
ds_tmp
;
}
public
int
length
()
{
int
length
=
0
;
for
(
byte
[]
b
:
ds
)
{
length
+=
b
.
length
;
}
return
length
;
}
public
byte
[]
bytes
()
{
byte
[]
bytes
=
new
byte
[
length
()];
int
index
=
0
;
for
(
int
i
=
0
;
i
<
ds
.
length
;
i
++)
{
for
(
int
k
=
0
;
k
<
ds
[
i
].
length
;
k
++)
{
bytes
[
index
++]
=
ds
[
i
][
k
];
}
}
return
bytes
;
}
}
}
src/main/java/com/egolm/pds/schedule/PdsProductsUpdateTask.java
0 → 100644
View file @
ec131bc9
package
com
.
egolm
.
pds
.
schedule
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.egolm.pds.config.HttpUtil
;
import
com.egolm.pds.schedule.service.PdsService
;
@Component
public
class
PdsProductsUpdateTask
{
@Autowired
private
PdsService
pdsService
;
@Value
(
"${pds.url_update}"
)
private
String
urlUpdate
;
@Value
(
"${pds.auth_key}"
)
private
String
authKey
;
@Value
(
"${pds.auth_value}"
)
private
String
authValue
;
@Value
(
"${pds.url_query}"
)
private
String
urlQuery
;
@Scheduled
(
cron
=
"${pds.cron.products_download}"
)
public
void
execute
()
{
boolean
boo
=
true
;
int
loopCount
=
0
;
while
(
boo
)
{
boo
=
executeUpdateTask
()
>
0
&&
loopCount
++
<
10
;
}
}
private
int
executeUpdateTask
()
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
authKey
,
authValue
);
String
responseBody
=
HttpUtil
.
get
(
urlQuery
,
headers
);
System
.
out
.
println
(
"headers"
+
JSON
.
toJSONString
(
headers
));
System
.
out
.
println
(
responseBody
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
responseBody
);
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"data"
);
if
(
jsonArray
!=
null
)
{
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
JSONObject
productJsonObject
=
jsonArray
.
getJSONObject
(
i
);
String
article_description
=
productJsonObject
.
getString
(
"article_description"
);
String
article_group_no
=
productJsonObject
.
getString
(
"article_group_no"
);
String
article_short_description
=
productJsonObject
.
getString
(
"article_short_description"
);
String
article_type
=
productJsonObject
.
getString
(
"article_type"
);
String
barcode
=
productJsonObject
.
getString
(
"barcode"
);
String
buying_price
=
productJsonObject
.
getString
(
"buying_price"
);
String
buying_price_with_tax
=
productJsonObject
.
getString
(
"buying_price_with_tax"
);
Integer
case_qty
=
productJsonObject
.
getInteger
(
"case_qty"
);
String
deduction
=
productJsonObject
.
getString
(
"deduction"
);
String
made_in
=
productJsonObject
.
getString
(
"made_in"
);
String
order_way
=
productJsonObject
.
getString
(
"order_way"
);
String
pack_unit
=
productJsonObject
.
getString
(
"pack_unit"
);
String
selling_price
=
productJsonObject
.
getString
(
"selling_price"
);
String
specification
=
productJsonObject
.
getString
(
"specification"
);
String
stores
=
productJsonObject
.
getString
(
"stores"
);
String
supplier_article_no
=
productJsonObject
.
getString
(
"supplier_article_no"
);
String
supplier_no
=
productJsonObject
.
getString
(
"supplier_no"
);
String
tax_rate
=
productJsonObject
.
getString
(
"tax_rate"
);
String
trade_mode
=
productJsonObject
.
getString
(
"trade_mode"
);
String
weight_article
=
productJsonObject
.
getString
(
"weight_article"
);
Object
transactionId
=
productJsonObject
.
get
(
"transaction_id"
);
Map
<
String
,
Object
>
productMap
=
new
HashMap
<
String
,
Object
>();
productMap
.
put
(
"article_description"
,
article_description
);
productMap
.
put
(
"article_group_no"
,
article_group_no
);
productMap
.
put
(
"article_short_description"
,
article_short_description
);
productMap
.
put
(
"article_type"
,
article_type
);
productMap
.
put
(
"barcode"
,
barcode
);
productMap
.
put
(
"buying_price"
,
buying_price
);
productMap
.
put
(
"buying_price_with_tax"
,
buying_price_with_tax
);
productMap
.
put
(
"case_qty"
,
case_qty
);
productMap
.
put
(
"deduction"
,
deduction
);
productMap
.
put
(
"made_in"
,
made_in
);
productMap
.
put
(
"order_way"
,
order_way
);
productMap
.
put
(
"pack_unit"
,
pack_unit
);
productMap
.
put
(
"selling_price"
,
selling_price
);
productMap
.
put
(
"specification"
,
specification
);
productMap
.
put
(
"stores"
,
stores
);
productMap
.
put
(
"supplier_article_no"
,
supplier_article_no
);
productMap
.
put
(
"supplier_no"
,
supplier_no
);
productMap
.
put
(
"tax_rate"
,
tax_rate
);
productMap
.
put
(
"trade_mode"
,
trade_mode
);
productMap
.
put
(
"weight_article"
,
weight_article
);
productMap
.
put
(
"dLastUpdateTime"
,
new
Date
());
pdsService
.
savePdsProduct
(
transactionId
,
productMap
);
}
}
return
jsonArray
==
null
?
0
:
jsonArray
.
size
();
}
}
src/main/java/com/egolm/pds/schedule/TestController.java
0 → 100644
View file @
ec131bc9
package
com
.
egolm
.
pds
.
schedule
;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
public
class
TestController
{
@Value
(
"${spring.profiles.active}"
)
private
String
profiles
;
@Autowired
private
PdsProductsUpdateTask
task
;
@RequestMapping
(
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
String
list
(
HttpServletRequest
request
)
{
Map
<
String
,
String
>
map
=
new
LinkedHashMap
<
String
,
String
>();
map
.
put
(
"/"
,
"接口列表"
);
map
.
put
(
"/executeProductDownload"
,
"下载商品数据"
);
StringBuffer
sb
=
new
StringBuffer
();
for
(
String
key
:
map
.
keySet
())
{
sb
.
append
(
"<A HREF=\""
+
key
+
"\">"
+
map
.
get
(
key
)
+
"</A>"
).
append
(
"<BR/>\n"
);
}
String
html
=
"<HTML>\n"
+
sb
.
toString
()
+
"</HTML>"
;
return
html
;
}
@RequestMapping
(
value
=
{
"/executeProductDownload"
},
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
public
String
executeProductDownload
()
{
task
.
execute
();
return
"OK"
;
}
}
src/main/java/com/egolm/pds/schedule/service/PdsService.java
0 → 100644
View file @
ec131bc9
package
com
.
egolm
.
pds
.
schedule
.
service
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Component
;
import
org.springframework.transaction.annotation.Transactional
;
import
com.egolm.common.jdbc.JdbcTemplate
;
import
com.egolm.pds.config.HttpUtil
;
@Component
public
class
PdsService
{
@Autowired
private
JdbcTemplate
jdbcTemplate
;
@Value
(
"pds.url_update"
)
private
String
urlUpdate
;
@Value
(
"pds.auth_key"
)
private
String
authKey
;
@Value
(
"pds.auth_value"
)
private
String
authValue
;
@Value
(
"pds.is_execute_confirm"
)
private
String
isExecuteConfirmString
;
@Transactional
public
void
savePdsProduct
(
Object
transactionId
,
Map
<
String
,
Object
>
productMap
)
{
jdbcTemplate
.
save
(
"pds_article"
,
productMap
);
Boolean
isExecuteConfirm
=
false
;
try
{
isExecuteConfirm
=
Boolean
.
valueOf
(
isExecuteConfirmString
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
isExecuteConfirm
!=
null
&&
isExecuteConfirm
)
{
Map
<
String
,
String
>
parameters
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
authKey
,
authValue
);
parameters
.
put
(
"transaction_id"
,
transactionId
==
null
?
null
:
transactionId
.
toString
());
HttpUtil
.
post
(
urlUpdate
,
parameters
,
headers
);
}
}
public
JdbcTemplate
getJdbcTemplate
()
{
return
jdbcTemplate
;
}
public
void
setJdbcTemplate
(
JdbcTemplate
jdbcTemplate
)
{
this
.
jdbcTemplate
=
jdbcTemplate
;
}
}
src/main/resources/.gitignore
0 → 100644
View file @
ec131bc9
/application.properties
src/main/resources/application-dev.yml
0 → 100644
View file @
ec131bc9
spring
:
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
driverClassName
:
com.microsoft.sqlserver.jdbc.SQLServerDriver
url
:
jdbc:sqlserver://10.10.0.22:1433;DatabaseName=LDEVHOADB
username
:
ERP
password
:
qiyang@2013
maxActive
:
20
initialSize
:
1
maxWait
:
60000
minIdle
:
1
timeBetweenEvictionRunsMillis
:
60000
minEvictableIdleTimeMillis
:
300000
validationQuery
:
SELECT 1
testWhileIdle
:
true
testOnBorrow
:
true
testOnReturn
:
true
poolPreparedStatements
:
true
maxOpenPreparedStatements
:
20
pds
:
cron
:
products_download
:
0 0 3 * * ?
is_execute_confirm
:
true
auth_key
:
x-api-key
auth_value
:
gPmsTNthxi5krwOTnaM9y5AhXlHrc6Ve5ik2GzQg
url_query
:
https://pztafj5g87.execute-api.ap-southeast-1.amazonaws.com/test/sunshine/new_products_with_prices
url_update
:
https://pztafj5g87.execute-api.ap-southeast-1.amazonaws.com/test/sunshine/confirm
\ No newline at end of file
src/main/resources/application-pro.yml
0 → 100644
View file @
ec131bc9
spring
:
datasource
:
type
:
com.alibaba.druid.pool.DruidDataSource
driverClassName
:
com.microsoft.sqlserver.jdbc.SQLServerDriver
url
:
jdbc:sqlserver://103.253.14.132:51410;instanceName=SQLSERVER;DatabaseName=HQHOADB
username
:
ERP
password
:
qiyang@2013
maxActive
:
20
initialSize
:
1
maxWait
:
60000
minIdle
:
1
timeBetweenEvictionRunsMillis
:
60000
minEvictableIdleTimeMillis
:
300000
validationQuery
:
SELECT 1
testWhileIdle
:
true
testOnBorrow
:
true
testOnReturn
:
true
poolPreparedStatements
:
true
maxOpenPreparedStatements
:
20
pds
:
cron
:
products_download
:
0 0 3 * * ?
is_execute_confirm
:
true
auth_key
:
x-api-key
auth_value
:
gPmsTNthxi5krwOTnaM9y5AhXlHrc6Ve5ik2GzQg
url_query
:
https://api.goodsmaster.com/v0/inbox/new_products_with_prices
url_update
:
https://api.goodsmaster.com/v0/inbox/new_products_with_prices/confirm
\ No newline at end of file
src/main/resources/application.yml
0 → 100644
View file @
ec131bc9
server
:
port
:
8080
spring
:
profiles
:
active
:
dev
\ No newline at end of file
src/main/resources/log4j.properties
0 → 100644
View file @
ec131bc9
log4j.rootLogger
=
info,appender
log4j.appender.appender
=
org.apache.log4j.ConsoleAppender
log4j.appender.appender.layout
=
org.apache.log4j.TTCCLayout
\ No newline at end of file
src/main/resources/logback.xml
0 → 100644
View file @
ec131bc9
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<include
resource=
"org/springframework/boot/logging/logback/base.xml"
/>
<appender
name=
"siftingAppender"
class=
"ch.qos.logback.classic.sift.SiftingAppender"
>
<discriminator>
<key>
context
</key>
<DefaultValue>
logback
</DefaultValue>
</discriminator>
<sift>
<appender
name=
"rollingFileAppender"
class=
"ch.qos.logback.core.rolling.RollingFileAppender"
>
<rollingPolicy
class=
"ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<FileNamePattern>
/data/logs/pds/${context}-%d{yyyy-MM-dd}.log
</FileNamePattern>
<MaxHistory>
30
</MaxHistory>
</rollingPolicy>
<encoder
class=
"ch.qos.logback.classic.encoder.PatternLayoutEncoder"
>
<pattern>
${CONSOLE_LOG_PATTERN}
</pattern>
</encoder>
</appender>
</sift>
</appender>
<root
level=
"INFO"
>
<appender-ref
ref=
"siftingAppender"
/>
</root>
<springProfile
name=
"dev"
>
<root
level=
"INFO"
>
<appender-ref
ref=
"siftingAppender"
/>
</root>
</springProfile>
<springProfile
name=
"pro"
>
<root
level=
"INFO"
>
<appender-ref
ref=
"siftingAppender"
/>
</root>
</springProfile>
<logger
name=
"com.microsoft"
level=
"INFO"
/>
<logger
name=
"com.alibaba"
level=
"INFO"
/>
<logger
name=
"springfox"
level=
"ERROR"
/>
<logger
name=
"javax"
level=
"ERROR"
/>
<logger
name=
"java"
level=
"ERROR"
/>
<logger
name=
"net"
level=
"ERROR"
/>
<logger
name=
"org"
level=
"INFO"
/>
<logger
name=
"io"
level=
"INFO"
/>
</configuration>
\ 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