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
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
172 additions
and
38 deletions
+172
-38
TakeStockOrder.cs
Domain/TakeStock/TakeStockOrder.cs
+6
-0
ITakeStockService.cs
IService/TakeStock/ITakeStockService.cs
+4
-0
TakeStockService.cs
Service/TakeStock/TakeStockService.cs
+85
-30
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
...
@@ -59,6 +59,12 @@ namespace Domain.TakeStock
...
@@ -59,6 +59,12 @@ namespace Domain.TakeStock
public
string
WaitCodes
{
get
;
set
;
}
public
string
WaitCodes
{
get
;
set
;
}
/// <summary>
/// <summary>
/// 待取消的配货单号
/// </summary>
[
SugarColumn
(
IsNullable
=
true
,
Length
=
1000
)]
public
string
ToCancelCodes
{
get
;
set
;
}
/// <summary>
/// 取消的配货单号
/// 取消的配货单号
/// </summary>
/// </summary>
[
SugarColumn
(
IsNullable
=
true
,
Length
=
1000
)]
[
SugarColumn
(
IsNullable
=
true
,
Length
=
1000
)]
...
...
IService/TakeStock/ITakeStockService.cs
View file @
f6b3f0c7
...
@@ -24,6 +24,10 @@ namespace IService.TakeStock
...
@@ -24,6 +24,10 @@ namespace IService.TakeStock
/// <returns></returns>
/// <returns></returns>
Task
<
bool
>
StartTakeStock
(
int
id
,
int
beforeQuantity
);
Task
<
bool
>
StartTakeStock
(
int
id
,
int
beforeQuantity
);
Task
CanceledInform
(
int
id
,
string
acOrderCode
);
Task
DeliveryInform
(
int
id
,
string
acOrderCode
);
/// <summary>
/// <summary>
/// 盘点结果反馈
/// 盘点结果反馈
/// </summary>
/// </summary>
...
...
Service/TakeStock/TakeStockService.cs
View file @
f6b3f0c7
...
@@ -185,14 +185,10 @@ namespace Service.TakeStock
...
@@ -185,14 +185,10 @@ namespace Service.TakeStock
bool
isSuccess
=
false
;
bool
isSuccess
=
false
;
if
(
order
.
State
==
TSOrderState
.
取消
)
if
(
order
.
State
==
TSOrderState
.
取消
)
return
true
;
return
true
;
if
(
order
.
State
==
TSOrderState
.
释放库存
)
isSuccess
=
true
;
else
{
var
schedule
=
_scheduleRepository
.
Get
(
order
.
ScheduleId
);
var
schedule
=
_scheduleRepository
.
Get
(
order
.
ScheduleId
);
var
client
=
_httpClientFactory
.
CreateClient
(
"WMS"
);
var
client
=
_httpClientFactory
.
CreateClient
(
"WMS"
);
client
.
DefaultRequestHeaders
.
Add
(
"Access-Control-Allow-Origin"
,
"*"
);
client
.
DefaultRequestHeaders
.
Add
(
"Access-Control-Allow-Origin"
,
"*"
);
string
data
=
JsonConvert
.
SerializeObject
(
new
{
Data
=
new
{
WarehouseCode
=
order
.
WarehouseCode
,
Sku
=
order
.
Sku
,
IsAutomation
=
schedule
.
IsAutomation
}
});
string
data
=
JsonConvert
.
SerializeObject
(
new
{
Data
=
new
{
TakeId
=
id
,
WarehouseCode
=
order
.
WarehouseCode
,
Sku
=
order
.
Sku
,
IsAutomation
=
schedule
.
IsAutomation
}
});
HttpContent
content
=
new
StringContent
(
data
);
HttpContent
content
=
new
StringContent
(
data
);
content
.
Headers
.
ContentType
=
new
MediaTypeHeaderValue
(
"application/json"
);
content
.
Headers
.
ContentType
=
new
MediaTypeHeaderValue
(
"application/json"
);
var
response
=
await
client
.
PostAsync
(
"TakeStockScheduleService/RollbackStock"
,
content
);
var
response
=
await
client
.
PostAsync
(
"TakeStockScheduleService/RollbackStock"
,
content
);
...
@@ -201,51 +197,110 @@ namespace Service.TakeStock
...
@@ -201,51 +197,110 @@ namespace Service.TakeStock
var
responseContent
=
await
response
.
Content
.
ReadAsStringAsync
();
var
responseContent
=
await
response
.
Content
.
ReadAsStringAsync
();
var
jobj
=
JObject
.
Parse
(
responseContent
)[
"data"
];
var
jobj
=
JObject
.
Parse
(
responseContent
)[
"data"
];
isSuccess
=
jobj
[
"result"
].
ToObject
<
bool
>();
isSuccess
=
jobj
[
"result"
].
ToObject
<
bool
>();
Task
<
bool
>
logTask
=
null
;
if
(
isSuccess
)
if
(
isSuccess
)
{
{
order
.
State
=
TSOrderState
.
释放库存
;
var
toCancelCodes
=
jobj
[
"toCancelCodes"
].
ToObject
<
string
[
]>
();
order
.
LastModificationTime
=
DateTime
.
Now
;
var
waitCodes
=
jobj
[
"waitCodes"
].
ToObject
<
string
[
]>
();
if
(
toCancelCodes
?.
Length
>
0
)
logTask
=
AddOrUpdateLog
(
id
,
TSOrderState
.
释放库存
,
"已释放占用库存。"
);
order
.
ToCancelCodes
=
string
.
Join
(
','
,
toCancelCodes
);
if
(
waitCodes
?.
Length
>
0
)
order
.
WaitCodes
=
string
.
Join
(
','
,
waitCodes
);
}
}
else
else
{
{
order
.
State
=
TSOrderState
.
异常
;
order
.
State
=
TSOrderState
.
异常
;
order
.
LastModificationTime
=
DateTime
.
Now
;
order
.
LastModificationTime
=
DateTime
.
Now
;
logTask
=
AddOrUpdateLog
(
id
,
TSOrderState
.
异常
,
"
释放占用库存失败,WMS返回消息:"
+
jobj
[
"message"
],
responseContent
);
await
AddOrUpdateLog
(
id
,
TSOrderState
.
异常
,
"请求
释放占用库存失败,WMS返回消息:"
+
jobj
[
"message"
],
responseContent
);
}
}
var
cancelCodes
=
jobj
[
"cancelCodes"
].
ToString
();
await
_orderRepository
.
UpdateAsync
(
order
,
"State"
,
"ToCancelCodes"
,
"WaitCodes"
,
"LastModificationTime"
);
var
waitCodes
=
jobj
[
"waitCodes"
].
ToString
();
}
if
(!
cancelCodes
.
Equals
(
"[]"
))
if
(
isSuccess
)
{
{
order
.
CancelCodes
+=
","
+
cancelCodes
.
Trim
(
'['
,
']'
);
if
((
schedule
.
IsAutomation
&&
string
.
IsNullOrWhiteSpace
(
order
.
ToCancelCodes
))
||
(!
schedule
.
IsAutomation
&&
string
.
IsNullOrWhiteSpace
(
order
.
WaitCodes
)))
order
.
CancelCodes
=
order
.
CancelCodes
.
TrimStart
(
','
);
BackgroundJob
.
Enqueue
(()
=>
Completed
(
id
));
}
else
BackgroundJob
.
Schedule
(()
=>
RollbackStockAsync
(
id
),
DateTime
.
Now
.
AddMinutes
(
_delay
));
return
isSuccess
;
}
}
if
(!
waitCodes
.
Equals
(
"[]"
))
/// <summary>
/// WMS取消配货单成功后异步通知
/// </summary>
/// <param name="id"></param>
/// <param name="acOrderCode"></param>
/// <returns></returns>
public
async
Task
CanceledInform
(
int
id
,
string
acOrderCode
)
{
{
order
.
State
=
TSOrderState
.
冻结库存
;
bool
isSuccess
=
false
;
order
.
WaitCodes
=
waitCodes
.
Trim
(
'['
,
']'
);
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
;
}
}
int
row
=
await
_orderRepository
.
UpdateAsync
(
order
,
"State"
,
"CancelCodes"
,
"WaitCodes"
,
"LastModificationTime"
);
if
(
string
.
IsNullOrWhiteSpace
(
order
.
ToCancelCodes
)
&&
string
.
IsNullOrWhiteSpace
(
order
.
WaitCodes
))
BackgroundJob
.
Enqueue
(()
=>
Completed
(
id
));
}
if
(!(
row
>
0
&&
await
logTask
))
isSuccess
=
false
;
/// <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
));
}
}
if
(
isSuccess
)
/// <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
);
var
schedule
=
_scheduleRepository
.
Get
(
order
.
ScheduleId
);
if
(
schedule
.
IsAutomation
)
if
(
schedule
.
IsAutomation
)
BackgroundJob
.
Schedule
(()
=>
SyncAndEnabledAsync
(
id
),
DateTime
.
Now
.
AddMinutes
(
15
));
BackgroundJob
.
Enqueue
(()
=>
SyncAndEnabledAsync
(
id
));
}
else
BackgroundJob
.
Schedule
(()
=>
RollbackStockAsync
(
id
),
DateTime
.
Now
.
AddMinutes
(
_delay
));
return
isSuccess
;
}
}
/// <summary>
/// <summary>
...
@@ -298,8 +353,8 @@ namespace Service.TakeStock
...
@@ -298,8 +353,8 @@ namespace Service.TakeStock
if
(
isSuccess
)
if
(
isSuccess
)
{
{
BackgroundJob
.
Enqueue
(()
=>
CheckComplete
(
order
.
ScheduleId
));
BackgroundJob
.
Enqueue
(()
=>
CheckComplete
(
order
.
ScheduleId
));
if
(
order
.
State
==
TSOrderState
.
完成
)
//if
(order.State == TSOrderState.完成)
PushTakeStockMsg
(
order
);
//
PushTakeStockMsg(order);
}
}
else
else
BackgroundJob
.
Schedule
(()
=>
SyncAndEnabledAsync
(
id
),
DateTime
.
Now
.
AddMinutes
(
15
));
BackgroundJob
.
Schedule
(()
=>
SyncAndEnabledAsync
(
id
),
DateTime
.
Now
.
AddMinutes
(
15
));
...
...
TakeStock.API/Controllers/TakeStockController.cs
View file @
f6b3f0c7
...
@@ -57,6 +57,18 @@ namespace TakeStock.API.Controllers
...
@@ -57,6 +57,18 @@ namespace TakeStock.API.Controllers
return
await
takeStockAppService
.
StartTakeStock
(
input
);
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"
)]
[
HttpGet
(
"ReTry"
)]
public
async
Task
<
bool
>
ReTry
(
int
scheduleId
)
public
async
Task
<
bool
>
ReTry
(
int
scheduleId
)
{
{
...
...
TakeStock.API/appsettings.Development.json
View file @
f6b3f0c7
{
{
"Logging"
:
{
"Logging"
:
{
"LogLevel"
:
{
"LogLevel"
:
{
"Default"
:
"Debug"
,
"Default"
:
"Warning"
,
"System"
:
"Information"
,
"Hangfire"
:
"Information"
"Microsoft"
:
"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 @@
...
@@ -5,20 +5,15 @@
"Hangfire"
:
"Information"
"Hangfire"
:
"Information"
}
}
},
},
//
"AllowedHosts"
:
"*"
,
"WMS"
:
{
"WMS"
:
{
"Name"
:
"WMS"
,
"Name"
:
"WMS"
,
"Uri"
:
"http://wms.bailuntec.com/api/services/app/"
,
"Uri"
:
"http://wms.bailuntec.com/api/services/app/"
,
//
"Uri"
:
"http://wms.oa.com/api/services/app/"
,
"Timeout"
:
120
"Timeout"
:
120
},
},
"ConnectionStrings"
:
{
"ConnectionStrings"
:
{
"Localhost"
:
"server=10.0.8.14;database=bailun_wms;uid=root;pwd=#7kfnymAM$Y9-Ntf;port=3306;Convert Zero Datetime=True;"
,
"Localhost"
:
"server=10.0.8.14;database=bailun_wms;uid=root;pwd=#7kfnymAM$Y9-Ntf;port=3306;Convert Zero Datetime=True;"
,
"Redis"
:
"common-redis"
,
"Redis"
:
"common-redis"
,
"RabbitMqConnection"
:
"host=owms-rabbitmq:5672;username=bailun;password=1234abcd;prefetchcount=2;publisherConfirms=true;timeout=10"
"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"
:
{
"App"
:
{
"CorsOrigins"
:
"*"
"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
...
@@ -37,6 +37,18 @@ namespace TakeStock.Application.TakeStock
return
await
takeStockService
.
ReTry
(
scheduleId
);
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
)
public
async
Task
<
bool
>
StartTakeStock
(
StartTakeStockInputDto
input
)
{
{
return
await
takeStockService
.
StartTakeStock
(
input
.
Id
,
input
.
BeforeQuantity
);
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