Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
dc-java
Overview
Overview
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
huluobin
dc-java
Commits
d44fe9ac
Commit
d44fe9ac
authored
Mar 26, 2020
by
yinyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数据中心--资料库 获取所有分类信息
parent
0c01ef59
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
363 additions
and
4 deletions
+363
-4
Application.java
...ase-sync-sku/src/main/java/com/bailuntec/Application.java
+9
-4
BailunCategoryResult.java
.../java/com/bailuntec/domain/pojo/BailunCategoryResult.java
+13
-0
BailunCategoryJob.java
...ku/src/main/java/com/bailuntec/job/BailunCategoryJob.java
+64
-0
const.properties
data-base/base-sync-sku/src/main/resources/const.properties
+2
-0
job.properties
data-base/base-sync-sku/src/main/resources/job.properties
+3
-0
DcBaseBailuncategory.java
...ava/com/bailuntec/domain/entity/DcBaseBailuncategory.java
+147
-0
DcBaseBailuncategoryExample.java
...bailuntec/domain/example/DcBaseBailuncategoryExample.java
+0
-0
DcBaseBailuncategoryMapper.java
...java/com/bailuntec/mapper/DcBaseBailuncategoryMapper.java
+125
-0
DcBaseBailuncategoryMapper.xml
.../java/com/bailuntec/mapper/DcBaseBailuncategoryMapper.xml
+0
-0
No files found.
data-base/base-sync-sku/src/main/java/com/bailuntec/Application.java
View file @
d44fe9ac
package
com
.
bailuntec
;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.bailuntec.job.SkuCoroutineMSSyncJob
;
import
com.bailuntec.job.SkuMSSyncJob
;
import
com.bailuntec.job.SkuMappingSyncJob
;
import
com.bailuntec.job.SkuSimpleCategoryJob
;
import
com.bailuntec.job.*
;
import
com.bailuntec.listener.SkuMSSyncJobListener
;
import
com.bailuntec.utils.PropertiesUtil
;
import
com.dangdang.ddframe.job.config.JobCoreConfiguration
;
...
...
@@ -32,6 +29,7 @@ public class Application {
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration3
()).
init
();
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration1
()).
init
();
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration2
()).
init
();
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration4
()).
init
();
}
private
static
CoordinatorRegistryCenter
createRegistryCenter
()
{
...
...
@@ -60,6 +58,13 @@ public class Application {
return
simpleJobRootConfig
;
}
private
static
LiteJobConfiguration
createJobConfiguration4
()
{
JobCoreConfiguration
simpleCoreConfig
=
JobCoreConfiguration
.
newBuilder
(
propertiesUtil
.
getPropertyAsString
(
"JOB_CATEGORY_NAME"
),
propertiesUtil
.
getPropertyAsString
(
"JOB_CATEGORY_CRON"
),
propertiesUtil
.
getPropertyAsInt
(
"SHARDING_TOTAL_COUNT"
)).
build
();
SimpleJobConfiguration
simpleJobConfig
=
new
SimpleJobConfiguration
(
simpleCoreConfig
,
BailunCategoryJob
.
class
.
getCanonicalName
());
LiteJobConfiguration
simpleJobRootConfig
=
LiteJobConfiguration
.
newBuilder
(
simpleJobConfig
).
build
();
return
simpleJobRootConfig
;
}
private
static
LiteJobConfiguration
createJobConfiguration3
()
{
JobCoreConfiguration
simpleCoreConfig
=
JobCoreConfiguration
.
newBuilder
(
propertiesUtil
.
getPropertyAsString
(
"JOB_NAME_COROUTINE"
),
propertiesUtil
.
getPropertyAsString
(
"JOB_CRON_COROUTINE"
),
propertiesUtil
.
getPropertyAsInt
(
"SHARDING_TOTAL_COUNT"
)).
build
();
SimpleJobConfiguration
simpleJobConfig
=
new
SimpleJobConfiguration
(
simpleCoreConfig
,
SkuCoroutineMSSyncJob
.
class
.
getCanonicalName
());
...
...
data-base/base-sync-sku/src/main/java/com/bailuntec/domain/pojo/BailunCategoryResult.java
0 → 100644
View file @
d44fe9ac
package
com
.
bailuntec
.
domain
.
pojo
;
import
com.bailuntec.domain.entity.DcBaseBailuncategory
;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
BailunCategoryResult
{
private
List
<
DcBaseBailuncategory
>
result
;
private
Integer
statusCode
;
private
String
message
;
}
data-base/base-sync-sku/src/main/java/com/bailuntec/job/BailunCategoryJob.java
0 → 100644
View file @
d44fe9ac
package
com
.
bailuntec
.
job
;
import
com.alibaba.fastjson.JSON
;
import
com.bailuntec.domain.entity.DcBaseBailuncategory
;
import
com.bailuntec.domain.pojo.BailunCategoryResult
;
import
com.bailuntec.mapper.DcBaseBailuncategoryMapper
;
import
com.bailuntec.utils.OkHttpUtil
;
import
com.bailuntec.utils.PropertiesUtil
;
import
com.bailuntec.utils.SessionUtil
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.dangdang.ddframe.job.api.simple.SimpleJob
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
org.apache.commons.beanutils.BeanUtils
;
import
java.time.LocalDateTime
;
import
java.util.LinkedHashMap
;
@Slf4j
public
class
BailunCategoryJob
implements
SimpleJob
{
private
PropertiesUtil
propertiesUtil
=
PropertiesUtil
.
getInstance
(
"const"
);
private
OkHttpClient
client
=
OkHttpUtil
.
getInstance
();
@Override
public
void
execute
(
ShardingContext
shardingContext
)
{
LinkedHashMap
<
String
,
String
>
map
=
new
LinkedHashMap
<>(
2
);
map
.
put
(
"level"
,
"0"
);
Request
request
=
new
Request
.
Builder
()
.
url
(
OkHttpUtil
.
attachHttpGetParams
(
propertiesUtil
.
getPropertyAsString
(
"BAILUN_CATEGORY_URL"
),
map
))
.
get
()
.
addHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
Response
response
=
null
;
try
{
response
=
client
.
newCall
(
request
).
execute
();
BailunCategoryResult
bailunCategoryResult
=
JSON
.
parseObject
(
response
.
body
().
byteStream
(),
BailunCategoryResult
.
class
);
if
(
bailunCategoryResult
.
getStatusCode
().
equals
(
200
))
{
if
(
bailunCategoryResult
.
getResult
()
!=
null
&&
bailunCategoryResult
.
getResult
().
size
()
>
0
)
{
DcBaseBailuncategory
dcBaseBailuncategory
=
new
DcBaseBailuncategory
();
DcBaseBailuncategoryMapper
mapper
=
SessionUtil
.
getSession
().
getMapper
(
DcBaseBailuncategoryMapper
.
class
);
for
(
DcBaseBailuncategory
baseBailuncategory
:
bailunCategoryResult
.
getResult
())
{
try
{
BeanUtils
.
copyProperties
(
dcBaseBailuncategory
,
baseBailuncategory
);
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"BeanUtils.copyProperties失败"
,
e
);
}
dcBaseBailuncategory
.
setGmtModified
(
LocalDateTime
.
now
());
mapper
.
upsertSelective
(
dcBaseBailuncategory
);
}
}
}
else
{
throw
new
RuntimeException
(
"调用百伦分类接口返回错误"
);
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"调用百伦分类接口失败"
+
e
.
getCause
().
getMessage
(),
e
);
}
finally
{
SessionUtil
.
closeSession
();
if
(
response
!=
null
)
{
response
.
close
();
}
}
}
}
data-base/base-sync-sku/src/main/resources/const.properties
View file @
d44fe9ac
...
...
@@ -2,6 +2,8 @@
SKU_URL
=
http://10.0.8.13:8000/api/sku/productsku/gmtproductskus
SKU_SIMPLE_CATEGORY_URL
=
http://10.0.8.13:8000/api/category/simplecategory/categoriessimplebylevel?level=0
SKU_MAPPING_URL
=
http://172.31.255.108:6039/skumapping/getpageskumappings
BAILUN_CATEGORY_URL
=
http://10.0.8.13:8000/api/category/categorybailun/gmtbailuncategoriesbylevel
#BAILUN_CATEGORY_URL=http://doc.bailuntec.com:6001/categorybailun/gmtbailuncategoriesbylevel
# SKU_MAPPING_URL=http://doc.bailuntec.com:6021/skumapping/getpageskumappings
# \u7EBF\u4E0B\u73AF\u5883
#SKU_URL=http://api.skums.bailuntec.com/api/sku/productsku/gmtproductskus
...
...
data-base/base-sync-sku/src/main/resources/job.properties
View file @
d44fe9ac
...
...
@@ -16,4 +16,6 @@ JOB_SIMPLE_CATEGORY_NAME=base-sync-sku-simple-category
JOB_SIMPLE_CATEGORY_CRON
=
0 0 23 * * ? *
JOB_MAPPING_NAME
=
base-sync-sku-mapping
JOB_MAPPING_CRON
=
0/10 * * * * ? *
JOB_CATEGORY_NAME
=
base-sync-category
JOB_CATEGORY_CRON
=
0 12 * * * ? *
SHARDING_TOTAL_COUNT
=
1
\ No newline at end of file
data-common/src/main/java/com/bailuntec/domain/entity/DcBaseBailuncategory.java
0 → 100644
View file @
d44fe9ac
package
com
.
bailuntec
.
domain
.
entity
;
import
com.alibaba.fastjson.annotation.JSONField
;
import
lombok.Data
;
import
java.time.LocalDateTime
;
@Data
public
class
DcBaseBailuncategory
{
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.id
*
* @mbg.generated
*/
private
Integer
id
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.c_id
*
* @mbg.generated
*/
private
Integer
cId
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.c_parentid
*
* @mbg.generated
*/
private
Integer
cParentid
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.c_ename
*
* @mbg.generated
*/
private
String
cEname
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.c_cname
*
* @mbg.generated
*/
private
String
cCname
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.c_sort
*
* @mbg.generated
*/
private
Integer
cSort
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.c_level
*
* @mbg.generated
*/
private
Integer
cLevel
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.path
*
* @mbg.generated
*/
private
String
path
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.c_name
*
* @mbg.generated
*/
private
String
cName
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.gmt_create
*
* @mbg.generated
*/
private
LocalDateTime
gmtCreate
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.gmt_modified
*
* @mbg.generated
*/
private
LocalDateTime
gmtModified
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_base_bailuncategory.has_delete
*
* @mbg.generated
*/
@JSONField
(
name
=
"isDelete"
)
private
Integer
hasDelete
;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
getClass
().
getSimpleName
());
sb
.
append
(
" ["
);
sb
.
append
(
"Hash = "
).
append
(
hashCode
());
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", cId="
).
append
(
cId
);
sb
.
append
(
", cParentid="
).
append
(
cParentid
);
sb
.
append
(
", cEname="
).
append
(
cEname
);
sb
.
append
(
", cCname="
).
append
(
cCname
);
sb
.
append
(
", cSort="
).
append
(
cSort
);
sb
.
append
(
", cLevel="
).
append
(
cLevel
);
sb
.
append
(
", path="
).
append
(
path
);
sb
.
append
(
", cName="
).
append
(
cName
);
sb
.
append
(
", gmtCreate="
).
append
(
gmtCreate
);
sb
.
append
(
", gmtModified="
).
append
(
gmtModified
);
sb
.
append
(
", hasDelete="
).
append
(
hasDelete
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
}
\ No newline at end of file
data-common/src/main/java/com/bailuntec/domain/example/DcBaseBailuncategoryExample.java
0 → 100644
View file @
d44fe9ac
This diff is collapsed.
Click to expand it.
data-common/src/main/java/com/bailuntec/mapper/DcBaseBailuncategoryMapper.java
0 → 100644
View file @
d44fe9ac
package
com
.
bailuntec
.
mapper
;
import
com.bailuntec.domain.entity.DcBaseBailuncategory
;
import
com.bailuntec.domain.example.DcBaseBailuncategoryExample
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
DcBaseBailuncategoryMapper
{
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
long
countByExample
(
DcBaseBailuncategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
int
deleteByExample
(
DcBaseBailuncategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
int
deleteByPrimaryKey
(
Integer
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
int
insert
(
DcBaseBailuncategory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
int
insertSelective
(
DcBaseBailuncategory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcBaseBailuncategory
selectOneByExample
(
DcBaseBailuncategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
List
<
DcBaseBailuncategory
>
selectByExample
(
DcBaseBailuncategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
DcBaseBailuncategory
selectByPrimaryKey
(
Integer
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
int
updateByExampleSelective
(
@Param
(
"record"
)
DcBaseBailuncategory
record
,
@Param
(
"example"
)
DcBaseBailuncategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
int
updateByExample
(
@Param
(
"record"
)
DcBaseBailuncategory
record
,
@Param
(
"example"
)
DcBaseBailuncategoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
int
updateByPrimaryKeySelective
(
DcBaseBailuncategory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
*/
int
updateByPrimaryKey
(
DcBaseBailuncategory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int
upsert
(
DcBaseBailuncategory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_base_bailuncategory
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int
upsertSelective
(
DcBaseBailuncategory
record
);
}
\ No newline at end of file
data-common/src/main/java/com/bailuntec/mapper/DcBaseBailuncategoryMapper.xml
0 → 100644
View file @
d44fe9ac
This diff is collapsed.
Click to expand it.
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