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
bltdc
dc-java
Commits
d77fc722
Commit
d77fc722
authored
Oct 15, 2019
by
yinyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
同步半成品总库存流水报表
parent
71251015
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
233 additions
and
8 deletions
+233
-8
Application.java
...c-semi-order/src/main/java/com/bailuntec/Application.java
+9
-0
SemiResultInfo.java
...c/main/java/com/bailuntec/domain/pojo/SemiResultInfo.java
+2
-2
SemiOrderSyncJob.java
...der/src/main/java/com/bailuntec/job/SemiOrderSyncJob.java
+4
-4
SemiStockReportSyncJob.java
...c/main/java/com/bailuntec/job/SemiStockReportSyncJob.java
+87
-0
const.properties
.../base-sync-semi-order/src/main/resources/const.properties
+3
-2
job.properties
...se/base-sync-semi-order/src/main/resources/job.properties
+3
-0
DcSemiStockReport.java
...n/java/com/bailuntec/domain/entity/DcSemiStockReport.java
+0
-0
DcSemiStockReportExample.java
...om/bailuntec/domain/example/DcSemiStockReportExample.java
+0
-0
DcSemiStockReportMapper.java
...in/java/com/bailuntec/mapper/DcSemiStockReportMapper.java
+125
-0
DcSemiStockReportMapper.xml
...ain/java/com/bailuntec/mapper/DcSemiStockReportMapper.xml
+0
-0
No files found.
data-base/base-sync-semi-order/src/main/java/com/bailuntec/Application.java
View file @
d77fc722
...
...
@@ -2,6 +2,7 @@ package com.bailuntec;
import
com.alibaba.druid.pool.DruidDataSource
;
import
com.bailuntec.job.SemiOrderSyncJob
;
import
com.bailuntec.job.SemiStockReportSyncJob
;
import
com.bailuntec.listener.SemiOrderSyncJobListener
;
import
com.bailuntec.utils.PropertiesUtil
;
import
com.dangdang.ddframe.job.config.JobCoreConfiguration
;
...
...
@@ -26,6 +27,7 @@ public class Application {
private
static
final
String
EVENT_RDB_STORAGE_PASSWORD
=
propertiesUtil
.
getPropertyAsString
(
"EVENT_RDB_STORAGE_PASSWORD"
);
public
static
void
main
(
String
[]
args
)
{
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration
(),
createJobEventConfiguration
(),
new
SemiOrderSyncJobListener
()).
init
();
new
JobScheduler
(
createRegistryCenter
(),
createJobConfiguration1
(),
createJobEventConfiguration
()).
init
();
}
private
static
CoordinatorRegistryCenter
createRegistryCenter
()
{
...
...
@@ -41,6 +43,13 @@ public class Application {
return
simpleJobRootConfig
;
}
private
static
LiteJobConfiguration
createJobConfiguration1
()
{
JobCoreConfiguration
simpleCoreConfig
=
JobCoreConfiguration
.
newBuilder
(
propertiesUtil
.
getPropertyAsString
(
"JOB_STOCK_NAME"
),
propertiesUtil
.
getPropertyAsString
(
"JOB_STOCK_CRON"
),
propertiesUtil
.
getPropertyAsInt
(
"SHARDING_TOTAL_COUNT"
)).
build
();
SimpleJobConfiguration
simpleJobConfig
=
new
SimpleJobConfiguration
(
simpleCoreConfig
,
SemiStockReportSyncJob
.
class
.
getCanonicalName
());
LiteJobConfiguration
simpleJobRootConfig
=
LiteJobConfiguration
.
newBuilder
(
simpleJobConfig
).
build
();
return
simpleJobRootConfig
;
}
private
static
JobEventConfiguration
createJobEventConfiguration
()
{
JobEventConfiguration
jobEventRdbConfig
=
new
JobEventRdbConfiguration
(
setUpEventTraceDataSource
());
return
jobEventRdbConfig
;
...
...
data-base/base-sync-semi-order/src/main/java/com/bailuntec/domain/pojo/Semi
Order
ResultInfo.java
→
data-base/base-sync-semi-order/src/main/java/com/bailuntec/domain/pojo/SemiResultInfo.java
View file @
d77fc722
...
...
@@ -7,9 +7,9 @@ import lombok.Data;
import
java.util.List
;
@Data
public
class
Semi
OrderResultInfo
{
public
class
Semi
ResultInfo
<
T
>
{
private
Boolean
success
;
private
List
<
DcSemiOrder
>
data
;
private
List
<
T
>
data
;
}
data-base/base-sync-semi-order/src/main/java/com/bailuntec/job/SemiOrderSyncJob.java
View file @
d77fc722
package
com
.
bailuntec
.
job
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.bailuntec.domain.constant.CommonConstant
;
import
com.bailuntec.domain.entity.DcSemiOrder
;
import
com.bailuntec.domain.entity.JobPointLog
;
import
com.bailuntec.domain.pojo.SemiOrderResultInfo
;
import
com.bailuntec.domain.pojo.ResultData
;
import
com.bailuntec.domain.pojo.SemiResultInfo
;
import
com.bailuntec.mapper.DcSemiOrderMapper
;
import
com.bailuntec.mapper.JobPointLogMapper
;
import
com.bailuntec.support.PointJob
;
import
com.bailuntec.utils.OkHttpUtil
;
import
com.bailuntec.utils.PropertiesUtil
;
...
...
@@ -56,7 +56,7 @@ public class SemiOrderSyncJob extends PointJob {
}
}
if
(
StringUtils
.
isNoneBlank
(
palResultStr
))
{
Semi
OrderResultInfo
palResultRoot
=
JSON
.
parseObject
(
palResultStr
,
SemiOrderResultInfo
.
class
);
Semi
ResultInfo
<
DcSemiOrder
>
palResultRoot
=
JSONObject
.
parseObject
(
palResultStr
,
new
TypeReference
<
SemiResultInfo
<
DcSemiOrder
>>(){}
);
if
(
palResultRoot
!=
null
&&
palResultRoot
.
getSuccess
().
booleanValue
())
{
List
<
DcSemiOrder
>
resultData
=
palResultRoot
.
getData
();
if
(
resultData
!=
null
&&
resultData
.
size
()
>
0
)
{
...
...
data-base/base-sync-semi-order/src/main/java/com/bailuntec/job/SemiStockReportSyncJob.java
0 → 100644
View file @
d77fc722
package
com
.
bailuntec
.
job
;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
com.bailuntec.domain.constant.CommonConstant
;
import
com.bailuntec.domain.entity.DcSemiStockReport
;
import
com.bailuntec.domain.entity.JobPointLog
;
import
com.bailuntec.domain.pojo.SemiResultInfo
;
import
com.bailuntec.mapper.DcSemiStockReportMapper
;
import
com.bailuntec.support.PointJob
;
import
com.bailuntec.utils.OkHttpUtil
;
import
com.bailuntec.utils.PropertiesUtil
;
import
com.bailuntec.utils.SessionUtil
;
import
com.dangdang.ddframe.job.api.ShardingContext
;
import
com.google.gson.JsonObject
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Response
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.IOException
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
@Slf4j
public
class
SemiStockReportSyncJob
extends
PointJob
{
private
OkHttpClient
okHttpClient
=
OkHttpUtil
.
getInstance
();
private
PropertiesUtil
propertiesUtil
=
PropertiesUtil
.
getInstance
(
"const"
);
@Override
public
void
executeJob
(
ShardingContext
shardingContext
,
JobPointLog
jobPointLog
)
{
LinkedHashMap
<
String
,
String
>
map
=
new
LinkedHashMap
<>(
4
);
map
.
put
(
"rows"
,
jobPointLog
.
getPageSize
().
toString
());
map
.
put
(
"btime"
,
DateTimeFormatter
.
ofPattern
(
CommonConstant
.
TIME_FORMAT
).
format
(
jobPointLog
.
getStartTime
()));
map
.
put
(
"etime"
,
DateTimeFormatter
.
ofPattern
(
CommonConstant
.
TIME_FORMAT
).
format
(
jobPointLog
.
getEndTime
()));
do
{
map
.
put
(
"page"
,
jobPointLog
.
getPageIndex
().
equals
(
0
)
?
"1"
:
jobPointLog
.
getPageIndex
().
toString
());
Response
response
=
null
;
String
palResultStr
=
null
;
try
{
Request
request
=
new
Request
.
Builder
()
.
get
()
.
url
(
OkHttpUtil
.
attachHttpGetParams
(
propertiesUtil
.
getPropertyAsString
(
"SEMI_STOCK_URL"
),
map
))
.
addHeader
(
"Content-Type"
,
"application/json"
)
.
build
();
response
=
okHttpClient
.
newCall
(
request
).
execute
();
palResultStr
=
response
.
body
().
string
();
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
map
+
"请求流水接口同步百伦接口失败"
+
response
,
e
);
}
finally
{
if
(
response
!=
null
)
{
response
.
close
();
}
}
if
(
StringUtils
.
isNoneBlank
(
palResultStr
))
{
SemiResultInfo
<
DcSemiStockReport
>
palResultRoot
=
JSONObject
.
parseObject
(
palResultStr
,
new
TypeReference
<
SemiResultInfo
<
DcSemiStockReport
>>(){});
if
(
palResultRoot
!=
null
&&
palResultRoot
.
getSuccess
().
booleanValue
())
{
List
<
DcSemiStockReport
>
resultData
=
palResultRoot
.
getData
();
if
(
resultData
!=
null
&&
resultData
.
size
()
>
0
)
{
for
(
DcSemiStockReport
semiStockReport
:
resultData
)
{
semiStockReport
.
setId
(
null
);
DcSemiStockReportMapper
mapper
=
SessionUtil
.
getSession
().
getMapper
(
DcSemiStockReportMapper
.
class
);
mapper
.
upsertSelective
(
semiStockReport
);
}
}
else
{
break
;
}
}
else
{
throw
new
RuntimeException
(
"调用库存流水报表接口同步百伦库存流水失败, 响应200, 请求参数"
+
map
.
toString
());
}
}
else
{
throw
new
RuntimeException
(
"调用库存流水报表接口同步百伦库存流水失败, 响应为null, 请求参数"
+
map
.
toString
());
}
jobPointLog
.
setPageIndex
(
jobPointLog
.
getPageIndex
()
+
1
);
}
while
(
true
);
jobPointLog
.
setPageIndex
(
0
);
jobPointLog
.
setStartTime
(
jobPointLog
.
getEndTime
());
jobPointLog
.
setEndTime
(
jobPointLog
.
getEndTime
().
plusDays
(
jobPointLog
.
getIntervalTime
()).
isAfter
(
LocalDateTime
.
now
())
?
LocalDateTime
.
now
()
:
jobPointLog
.
getEndTime
().
plusDays
(
jobPointLog
.
getIntervalTime
()));
}
}
data-base/base-sync-semi-order/src/main/resources/const.properties
View file @
d77fc722
SEMI_ORDER_URL
=
http://mjzz.bailuntec.com/api/ApiOrderApply
\ No newline at end of file
SEMI_ORDER_URL
=
http://mjzz.bailuntec.com/api/ApiOrderApply
SEMI_STOCK_URL
=
http://mjzz.bailuntec.com/Material/FullStockLogPage
\ No newline at end of file
data-base/base-sync-semi-order/src/main/resources/job.properties
View file @
d77fc722
...
...
@@ -11,4 +11,6 @@ ZOOKEEPER_SERVER=172.31.255.120:2181
NAME_SPACE
=
data-center
JOB_NAME
=
base-sync-semi-order
JOB_CRON
=
0/1 * * * * ? *
JOB_STOCK_NAME
=
base_sync_semi_stock
JOB_STOCK_CRON
=
0/10 * * * * ? *
SHARDING_TOTAL_COUNT
=
1
\ No newline at end of file
data-common/src/main/java/com/bailuntec/domain/entity/DcSemiStockReport.java
0 → 100644
View file @
d77fc722
This diff is collapsed.
Click to expand it.
data-common/src/main/java/com/bailuntec/domain/example/DcSemiStockReportExample.java
0 → 100644
View file @
d77fc722
This diff is collapsed.
Click to expand it.
data-common/src/main/java/com/bailuntec/mapper/DcSemiStockReportMapper.java
0 → 100644
View file @
d77fc722
package
com
.
bailuntec
.
mapper
;
import
com.bailuntec.domain.entity.DcSemiStockReport
;
import
com.bailuntec.domain.example.DcSemiStockReportExample
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
DcSemiStockReportMapper
{
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
long
countByExample
(
DcSemiStockReportExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
int
deleteByExample
(
DcSemiStockReportExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
int
deleteByPrimaryKey
(
Integer
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
int
insert
(
DcSemiStockReport
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
int
insertSelective
(
DcSemiStockReport
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcSemiStockReport
selectOneByExample
(
DcSemiStockReportExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
List
<
DcSemiStockReport
>
selectByExample
(
DcSemiStockReportExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
DcSemiStockReport
selectByPrimaryKey
(
Integer
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
int
updateByExampleSelective
(
@Param
(
"record"
)
DcSemiStockReport
record
,
@Param
(
"example"
)
DcSemiStockReportExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
int
updateByExample
(
@Param
(
"record"
)
DcSemiStockReport
record
,
@Param
(
"example"
)
DcSemiStockReportExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
int
updateByPrimaryKeySelective
(
DcSemiStockReport
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
*/
int
updateByPrimaryKey
(
DcSemiStockReport
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int
upsert
(
DcSemiStockReport
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_semi_stock_report
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int
upsertSelective
(
DcSemiStockReport
record
);
}
\ No newline at end of file
data-common/src/main/java/com/bailuntec/mapper/DcSemiStockReportMapper.xml
0 → 100644
View file @
d77fc722
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