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
e0f45641
Commit
e0f45641
authored
Oct 16, 2019
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
0e751ff1
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
127 additions
and
10 deletions
+127
-10
PdsPriceUpdateTask.java
src/main/java/com/egolm/pds/schedule/PdsPriceUpdateTask.java
+112
-0
PdsProductsUpdateTask.java
...in/java/com/egolm/pds/schedule/PdsProductsUpdateTask.java
+2
-5
PdsService.java
src/main/java/com/egolm/pds/schedule/service/PdsService.java
+1
-1
application-dev.yml
src/main/resources/application-dev.yml
+6
-2
application-pro.yml
src/main/resources/application-pro.yml
+6
-2
No files found.
src/main/java/com/egolm/pds/schedule/PdsPriceUpdateTask.java
0 → 100644
View file @
e0f45641
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.common.DateUtil
;
import
com.egolm.pds.config.HttpUtil
;
import
com.egolm.pds.schedule.service.PdsService
;
@Component
public
class
PdsPriceUpdateTask
{
@Autowired
private
PdsService
pdsService
;
@Value
(
"${pds.auth_key}"
)
private
String
authKey
;
@Value
(
"${pds.auth_value}"
)
private
String
authValue
;
@Value
(
"${pds.url_query}"
)
private
String
urlQuery
;
@Value
(
"${pds.cron.products_download}"
)
private
String
cron
;
@Scheduled
(
cron
=
"${pds.cron.products_download}"
)
public
void
execute
()
{
System
.
out
.
println
(
DateUtil
.
format
(
new
Date
())
+
" PdsProductsUpdateTask RUN "
+
cron
);
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
);
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
();
}
public
static
void
main
(
String
[]
args
)
{
Date
date
=
new
Date
(
1568079001765L
);
System
.
out
.
println
(
DateUtil
.
format
(
date
));
}
}
src/main/java/com/egolm/pds/schedule/PdsProductsUpdateTask.java
View file @
e0f45641
...
...
@@ -22,16 +22,13 @@ 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}"
)
@Value
(
"${pds.
products.
url_query}"
)
private
String
urlQuery
;
@Value
(
"${pds.cron.products_download}"
)
...
...
src/main/java/com/egolm/pds/schedule/service/PdsService.java
View file @
e0f45641
...
...
@@ -20,7 +20,7 @@ public class PdsService {
@Autowired
private
JdbcTemplate
jdbcTemplate
;
@Value
(
"${pds.url_update}"
)
@Value
(
"${pds.
products.
url_update}"
)
private
String
urlUpdate
;
@Value
(
"${pds.auth_key}"
)
...
...
src/main/resources/application-dev.yml
View file @
e0f45641
...
...
@@ -22,5 +22,9 @@ pds:
products_download
:
0 0 3 * * ?
auth_key
:
x-api-key
auth_value
:
gPmsTNthxi5krwOTnaM9y5AhXlHrc6Ve5ik2GzQg
products
:
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
price
:
url_query
:
https://pztafj5g87.execute-api.ap-southeast-1.amazonaws.com/test/sunshine/price_changes
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
View file @
e0f45641
...
...
@@ -22,6 +22,10 @@ pds:
products_download
:
0 0 3 * * ?
auth_key
:
x-api-key
auth_value
:
gPmsTNthxi5krwOTnaM9y5AhXlHrc6Ve5ik2GzQg
products
:
url_query
:
https://api.goodsmaster.com/sunshine/new_products_with_prices
url_update
:
https://api.goodsmaster.com/sunshine/new_products_with_prices/confirm
price
:
url_query
:
https://api.goodsmaster.com/sunshine/price_changes
url_update
:
https://api.goodsmaster.com/sunshine/price_changes/confirm
\ 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