Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TakeStock
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
pengjinyang
TakeStock
Commits
f6b3f0c7
Commit
f6b3f0c7
authored
Dec 30, 2019
by
pengjinyang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
盘点取消配货异步实现。
parent
365edc49
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
192 additions
and
58 deletions
+192
-58
TakeStockOrder.cs
Domain/TakeStock/TakeStockOrder.cs
+6
-0
ITakeStockService.cs
IService/TakeStock/ITakeStockService.cs
+4
-0
TakeStockService.cs
Service/TakeStock/TakeStockService.cs
+105
-50
TakeStockController.cs
TakeStock.API/Controllers/TakeStockController.cs
+12
-0
appsettings.Development.json
TakeStock.API/appsettings.Development.json
+15
-3
appsettings.json
TakeStock.API/appsettings.json
+0
-5
CanceledInformInputDto.cs
...Stock.Application/TakeStock/Dto/CanceledInformInputDto.cs
+19
-0
DeliveryInformInputDto.cs
...Stock.Application/TakeStock/Dto/DeliveryInformInputDto.cs
+19
-0
TakeStockAppService.cs
TakeStock.Application/TakeStock/TakeStockAppService.cs
+12
-0
No files found.
Domain/TakeStock/TakeStockOrder.cs
View file @
f6b3f0c7
...
...
@@ -57,6 +57,12 @@ namespace Domain.TakeStock
/// </summary>
[
SugarColumn
(
IsNullable
=
true
,
Length
=
1000
)]
public
string
WaitCodes
{
get
;
set
;
}
/// <summary>
/// 待取消的配货单号
/// </summary>
[
SugarColumn
(
IsNullable
=
true
,
Length
=
1000
)]
public
string
ToCancelCodes
{
get
;
set
;
}
/// <summary>
/// 取消的配货单号
...
...
IService/TakeStock/ITakeStockService.cs
View file @
f6b3f0c7
...
...
@@ -24,6 +24,10 @@ namespace IService.TakeStock
/// <returns></returns>
Task
<
bool
>
StartTakeStock
(
int
id
,
int
beforeQuantity
);
Task
CanceledInform
(
int
id
,
string
acOrderCode
);
Task
DeliveryInform
(
int
id
,
string
acOrderCode
);
/// <summary>
/// 盘点结果反馈
/// </summary>
...
...
Service/TakeStock/TakeStockService.cs
View file @
f6b3f0c7
...
...
@@ -185,62 +185,42 @@ namespace Service.TakeStock
bool
isSuccess
=
false
;
if
(
order
.
State
==
TSOrderState
.
取消
)
return
true
;
if
(
order
.
State
==
TSOrderState
.
释放库存
)
isSuccess
=
true
;
else
var
schedule
=
_scheduleRepository
.
Get
(
order
.
ScheduleId
);
var
client
=
_httpClientFactory
.
CreateClient
(
"WMS"
);
client
.
DefaultRequestHeaders
.
Add
(
"Access-Control-Allow-Origin"
,
"*"
);
string
data
=
JsonConvert
.
SerializeObject
(
new
{
Data
=
new
{
TakeId
=
id
,
WarehouseCode
=
order
.
WarehouseCode
,
Sku
=
order
.
Sku
,
IsAutomation
=
schedule
.
IsAutomation
}
});
HttpContent
content
=
new
StringContent
(
data
);
content
.
Headers
.
ContentType
=
new
MediaTypeHeaderValue
(
"application/json"
);
var
response
=
await
client
.
PostAsync
(
"TakeStockScheduleService/RollbackStock"
,
content
);
if
(
response
.
IsSuccessStatusCode
)
{
var
schedule
=
_scheduleRepository
.
Get
(
order
.
ScheduleId
);
var
client
=
_httpClientFactory
.
CreateClient
(
"WMS"
);
client
.
DefaultRequestHeaders
.
Add
(
"Access-Control-Allow-Origin"
,
"*"
);
string
data
=
JsonConvert
.
SerializeObject
(
new
{
Data
=
new
{
WarehouseCode
=
order
.
WarehouseCode
,
Sku
=
order
.
Sku
,
IsAutomation
=
schedule
.
IsAutomation
}
});
HttpContent
content
=
new
StringContent
(
data
);
content
.
Headers
.
ContentType
=
new
MediaTypeHeaderValue
(
"application/json"
);
var
response
=
await
client
.
PostAsync
(
"TakeStockScheduleService/RollbackStock"
,
content
);
if
(
response
.
IsSuccessStatusCode
)
var
responseContent
=
await
response
.
Content
.
ReadAsStringAsync
();
var
jobj
=
JObject
.
Parse
(
responseContent
)[
"data"
];
isSuccess
=
jobj
[
"result"
].
ToObject
<
bool
>();
if
(
isSuccess
)
{
var
responseContent
=
await
response
.
Content
.
ReadAsStringAsync
();
var
jobj
=
JObject
.
Parse
(
responseContent
)[
"data"
];
isSuccess
=
jobj
[
"result"
].
ToObject
<
bool
>();
Task
<
bool
>
logTask
=
null
;
if
(
isSuccess
)
{
order
.
State
=
TSOrderState
.
释放库存
;
order
.
LastModificationTime
=
DateTime
.
Now
;
logTask
=
AddOrUpdateLog
(
id
,
TSOrderState
.
释放库存
,
"已释放占用库存。"
);
}
else
{
order
.
State
=
TSOrderState
.
异常
;
order
.
LastModificationTime
=
DateTime
.
Now
;
logTask
=
AddOrUpdateLog
(
id
,
TSOrderState
.
异常
,
"释放占用库存失败,WMS返回消息:"
+
jobj
[
"message"
],
responseContent
);
}
var
cancelCodes
=
jobj
[
"cancelCodes"
].
ToString
();
var
waitCodes
=
jobj
[
"waitCodes"
].
ToString
();
if
(!
cancelCodes
.
Equals
(
"[]"
))
{
order
.
CancelCodes
+=
","
+
cancelCodes
.
Trim
(
'['
,
']'
);
order
.
CancelCodes
=
order
.
CancelCodes
.
TrimStart
(
','
);
}
if
(!
waitCodes
.
Equals
(
"[]"
))
{
order
.
State
=
TSOrderState
.
冻结库存
;
order
.
WaitCodes
=
waitCodes
.
Trim
(
'['
,
']'
);
}
int
row
=
await
_orderRepository
.
UpdateAsync
(
order
,
"State"
,
"CancelCodes"
,
"WaitCodes"
,
"LastModificationTime"
);
var
toCancelCodes
=
jobj
[
"toCancelCodes"
].
ToObject
<
string
[
]>
();
var
waitCodes
=
jobj
[
"waitCodes"
].
ToObject
<
string
[
]>
();
if
(
toCancelCodes
?.
Length
>
0
)
order
.
ToCancelCodes
=
string
.
Join
(
','
,
toCancelCodes
);
if
(
waitCodes
?.
Length
>
0
)
order
.
WaitCodes
=
string
.
Join
(
','
,
waitCodes
);
}
else
{
order
.
State
=
TSOrderState
.
异常
;
order
.
LastModificationTime
=
DateTime
.
Now
;
if
(!(
row
>
0
&&
await
logTask
))
isSuccess
=
false
;
await
AddOrUpdateLog
(
id
,
TSOrderState
.
异常
,
"请求释放占用库存失败,WMS返回消息:"
+
jobj
[
"message"
],
responseContent
)
;
}
await
_orderRepository
.
UpdateAsync
(
order
,
"State"
,
"ToCancelCodes"
,
"WaitCodes"
,
"LastModificationTime"
);
}
if
(
isSuccess
)
{
var
schedule
=
_scheduleRepository
.
Get
(
order
.
ScheduleId
);
if
(
schedule
.
IsAutomation
)
BackgroundJob
.
Schedule
(()
=>
SyncAndEnabledAsync
(
id
),
DateTime
.
Now
.
AddMinutes
(
15
));
if
((
schedule
.
IsAutomation
&&
string
.
IsNullOrWhiteSpace
(
order
.
ToCancelCodes
))
||
(!
schedule
.
IsAutomation
&&
string
.
IsNullOrWhiteSpace
(
order
.
WaitCodes
)))
BackgroundJob
.
Enqueue
(()
=>
Completed
(
id
));
}
else
BackgroundJob
.
Schedule
(()
=>
RollbackStockAsync
(
id
),
DateTime
.
Now
.
AddMinutes
(
_delay
));
...
...
@@ -249,6 +229,81 @@ namespace Service.TakeStock
}
/// <summary>
/// WMS取消配货单成功后异步通知
/// </summary>
/// <param name="id"></param>
/// <param name="acOrderCode"></param>
/// <returns></returns>
public
async
Task
CanceledInform
(
int
id
,
string
acOrderCode
)
{
bool
isSuccess
=
false
;
var
order
=
_orderRepository
.
Get
(
id
);
if
(
string
.
IsNullOrWhiteSpace
(
order
.
ToCancelCodes
))
isSuccess
=
true
;
else
{
var
toCancelCodes
=
order
.
ToCancelCodes
.
Split
(
','
);
order
.
ToCancelCodes
=
string
.
Join
(
','
,
toCancelCodes
.
Where
(
c
=>
!
c
.
Equals
(
acOrderCode
)).
ToArray
());
var
canceledCodes
=
order
.
CancelCodes
?.
Split
(
','
).
ToList
();
if
(
canceledCodes
==
null
)
canceledCodes
=
new
List
<
string
>();
canceledCodes
.
Add
(
acOrderCode
);
order
.
CancelCodes
=
string
.
Join
(
','
,
canceledCodes
);
await
_orderRepository
.
UpdateAsync
(
order
,
"ToCancelCodes"
,
"CancelCodes"
,
"LastModificationTime"
);
if
(
string
.
IsNullOrWhiteSpace
(
order
.
ToCancelCodes
))
isSuccess
=
true
;
}
if
(
string
.
IsNullOrWhiteSpace
(
order
.
ToCancelCodes
)
&&
string
.
IsNullOrWhiteSpace
(
order
.
WaitCodes
))
BackgroundJob
.
Enqueue
(()
=>
Completed
(
id
));
}
/// <summary>
/// WMS取消配货单成功后异步通知
/// </summary>
/// <param name="id"></param>
/// <param name="acOrderCode"></param>
/// <returns></returns>
public
async
Task
DeliveryInform
(
int
id
,
string
acOrderCode
)
{
bool
isSuccess
=
false
;
var
order
=
_orderRepository
.
Get
(
id
);
if
(
string
.
IsNullOrWhiteSpace
(
order
.
WaitCodes
))
isSuccess
=
true
;
else
{
var
waitCodes
=
order
.
WaitCodes
.
Split
(
','
).
ToList
();
order
.
WaitCodes
=
string
.
Join
(
','
,
waitCodes
.
Where
(
c
=>
!
c
.
Equals
(
acOrderCode
)).
ToArray
());
await
_orderRepository
.
UpdateAsync
(
order
,
"WaitCodes"
,
"LastModificationTime"
);
if
(
string
.
IsNullOrWhiteSpace
(
order
.
WaitCodes
))
isSuccess
=
true
;
}
if
(
string
.
IsNullOrWhiteSpace
(
order
.
ToCancelCodes
)
&&
string
.
IsNullOrWhiteSpace
(
order
.
WaitCodes
))
BackgroundJob
.
Enqueue
(()
=>
Completed
(
id
));
}
/// <summary>
/// 完成取消配货单
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public
async
Task
Completed
(
int
id
)
{
var
order
=
_orderRepository
.
Get
(
id
);
order
.
State
=
TSOrderState
.
释放库存
;
order
.
LastModificationTime
=
DateTime
.
Now
;
await
_orderRepository
.
UpdateAsync
(
order
,
"State"
,
"LastModificationTime"
);
await
AddOrUpdateLog
(
id
,
TSOrderState
.
释放库存
,
"已释放占用库存。"
);
var
schedule
=
_scheduleRepository
.
Get
(
order
.
ScheduleId
);
if
(
schedule
.
IsAutomation
)
BackgroundJob
.
Enqueue
(()
=>
SyncAndEnabledAsync
(
id
));
}
/// <summary>
/// 同步和启用库存
/// </summary>
/// <param name="warehouseCode"></param>
...
...
@@ -298,8 +353,8 @@ namespace Service.TakeStock
if
(
isSuccess
)
{
BackgroundJob
.
Enqueue
(()
=>
CheckComplete
(
order
.
ScheduleId
));
if
(
order
.
State
==
TSOrderState
.
完成
)
PushTakeStockMsg
(
order
);
//if
(order.State == TSOrderState.完成)
//
PushTakeStockMsg(order);
}
else
BackgroundJob
.
Schedule
(()
=>
SyncAndEnabledAsync
(
id
),
DateTime
.
Now
.
AddMinutes
(
15
));
...
...
TakeStock.API/Controllers/TakeStockController.cs
View file @
f6b3f0c7
...
...
@@ -56,6 +56,18 @@ namespace TakeStock.API.Controllers
{
return
await
takeStockAppService
.
StartTakeStock
(
input
);
}
[
HttpPost
(
"CanceledInform"
)]
public
async
Task
<
bool
>
CanceledInform
([
FromBody
]
CanceledInformInputDto
input
)
{
return
await
takeStockAppService
.
CanceledInform
(
input
.
Id
,
input
.
ACOrderCode
);
}
[
HttpPost
(
"DeliveryInform"
)]
public
async
Task
<
bool
>
DeliveryInform
([
FromBody
]
DeliveryInformInputDto
input
)
{
return
await
takeStockAppService
.
DeliveryInform
(
input
.
Id
,
input
.
ACOrderCode
);
}
[
HttpGet
(
"ReTry"
)]
public
async
Task
<
bool
>
ReTry
(
int
scheduleId
)
...
...
TakeStock.API/appsettings.Development.json
View file @
f6b3f0c7
{
"Logging"
:
{
"LogLevel"
:
{
"Default"
:
"Debug"
,
"System"
:
"Information"
,
"Microsoft"
:
"Information"
"Default"
:
"Warning"
,
"Hangfire"
:
"Information"
}
},
"WMS"
:
{
"Name"
:
"WMS"
,
"Uri"
:
"http://localhost:5001/api/services/app/"
,
"Timeout"
:
120
},
"ConnectionStrings"
:
{
"Localhost"
:
"server=gz-cdb-hqmznu0w.sql.tencentcdb.com;port=63523;database=bailun_wms;uid=root;password=#7kfnymAM$Y9-Ntf;Convert Zero Datetime=True;"
,
"Redis"
:
"129.204.97.78"
,
"RabbitMqConnection"
:
"host=111.230.164.154:5672;username=bailun;password=1234abcd;prefetchcount=2;publisherConfirms=true;timeout=10"
},
"App"
:
{
"CorsOrigins"
:
"*"
}
}
TakeStock.API/appsettings.json
View file @
f6b3f0c7
...
...
@@ -5,20 +5,15 @@
"Hangfire"
:
"Information"
}
},
//
"AllowedHosts"
:
"*"
,
"WMS"
:
{
"Name"
:
"WMS"
,
"Uri"
:
"http://wms.bailuntec.com/api/services/app/"
,
//
"Uri"
:
"http://wms.oa.com/api/services/app/"
,
"Timeout"
:
120
},
"ConnectionStrings"
:
{
"Localhost"
:
"server=10.0.8.14;database=bailun_wms;uid=root;pwd=#7kfnymAM$Y9-Ntf;port=3306;Convert Zero Datetime=True;"
,
"Redis"
:
"common-redis"
,
"RabbitMqConnection"
:
"host=owms-rabbitmq:5672;username=bailun;password=1234abcd;prefetchcount=2;publisherConfirms=true;timeout=10"
//
"Localhost"
:
"server=gz-cdb-hqmznu0w.sql.tencentcdb.com;port=63523;database=bailun_wms;uid=root;password=#7kfnymAM$Y9-Ntf;Convert Zero Datetime=True;"
,
//
"Redis"
:
"129.204.97.78"
,
//
"RabbitMqConnection"
:
"host=111.230.164.154:5672;username=bailun;password=1234abcd;prefetchcount=2;publisherConfirms=true;timeout=10"
},
"App"
:
{
"CorsOrigins"
:
"*"
...
...
TakeStock.Application/TakeStock/Dto/CanceledInformInputDto.cs
0 → 100644
View file @
f6b3f0c7
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
TakeStock.Application.TakeStock.Dto
{
public
class
CanceledInformInputDto
{
/// <summary>
/// 盘点单Id
/// </summary>
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 取消的配货单号
/// </summary>
public
string
ACOrderCode
{
get
;
set
;
}
}
}
TakeStock.Application/TakeStock/Dto/DeliveryInformInputDto.cs
0 → 100644
View file @
f6b3f0c7
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
TakeStock.Application.TakeStock.Dto
{
public
class
DeliveryInformInputDto
{
/// <summary>
/// 盘点单Id
/// </summary>
public
int
Id
{
get
;
set
;
}
/// <summary>
/// 发货的配货单号
/// </summary>
public
string
ACOrderCode
{
get
;
set
;
}
}
}
TakeStock.Application/TakeStock/TakeStockAppService.cs
View file @
f6b3f0c7
...
...
@@ -37,6 +37,18 @@ namespace TakeStock.Application.TakeStock
return
await
takeStockService
.
ReTry
(
scheduleId
);
}
public
async
Task
<
bool
>
CanceledInform
(
int
id
,
string
acOrderCode
)
{
await
takeStockService
.
CanceledInform
(
id
,
acOrderCode
);
return
true
;
}
public
async
Task
<
bool
>
DeliveryInform
(
int
id
,
string
acOrderCode
)
{
await
takeStockService
.
DeliveryInform
(
id
,
acOrderCode
);
return
true
;
}
public
async
Task
<
bool
>
StartTakeStock
(
StartTakeStockInputDto
input
)
{
return
await
takeStockService
.
StartTakeStock
(
input
.
Id
,
input
.
BeforeQuantity
);
...
...
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