Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
C
chinafrica
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
chinafrica
Commits
e693395d
提交
e693395d
authored
12月 05, 2019
作者:
zgy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新定时任务时间
上级
ea9817b1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
82 行增加
和
24 行删除
+82
-24
ExpressStatusTask.java
...in/src/main/java/com/platform/task/ExpressStatusTask.java
+3
-3
ItemTask.java
platform-admin/src/main/java/com/platform/task/ItemTask.java
+76
-18
j2cache.properties
platform-admin/src/main/resources/j2cache.properties
+3
-3
没有找到文件。
platform-admin/src/main/java/com/platform/task/ExpressStatusTask.java
浏览文件 @
e693395d
...
@@ -31,7 +31,7 @@ public class ExpressStatusTask {
...
@@ -31,7 +31,7 @@ public class ExpressStatusTask {
@Autowired
@Autowired
private
TbCfOrderService
tbCfOrderService
;
private
TbCfOrderService
tbCfOrderService
;
@Scheduled
(
cron
=
"0
15 0/2 * * ?
"
)
@Scheduled
(
cron
=
"0
0/10 * * * ?
"
)
public
void
expressStatusTaskForStorageC
()
{
public
void
expressStatusTaskForStorageC
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
startime
=
sdf
.
format
(
getStartTime
());
String
startime
=
sdf
.
format
(
getStartTime
());
...
@@ -63,7 +63,7 @@ public class ExpressStatusTask {
...
@@ -63,7 +63,7 @@ public class ExpressStatusTask {
System
.
out
.
println
(
"入珠海仓库查询时间:"
+
s1
);
System
.
out
.
println
(
"入珠海仓库查询时间:"
+
s1
);
System
.
out
.
println
(
"消耗时间:"
+(
endTime
-
startTime
)+
"ms"
);
System
.
out
.
println
(
"消耗时间:"
+(
endTime
-
startTime
)+
"ms"
);
}
}
@Scheduled
(
cron
=
"0
35 0/2 * * ?
"
)
@Scheduled
(
cron
=
"0
0/10 * * * ?
"
)
public
void
expressStatusTaskForStorageA
()
{
public
void
expressStatusTaskForStorageA
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
startime
=
sdf
.
format
(
getStartTime
());
String
startime
=
sdf
.
format
(
getStartTime
());
...
@@ -95,7 +95,7 @@ public class ExpressStatusTask {
...
@@ -95,7 +95,7 @@ public class ExpressStatusTask {
System
.
out
.
println
(
"入非洲仓库查询时间:"
+
s1
);
System
.
out
.
println
(
"入非洲仓库查询时间:"
+
s1
);
System
.
out
.
println
(
"消耗时间:"
+(
endTime
-
startTime
)+
"ms"
);
System
.
out
.
println
(
"消耗时间:"
+(
endTime
-
startTime
)+
"ms"
);
}
}
@Scheduled
(
cron
=
"0
55 0/2 * * ?
"
)
@Scheduled
(
cron
=
"0
0/10 * * * ?
"
)
public
void
expressStatusTaskForDelivery
()
{
public
void
expressStatusTaskForDelivery
()
{
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
startime
=
sdf
.
format
(
getStartTime
());
String
startime
=
sdf
.
format
(
getStartTime
());
...
...
platform-admin/src/main/java/com/platform/task/ItemTask.java
浏览文件 @
e693395d
package
com
.
platform
.
task
;
package
com
.
platform
.
task
;
import
com.alibaba.fastjson.JSON
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Lists
;
import
com.mashape.unirest.http.Unirest
;
import
com.platform.dao.TbCfStationItemDao
;
import
com.platform.entity.TbCfStationItemEntity
;
import
com.platform.entity.TbCfStationItemEntity
;
import
com.platform.service.TbCfStationItemService
;
import
com.platform.utils.IdUtil
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
org.apache.http.*
;
import
org.apache.http.*
;
...
@@ -16,14 +20,14 @@ import org.apache.http.message.BasicHeader;
...
@@ -16,14 +20,14 @@ import org.apache.http.message.BasicHeader;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.message.BasicNameValuePair
;
import
org.apache.http.util.EntityUtils
;
import
org.apache.http.util.EntityUtils
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
java.net.URI
;
import
java.net.URI
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
/**
* @Auther: wudepeng
* @Auther: wudepeng
...
@@ -33,42 +37,60 @@ import java.util.Map;
...
@@ -33,42 +37,60 @@ import java.util.Map;
@Component
(
"itemTask"
)
@Component
(
"itemTask"
)
public
class
ItemTask
{
public
class
ItemTask
{
@Autowired
private
TbCfStationItemDao
tbCfStationItemDao
;
/**
/**
* 定时查询
* 定时查询
*
*
* @throws IOException
* @throws IOException
*/
*/
//
@Scheduled(cron = "0 0 21 * * ? ")
//
@Scheduled(cron = "0 0 21 * * ? ")
@Test
// @Scheduled(cron = "0 0 0/1 * * ? ")
public
void
queryItemFromShopify
()
throws
IOException
{
public
void
queryItemFromShopify
()
throws
IOException
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
List
type
=
getProductType
();
List
type
=
getProductType
();
for
(
int
i
=
0
;
i
<
type
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
type
.
size
();
i
++)
{
params
.
put
(
"product_type"
,
type
.
get
(
i
));
params
.
put
(
"product_type"
,
type
.
get
(
i
));
params
.
put
(
"limit"
,
"
4
"
);
params
.
put
(
"limit"
,
"
250
"
);
String
data
=
createConnection
(
ShopifyConstant
.
productTypeUrl
(),
params
,
"UTF-8"
);
String
data
=
createConnection
(
ShopifyConstant
.
productTypeUrl
(),
params
,
"UTF-8"
);
System
.
out
.
println
(
data
);
System
.
out
.
println
(
data
);
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
data
);
JSONObject
jsonObject
=
JSONObject
.
fromObject
(
data
);
JSONArray
products
=
jsonObject
.
getJSONArray
(
"products"
);
JSONArray
products
=
jsonObject
.
getJSONArray
(
"products"
);
for
(
int
j
=
0
;
j
<
products
.
size
();
j
++)
{
for
(
int
j
=
0
;
j
<
products
.
size
();
j
++)
{
TbCfStationItemEntity
item
=
new
TbCfStationItemEntity
();
JSONObject
object
=
products
.
getJSONObject
(
j
);
JSONObject
object
=
products
.
getJSONObject
(
j
);
String
id
=
object
.
getString
(
"id"
);
String
id
=
object
.
getString
(
"id"
);
String
title
=
object
.
getString
(
"title"
);
String
title
=
object
.
getString
(
"title"
);
String
product_type
=
object
.
getString
(
"product_type"
);
String
product_type
=
object
.
getString
(
"product_type"
);
JSONArray
variants
=
object
.
getJSONArray
(
"variants"
);
JSONArray
variants
=
object
.
getJSONArray
(
"variants"
);
String
image
=
object
.
getJSONObject
(
"image"
).
getString
(
"src"
);
String
image
=
object
.
getJSONObject
(
"image"
).
getString
(
"src"
);
for
(
int
m
=
0
;
m
<
variants
.
size
();
m
++){
List
<
Double
>
priceList
=
new
ArrayList
<>();
for
(
int
m
=
0
;
m
<
variants
.
size
();
m
++)
{
JSONObject
obj
=
variants
.
getJSONObject
(
m
);
JSONObject
obj
=
variants
.
getJSONObject
(
m
);
String
price
=
obj
.
getString
(
"price"
);
String
productPrice
=
obj
.
getString
(
"price"
);
// System.out.println(id);
priceList
.
add
(
Double
.
valueOf
(
productPrice
));
// System.out.println(title);
// System.out.println(product_type);
// System.out.println(image);
// System.out.println(price);
// System.out.println("============================");
}
}
Collections
.
sort
(
priceList
);
System
.
out
.
println
(
id
);
System
.
out
.
println
(
title
);
System
.
out
.
println
(
product_type
);
System
.
out
.
println
(
image
);
System
.
out
.
println
(
priceList
);
System
.
out
.
println
(
"==================="
);
System
.
out
.
println
(
new
BigDecimal
(
priceList
.
get
(
0
)).
setScale
(
2
,
BigDecimal
.
ROUND_DOWN
));
TbCfStationItemEntity
product
=
new
TbCfStationItemEntity
();
product
.
setItemId
(
IdUtil
.
createIdbyUUID
());
product
.
setItemCode
(
id
);
product
.
setItemName
(
title
);
product
.
setItemBrief
(
title
);
product
.
setItemPrice
(
new
BigDecimal
(
priceList
.
get
(
0
)).
setScale
(
2
,
BigDecimal
.
ROUND_DOWN
));
product
.
setItemImg
(
image
);
product
.
setItemNum
(
0L
);
product
.
setPlatformCode
(
"afri-eshop"
);
product
.
setPlatformName
(
"afri-eshop"
);
product
.
setEnableFlag
(
1
);
product
.
setCreateTime
(
new
Date
());
tbCfStationItemDao
.
save
(
product
);
}
}
}
}
...
@@ -155,4 +177,40 @@ public class ItemTask {
...
@@ -155,4 +177,40 @@ public class ItemTask {
}
}
return
list
;
return
list
;
}
}
/**
* 获取shopify接口 headers里的参数【Link】
*
* @param url
* @return
* @throws Exception
*/
public
static
List
<
String
>
getHeaders
(
String
url
)
throws
Exception
{
List
<
String
>
list
=
new
ArrayList
();
com
.
mashape
.
unirest
.
http
.
HttpResponse
<
String
>
response
=
Unirest
.
get
(
url
)
.
headers
(
new
HashMap
<>())
.
asString
();
List
<
String
>
link
=
response
.
getHeaders
().
get
(
"Link"
);
String
linkString
=
link
.
toString
();
boolean
next
=
linkString
.
contains
(
"next"
);
boolean
previous
=
linkString
.
contains
(
"previous"
);
String
str
=
link
.
get
(
0
);
String
[]
split
=
str
.
split
(
","
);
for
(
int
i
=
0
;
i
<
split
.
length
;
i
++)
{
String
s
=
split
[
i
];
String
sub
=
s
.
substring
(
s
.
indexOf
(
"page_info="
),
s
.
lastIndexOf
(
">;"
));
String
substring
=
sub
.
substring
(
10
);
list
.
add
(
substring
);
}
if
(
next
)
{
list
.
add
(
"first"
);
if
(
previous
)
{
list
.
add
(
"middle"
);
}
}
else
{
list
.
add
(
"last"
);
}
return
list
;
}
}
}
platform-admin/src/main/resources/j2cache.properties
浏览文件 @
e693395d
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
# xx.xxxx.xxxx.Xxxxx your own cache broadcast policy classname that implement net.oschina.j2cache.ClusterPolicy
# xx.xxxx.xxxx.Xxxxx your own cache broadcast policy classname that implement net.oschina.j2cache.ClusterPolicy
#########################################
#########################################
j2cache.broadcast
=
redis
j2cache.broadcast
=
redis
#
组播的通道名称
#
�鲥��ͨ������
jgroups.channel.name
=
j2cache
jgroups.channel.name
=
j2cache
jgroups.configXml
=
/network.xml
jgroups.configXml
=
/network.xml
#########################################
#########################################
...
@@ -57,8 +57,8 @@ caffeine.properties=/caffeine.properties
...
@@ -57,8 +57,8 @@ caffeine.properties=/caffeine.properties
#
#
# single -> single redis server
# single -> single redis server
# sentinel -> master-slaves servers
# sentinel -> master-slaves servers
# cluster -> cluster servers (
数据库配置无效,使用 database = 0)
# cluster -> cluster servers (
���ݿ�������Ч��ʹ�� database = 0��
# sharded -> sharded servers (
密码、数据库必须在 hosts 中指定,且连接池配置无效 ; redis://user:password@127.0.0.1:6379/0)
# sharded -> sharded servers (
���롢���ݿ������ hosts ��ָ���������ӳ�������Ч ; redis://user:password@127.0.0.1:6379/0��
#
#
#########################################
#########################################
redis.mode
=
single
redis.mode
=
single
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论