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
b369e6f7
Commit
b369e6f7
authored
Aug 31, 2019
by
yinyong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JIT保底库存配置
parent
304285d2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
338 additions
and
0 deletions
+338
-0
SemiOrderSyncJob.java
...der/src/main/java/com/bailuntec/job/SemiOrderSyncJob.java
+97
-0
DcAutoJitInventory.java
.../java/com/bailuntec/domain/entity/DcAutoJitInventory.java
+116
-0
DcAutoJitInventoryExample.java
...m/bailuntec/domain/example/DcAutoJitInventoryExample.java
+0
-0
DcAutoJitInventoryMapper.java
...n/java/com/bailuntec/mapper/DcAutoJitInventoryMapper.java
+125
-0
DcAutoJitInventoryMapper.xml
...in/java/com/bailuntec/mapper/DcAutoJitInventoryMapper.xml
+0
-0
No files found.
data-base/base-sync-semi-order/src/main/java/com/bailuntec/job/SemiOrderSyncJob.java
0 → 100644
View file @
b369e6f7
package
com
.
bailuntec
.
job
;
import
com.alibaba.fastjson.JSON
;
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.mapper.DcSemiOrderMapper
;
import
com.bailuntec.mapper.JobPointLogMapper
;
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
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
;
@Slf4j
public
class
SemiOrderSyncJob
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_ORDER_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
))
{
SemiOrderResultInfo
palResultRoot
=
JSON
.
parseObject
(
palResultStr
,
SemiOrderResultInfo
.
class
);
if
(
palResultRoot
!=
null
&&
palResultRoot
.
getSuccess
().
booleanValue
())
{
ResultData
<
DcSemiOrder
>
resultData
=
palResultRoot
.
getData
();
if
(
jobPointLog
.
getPageIndex
().
equals
(
0
))
{
jobPointLog
.
setPageIndex
(
resultData
.
getTotalPages
()
+
1
);
}
if
(
resultData
.
getItems
()
!=
null
&&
resultData
.
getItems
().
size
()
>
0
)
{
for
(
DcSemiOrder
semiOrder
:
resultData
.
getItems
())
{
semiOrder
.
setId
(
null
);
DcSemiOrderMapper
mapper
=
SessionUtil
.
getSession
().
getMapper
(
DcSemiOrderMapper
.
class
);
mapper
.
upsertSelective
(
semiOrder
);
}
}
}
else
{
throw
new
RuntimeException
(
"调用流水接口同步百伦流水失败, 响应200, 请求参数"
+
map
.
toString
());
}
}
else
{
throw
new
RuntimeException
(
"调用流水接口同步百伦流水失败, 响应为null, 请求参数"
+
map
.
toString
());
}
if
(
jobPointLog
.
getPageIndex
()
%
10
==
0
)
{
try
{
JobPointLogMapper
mapper
=
SessionUtil
.
getSession
().
getMapper
(
JobPointLogMapper
.
class
);
mapper
.
upsertSelective
(
jobPointLog
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
RuntimeException
(
"Mybatis操作DB插入任务记录失败"
,
e
);
}
finally
{
SessionUtil
.
closeSession
();
}
}
jobPointLog
.
setPageIndex
(
jobPointLog
.
getPageIndex
()
-
1
);
}
while
(
0
<
jobPointLog
.
getPageIndex
());
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-common/src/main/java/com/bailuntec/domain/entity/DcAutoJitInventory.java
0 → 100644
View file @
b369e6f7
package
com
.
bailuntec
.
domain
.
entity
;
import
lombok.Data
;
@Data
public
class
DcAutoJitInventory
{
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_jit_inventory.id
*
* @mbg.generated
*/
private
Integer
id
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_jit_inventory.bailun_sku
*
* @mbg.generated
*/
private
String
bailunSku
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_jit_inventory.bailun_sku_title
*
* @mbg.generated
*/
private
String
bailunSkuTitle
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_jit_inventory.safe_stock
*
* @mbg.generated
*/
private
Integer
safeStock
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column dc_auto_jit_inventory.status
*
* @mbg.generated
*/
private
Integer
status
;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @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
(
", bailunSku="
).
append
(
bailunSku
);
sb
.
append
(
", bailunSkuTitle="
).
append
(
bailunSkuTitle
);
sb
.
append
(
", safeStock="
).
append
(
safeStock
);
sb
.
append
(
", status="
).
append
(
status
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
@Override
public
boolean
equals
(
Object
that
)
{
if
(
this
==
that
)
{
return
true
;
}
if
(
that
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
that
.
getClass
())
{
return
false
;
}
DcAutoJitInventory
other
=
(
DcAutoJitInventory
)
that
;
return
(
this
.
getId
()
==
null
?
other
.
getId
()
==
null
:
this
.
getId
().
equals
(
other
.
getId
()))
&&
(
this
.
getBailunSku
()
==
null
?
other
.
getBailunSku
()
==
null
:
this
.
getBailunSku
().
equals
(
other
.
getBailunSku
()))
&&
(
this
.
getBailunSkuTitle
()
==
null
?
other
.
getBailunSkuTitle
()
==
null
:
this
.
getBailunSkuTitle
().
equals
(
other
.
getBailunSkuTitle
()))
&&
(
this
.
getSafeStock
()
==
null
?
other
.
getSafeStock
()
==
null
:
this
.
getSafeStock
().
equals
(
other
.
getSafeStock
()))
&&
(
this
.
getStatus
()
==
null
?
other
.
getStatus
()
==
null
:
this
.
getStatus
().
equals
(
other
.
getStatus
()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
((
getId
()
==
null
)
?
0
:
getId
().
hashCode
());
result
=
prime
*
result
+
((
getBailunSku
()
==
null
)
?
0
:
getBailunSku
().
hashCode
());
result
=
prime
*
result
+
((
getBailunSkuTitle
()
==
null
)
?
0
:
getBailunSkuTitle
().
hashCode
());
result
=
prime
*
result
+
((
getSafeStock
()
==
null
)
?
0
:
getSafeStock
().
hashCode
());
result
=
prime
*
result
+
((
getStatus
()
==
null
)
?
0
:
getStatus
().
hashCode
());
return
result
;
}
}
\ No newline at end of file
data-common/src/main/java/com/bailuntec/domain/example/DcAutoJitInventoryExample.java
0 → 100644
View file @
b369e6f7
This diff is collapsed.
Click to expand it.
data-common/src/main/java/com/bailuntec/mapper/DcAutoJitInventoryMapper.java
0 → 100644
View file @
b369e6f7
package
com
.
bailuntec
.
mapper
;
import
com.bailuntec.domain.entity.DcAutoJitInventory
;
import
com.bailuntec.domain.example.DcAutoJitInventoryExample
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
public
interface
DcAutoJitInventoryMapper
{
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
long
countByExample
(
DcAutoJitInventoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
int
deleteByExample
(
DcAutoJitInventoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
int
deleteByPrimaryKey
(
Integer
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
int
insert
(
DcAutoJitInventory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
int
insertSelective
(
DcAutoJitInventory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
DcAutoJitInventory
selectOneByExample
(
DcAutoJitInventoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
List
<
DcAutoJitInventory
>
selectByExample
(
DcAutoJitInventoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
DcAutoJitInventory
selectByPrimaryKey
(
Integer
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
int
updateByExampleSelective
(
@Param
(
"record"
)
DcAutoJitInventory
record
,
@Param
(
"example"
)
DcAutoJitInventoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
int
updateByExample
(
@Param
(
"record"
)
DcAutoJitInventory
record
,
@Param
(
"example"
)
DcAutoJitInventoryExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
int
updateByPrimaryKeySelective
(
DcAutoJitInventory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
*/
int
updateByPrimaryKey
(
DcAutoJitInventory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int
upsert
(
DcAutoJitInventory
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table dc_auto_jit_inventory
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
int
upsertSelective
(
DcAutoJitInventory
record
);
}
\ No newline at end of file
data-common/src/main/java/com/bailuntec/mapper/DcAutoJitInventoryMapper.xml
0 → 100644
View file @
b369e6f7
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