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
e676dd19
Commit
e676dd19
authored
Nov 09, 2020
by
Quxl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
7c27fdd2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
64 deletions
+66
-64
ProductsTask.java
src/main/java/com/egolm/pds/schedule/ProductsTask.java
+66
-64
No files found.
src/main/java/com/egolm/pds/schedule/ProductsTask.java
View file @
e676dd19
...
@@ -41,77 +41,79 @@ public class ProductsTask {
...
@@ -41,77 +41,79 @@ public class ProductsTask {
@Scheduled
(
cron
=
"${pds.cron.products_download}"
)
@Scheduled
(
cron
=
"${pds.cron.products_download}"
)
public
void
execute
()
{
public
void
execute
()
{
log
.
debug
(
DateUtil
.
format
(
new
Date
())
+
" PdsProductsUpdateTask RUN"
);
log
.
debug
(
DateUtil
.
format
(
new
Date
())
+
" PdsProductsUpdateTask RUN START"
);
boolean
boo
=
true
;
this
.
executeUpdateTask
();
int
loopCount
=
0
;
log
.
debug
(
DateUtil
.
format
(
new
Date
())
+
" PdsProductsUpdateTask RUN END"
);
while
(
boo
)
{
boo
=
executeUpdateTask
()
>
0
&&
loopCount
++
<
10
;
}
}
}
private
int
executeUpdateTask
()
{
private
void
executeUpdateTask
()
{
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
Map
<
String
,
String
>
headers
=
new
HashMap
<
String
,
String
>();
headers
.
put
(
authKey
,
authValue
);
headers
.
put
(
authKey
,
authValue
);
String
responseBody
=
HttpUtil
.
get
(
urlQuery
,
headers
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
responseBody
);
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"data"
);
boolean
isFinishd
=
false
;
if
(
jsonArray
!=
null
)
{
while
(!
isFinishd
)
{
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
String
responseBody
=
HttpUtil
.
get
(
urlQuery
,
headers
);
JSONObject
productJsonObject
=
jsonArray
.
getJSONObject
(
i
);
JSONObject
jsonObject
=
JSON
.
parseObject
(
responseBody
);
String
article_description
=
productJsonObject
.
getString
(
"article_description"
);
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"data"
);
String
article_group_no
=
productJsonObject
.
getString
(
"article_group_no"
);
if
(
jsonArray
==
null
||
jsonArray
.
size
()
==
0
)
{
String
article_short_description
=
productJsonObject
.
getString
(
"article_short_description"
);
isFinishd
=
true
;
String
article_type
=
productJsonObject
.
getString
(
"article_type"
);
}
else
{
String
barcode
=
productJsonObject
.
getString
(
"barcode"
);
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
String
buying_price
=
productJsonObject
.
getString
(
"buying_price"
);
JSONObject
productJsonObject
=
jsonArray
.
getJSONObject
(
i
);
String
buying_price_with_tax
=
productJsonObject
.
getString
(
"buying_price_with_tax"
);
String
article_description
=
productJsonObject
.
getString
(
"article_description"
);
Integer
case_qty
=
productJsonObject
.
getInteger
(
"case_qty"
);
String
article_group_no
=
productJsonObject
.
getString
(
"article_group_no"
);
String
deduction
=
productJsonObject
.
getString
(
"deduction"
);
String
article_short_description
=
productJsonObject
.
getString
(
"article_short_description"
);
String
made_in
=
productJsonObject
.
getString
(
"made_in"
);
String
article_type
=
productJsonObject
.
getString
(
"article_type"
);
String
order_way
=
productJsonObject
.
getString
(
"order_way"
);
String
barcode
=
productJsonObject
.
getString
(
"barcode"
);
String
pack_unit
=
productJsonObject
.
getString
(
"pack_unit"
);
String
buying_price
=
productJsonObject
.
getString
(
"buying_price"
);
String
selling_price
=
productJsonObject
.
getString
(
"selling_price"
);
String
buying_price_with_tax
=
productJsonObject
.
getString
(
"buying_price_with_tax"
);
String
specification
=
productJsonObject
.
getString
(
"specification"
);
Integer
case_qty
=
productJsonObject
.
getInteger
(
"case_qty"
);
String
stores
=
productJsonObject
.
getString
(
"stores"
);
String
deduction
=
productJsonObject
.
getString
(
"deduction"
);
String
supplier_article_no
=
productJsonObject
.
getString
(
"supplier_article_no"
);
String
made_in
=
productJsonObject
.
getString
(
"made_in"
);
String
supplier_no
=
productJsonObject
.
getString
(
"supplier_no"
);
String
order_way
=
productJsonObject
.
getString
(
"order_way"
);
String
tax_rate
=
productJsonObject
.
getString
(
"tax_rate"
);
String
pack_unit
=
productJsonObject
.
getString
(
"pack_unit"
);
String
trade_mode
=
productJsonObject
.
getString
(
"trade_mode"
);
String
selling_price
=
productJsonObject
.
getString
(
"selling_price"
);
String
weight_article
=
productJsonObject
.
getString
(
"weight_article"
);
String
specification
=
productJsonObject
.
getString
(
"specification"
);
Object
transactionId
=
productJsonObject
.
get
(
"transaction_id"
);
String
stores
=
productJsonObject
.
getString
(
"stores"
);
String
supplier_article_no
=
productJsonObject
.
getString
(
"supplier_article_no"
);
Map
<
String
,
Object
>
productMap
=
new
HashMap
<
String
,
Object
>();
String
supplier_no
=
productJsonObject
.
getString
(
"supplier_no"
);
productMap
.
put
(
"article_description"
,
article_description
);
String
tax_rate
=
productJsonObject
.
getString
(
"tax_rate"
);
productMap
.
put
(
"article_group_no"
,
article_group_no
);
String
trade_mode
=
productJsonObject
.
getString
(
"trade_mode"
);
productMap
.
put
(
"article_short_description"
,
article_short_description
);
String
weight_article
=
productJsonObject
.
getString
(
"weight_article"
);
productMap
.
put
(
"article_type"
,
article_type
);
Object
transactionId
=
productJsonObject
.
get
(
"transaction_id"
);
productMap
.
put
(
"barcode"
,
barcode
);
productMap
.
put
(
"buying_price"
,
buying_price
);
Map
<
String
,
Object
>
productMap
=
new
HashMap
<
String
,
Object
>();
productMap
.
put
(
"buying_price_with_tax"
,
buying_price_with_tax
);
productMap
.
put
(
"article_description"
,
article_description
);
productMap
.
put
(
"case_qty"
,
case_qty
);
productMap
.
put
(
"article_group_no"
,
article_group_no
);
productMap
.
put
(
"deduction"
,
deduction
);
productMap
.
put
(
"article_short_description"
,
article_short_description
);
productMap
.
put
(
"made_in"
,
made_in
);
productMap
.
put
(
"article_type"
,
article_type
);
productMap
.
put
(
"order_way"
,
order_way
);
productMap
.
put
(
"barcode"
,
barcode
);
productMap
.
put
(
"pack_unit"
,
pack_unit
);
productMap
.
put
(
"buying_price"
,
buying_price
);
productMap
.
put
(
"selling_price"
,
selling_price
);
productMap
.
put
(
"buying_price_with_tax"
,
buying_price_with_tax
);
productMap
.
put
(
"specification"
,
specification
);
productMap
.
put
(
"case_qty"
,
case_qty
);
productMap
.
put
(
"stores"
,
stores
);
productMap
.
put
(
"deduction"
,
deduction
);
productMap
.
put
(
"supplier_article_no"
,
supplier_article_no
);
productMap
.
put
(
"made_in"
,
made_in
);
productMap
.
put
(
"supplier_no"
,
supplier_no
);
productMap
.
put
(
"order_way"
,
order_way
);
productMap
.
put
(
"tax_rate"
,
tax_rate
);
productMap
.
put
(
"pack_unit"
,
pack_unit
);
productMap
.
put
(
"trade_mode"
,
trade_mode
);
productMap
.
put
(
"selling_price"
,
selling_price
);
productMap
.
put
(
"weight_article"
,
weight_article
);
productMap
.
put
(
"specification"
,
specification
);
productMap
.
put
(
"dLastUpdateTime"
,
new
Date
());
productMap
.
put
(
"stores"
,
stores
);
try
{
productMap
.
put
(
"supplier_article_no"
,
supplier_article_no
);
pdsService
.
savePdsProduct
(
transactionId
,
productMap
);;
productMap
.
put
(
"supplier_no"
,
supplier_no
);
}
catch
(
Throwable
e
)
{
productMap
.
put
(
"tax_rate"
,
tax_rate
);
log
.
error
(
""
,
e
);
productMap
.
put
(
"trade_mode"
,
trade_mode
);
emailService
.
sendForasync
(
"PDS TASK ERROR"
,
productJsonObject
.
toJSONString
(),
e
);
productMap
.
put
(
"weight_article"
,
weight_article
);
productMap
.
put
(
"dLastUpdateTime"
,
new
Date
());
try
{
pdsService
.
savePdsProduct
(
transactionId
,
productMap
);;
}
catch
(
Throwable
e
)
{
log
.
error
(
""
,
e
);
emailService
.
sendForasync
(
"PDS TASK ERROR"
,
productJsonObject
.
toJSONString
(),
e
);
}
}
}
}
}
}
}
return
jsonArray
==
null
?
0
:
jsonArray
.
size
();
}
}
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
...
...
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