Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
Laisi_AutoMES2
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
jiawei.su
Laisi_AutoMES2
Commits
4835419a
Commit
4835419a
authored
Jan 20, 2021
by
xin.yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some update
parent
d729ace3
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
266 additions
and
172 deletions
+266
-172
.gitignore
.gitignore
+34
-4
LocationController.cs
Server/Apis/Siger.ApiWMS/Controllers/LocationController.cs
+189
-168
RequestEnum.cs
Server/Common/Siger.Middlelayer.Share/Enum/RequestEnum.cs
+3
-0
siger_wms_storage_location.cs
...ayer.WmsRepository/Entities/siger_wms_storage_location.cs
+2
-0
RequestAddLocation.cs
...r.Middlelayer.WmsRepository/Request/RequestAddLocation.cs
+38
-0
No files found.
.gitignore
View file @
4835419a
################################################################################
#Ignore thumbnails created by Windows
# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
Thumbs.db
#
###############################################################################
#
Ignore files built by Visual Studio
*.obj
*.exe
*.exe
*.pdb
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
.vs/
#Nuget packages folder
packages/
Server/.vs/SigerData/v15/Server/sqlite3/storage.ide
*.pyc
[Bb]in/
[Oo]bj/
[Ll]og/
Server/Apis/Siger.ApiWMS/Controllers/LocationController.cs
View file @
4835419a
...
@@ -20,6 +20,7 @@ using Siger.Middlelayer.WmsRepository.Entities;
...
@@ -20,6 +20,7 @@ using Siger.Middlelayer.WmsRepository.Entities;
using
Siger.Middlelayer.WmsRepository.Repositories.Interface
;
using
Siger.Middlelayer.WmsRepository.Repositories.Interface
;
using
Siger.Middlelayer.WmsRepository.Request
;
using
Siger.Middlelayer.WmsRepository.Request
;
using
Siger.Middlelayer.WmsRepository.Response
;
using
Siger.Middlelayer.WmsRepository.Response
;
using
Siger.Middlelayer.Common.Extensions
;
namespace
Siger.ApiWMS.Controllers
namespace
Siger.ApiWMS.Controllers
{
{
...
@@ -472,106 +473,6 @@ namespace Siger.ApiWMS.Controllers
...
@@ -472,106 +473,6 @@ namespace Siger.ApiWMS.Controllers
return
Ok
();
return
Ok
();
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
}
}
/// <summary>
/// 新增
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
IActionResult
AddLocation
([
FromBody
]
RequestAddLocation
req
)
{
int
locationType
=
0
;
int
storageid
=
0
;
//获取locationtype
siger_wms_storage_location_type
locationTypeEntity
;
switch
(
req
.
type
)
{
case
LocationTypeEnum
.
WaveHouse
:
if
(
location
.
IsExist
(
f
=>
f
.
realname
==
req
.
name
&&
f
.
projectid
==
ProjectId
&&
f
.
parentid
==
0
))
throw
new
BadRequestException
(
CommonEnum
.
RecordExits
);
locationTypeEntity
=
locationtype
.
Get
(
f
=>
f
.
status
==
(
int
)
RowState
.
Valid
&&
f
.
parentid
==
0
&&
f
.
projectid
==
ProjectId
);
if
(
locationTypeEntity
==
null
)
throw
new
BadRequestException
(
RequestEnum
.
LocationTypeNotExist
);
locationType
=
locationTypeEntity
.
id
;
storageid
=
req
.
parentid
;
req
.
parentid
=
0
;
break
;
case
LocationTypeEnum
.
Other
:
var
parentLocation
=
location
.
Get
(
f
=>
f
.
status
==
(
int
)
RowState
.
Valid
&&
f
.
id
==
req
.
parentid
&&
f
.
projectid
==
ProjectId
);
locationTypeEntity
=
locationtype
.
Get
(
f
=>
f
.
status
==
(
int
)
RowState
.
Valid
&&
f
.
parentid
==
parentLocation
.
typeid
);
if
(
locationTypeEntity
==
null
)
throw
new
BadRequestException
(
RequestEnum
.
LocationTypeNotExist
);
locationType
=
locationTypeEntity
.
id
;
storageid
=
parentLocation
.
storageid
;
if
(
location
.
IsExist
(
f
=>
f
.
realname
==
req
.
name
&&
f
.
projectid
==
ProjectId
&&
f
.
parentid
==
parentLocation
.
id
))
throw
new
BadRequestException
(
CommonEnum
.
RecordExits
);
break
;
default
:
break
;
}
//检测数量是否大于4
CheckCount
(
req
.
parentid
);
var
tmp
=
new
siger_wms_storage_location
{
storageid
=
storageid
,
parentid
=
req
.
parentid
,
name
=
req
.
name
,
realname
=
req
.
name
,
typeid
=
locationType
,
serial_number
=
Utility
.
GenSerialNumber
(),
creator
=
UserId
,
create_time
=
DateTime
.
Now
,
updator
=
UserId
,
update_time
=
DateTime
.
Now
,
projectid
=
ProjectId
,
status
=
req
.
status
==
(
int
)
RowState
.
Valid
?
(
int
)
RowState
.
Valid
:
(
int
)
RowState
.
Invalid
};
location
.
Insert
(
tmp
);
if
(
_unitOfWork
.
Commit
()
<=
0
)
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
//更新编号、层级名称
var
sn
=
new
StringBuilder
();
sn
.
Append
(
tmp
.
id
);
var
parent
=
location
.
Get
(
f
=>
f
.
id
==
tmp
.
parentid
&&
tmp
.
parentid
!=
0
&&
f
.
projectid
==
ProjectId
&&
f
.
status
==
(
int
)
RowState
.
Valid
);
var
parentname
=
""
;
if
(
parent
!=
null
)
{
parentname
=
parent
.
name
;
}
while
(
parent
!=
null
)
{
sn
.
Insert
(
0
,
parent
.
id
+
"_"
);
parent
=
location
.
Get
(
f
=>
f
.
id
==
parent
.
parentid
&&
parent
.
parentid
!=
0
&&
f
.
projectid
==
ProjectId
&&
f
.
status
==
(
int
)
RowState
.
Valid
);
}
//仓库
sn
.
Insert
(
0
,
storageid
+
"_"
);
tmp
.
serial_number
=
sn
.
ToString
();
//tmp.serial_number = $"{ sn.ToString()}_{ tmp.serial_number}";
//上级为仓库
if
(
tmp
.
parentid
==
0
)
{
var
wavehouse
=
storage
.
Get
(
f
=>
f
.
status
==
(
int
)
RowState
.
Valid
&&
f
.
projectid
==
ProjectId
&&
f
.
id
==
storageid
);
if
(
wavehouse
==
null
)
{
throw
new
BadRequestException
(
CommonEnum
.
NoData
);
}
tmp
.
name
=
$"
{
wavehouse
.
name
}
->
{
tmp
.
realname
}
"
;
}
else
{
tmp
.
name
=
$"
{
parentname
}
->
{
tmp
.
realname
}
"
;
}
location
.
Update
(
tmp
);
if
(
_unitOfWork
.
Commit
()
<=
0
)
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
return
Ok
();
}
private
void
CheckCount
(
int
pid
)
private
void
CheckCount
(
int
pid
)
{
{
...
@@ -590,74 +491,6 @@ namespace Siger.ApiWMS.Controllers
...
@@ -590,74 +491,6 @@ namespace Siger.ApiWMS.Controllers
}
}
}
}
/// <summary>
/// 更新
/// </summary>
/// <returns></returns>
[
HttpPost
]
public
IActionResult
UpdateLocation
([
FromBody
]
RequestUpdateLocation
req
)
{
if
(!
location
.
IsExist
(
f
=>
f
.
id
==
req
.
id
&&
f
.
projectid
==
ProjectId
))
throw
new
BadRequestException
(
CommonEnum
.
NoData
);
var
entity
=
location
.
Get
(
f
=>
f
.
id
==
req
.
id
&&
f
.
projectid
==
ProjectId
);
//同一级已经存在同名
if
(
location
.
IsExist
(
f
=>
f
.
realname
==
req
.
name
&&
f
.
id
!=
req
.
id
&&
f
.
projectid
==
ProjectId
&&
f
.
parentid
==
entity
.
parentid
))
throw
new
BadRequestException
(
RequestEnum
.
LevelExist
);
//update start
entity
.
realname
=
req
.
name
;
entity
.
updator
=
UserId
;
entity
.
update_time
=
DateTime
.
Now
;
entity
.
status
=
req
.
status
==
(
int
)
RowState
.
Valid
?
(
int
)
RowState
.
Valid
:
(
int
)
RowState
.
Invalid
;
if
(
entity
.
parentid
!=
0
)
{
var
parent
=
location
.
Get
(
f
=>
f
.
id
==
entity
.
parentid
&&
f
.
projectid
==
ProjectId
);
if
(
parent
==
null
)
{
throw
new
BadRequestException
(
RequestEnum
.
LocationPidNotExist
);
}
entity
.
name
=
$"
{
parent
.
name
}
->
{
entity
.
realname
}
"
;
}
else
{
var
parent
=
storage
.
Get
(
f
=>
f
.
id
==
entity
.
storageid
&&
f
.
projectid
==
ProjectId
);
if
(
parent
==
null
)
{
throw
new
BadRequestException
(
RequestEnum
.
LocationPidNotExist
);
}
entity
.
name
=
$"
{
parent
.
name
}
->
{
entity
.
realname
}
"
;
}
//update end
location
.
Update
(
entity
);
//重新生成子级
var
dic
=
new
Dictionary
<
int
,
string
>();
dic
.
Add
(
entity
.
id
,
entity
.
name
);
var
pids
=
new
List
<
int
>();
pids
.
Add
(
entity
.
id
);
while
(
pids
.
Count
()
!=
0
)
{
var
data
=
location
.
GetList
(
f
=>
pids
.
Contains
(
f
.
parentid
)
&&
f
.
projectid
==
ProjectId
).
ToList
();
pids
=
data
.
Select
(
f
=>
f
.
id
).
ToList
();
foreach
(
var
item
in
data
)
{
if
(
dic
.
TryGetValue
(
item
.
parentid
,
out
string
parentName
))
{
item
.
name
=
parentName
+
" -> "
+
item
.
realname
;
location
.
Update
(
item
);
}
}
dic
=
data
.
ToDictionary
(
f
=>
f
.
id
,
f
=>
f
.
name
);
}
if
(
_unitOfWork
.
Commit
()
>
0
)
return
Ok
();
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
}
[
HttpGet
]
[
HttpGet
]
public
IActionResult
GetTemplate
()
public
IActionResult
GetTemplate
()
{
{
...
@@ -1061,5 +894,192 @@ namespace Siger.ApiWMS.Controllers
...
@@ -1061,5 +894,192 @@ namespace Siger.ApiWMS.Controllers
}
}
return
new
PagedObjectResult
(
result
,
totalCount
,
page
,
pageSize
);
return
new
PagedObjectResult
(
result
,
totalCount
,
page
,
pageSize
);
}
}
[
HttpPost
]
public
IActionResult
AddLocation
([
FromBody
]
RequestAddLocationModel
req
)
{
if
(
req
.
storeID
.
ToInt
()
<=
0
||
req
.
locations
==
null
||
!
req
.
locations
.
Any
()
||
req
.
warehouseid
<=
0
)
{
throw
new
BadRequestException
(
RequestEnum
.
ParameterError
);
}
var
locationTypes
=
locationtype
.
GetList
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
).
ToList
();
if
(!
locationTypes
.
Any
())
{
throw
new
BadRequestException
(
RequestEnum
.
LocationTypeNotFound
);
}
var
sonLocationTypes
=
GetSonTypes
(
0
,
locationTypes
).
ToList
();
var
waveHouse
=
storage
.
Get
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
&&
q
.
id
==
req
.
warehouseid
);
if
(
waveHouse
==
null
)
{
throw
new
BadRequestException
(
RequestEnum
.
WaveHouseIDNotExist
);
}
if
(
req
.
locations
.
Count
!=
locationTypes
.
Count
)
{
throw
new
BadRequestException
(
RequestEnum
.
LocationCountError
);
}
foreach
(
var
Location
in
req
.
locations
)
{
var
loca
=
location
.
Get
(
q
=>
q
.
realname
==
Location
.
val
&&
q
.
projectid
==
ProjectId
);
if
(
loca
!=
null
)
{
throw
new
BadRequestException
(
RequestEnum
.
DataExist
);
}
}
var
ids
=
new
List
<
int
>();
var
parentid
=
0
;
foreach
(
var
locationType
in
sonLocationTypes
)
{
var
Location
=
req
.
locations
.
FirstOrDefault
(
q
=>
q
.
id
==
locationType
.
id
);
if
(
Location
==
null
)
{
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
//TODO
}
var
tmp
=
new
siger_wms_storage_location
{
storageid
=
req
.
warehouseid
,
parentid
=
parentid
,
name
=
""
,
realname
=
Location
.
val
,
typeid
=
Location
.
id
,
serial_number
=
Utility
.
GenSerialNumber
(),
creator
=
UserId
,
create_time
=
DateTime
.
Now
,
updator
=
UserId
,
update_time
=
DateTime
.
Now
,
projectid
=
ProjectId
,
status
=
req
.
status
==
(
int
)
RowState
.
Valid
?
(
int
)
RowState
.
Valid
:
(
int
)
RowState
.
Invalid
,
locationid
=
req
.
storeID
.
ToInt
()
};
parentid
=
InsertLocation
(
tmp
,
waveHouse
.
name
);
if
(
parentid
>
0
)
{
ids
.
Add
(
parentid
);
continue
;
}
else
{
foreach
(
var
id
in
ids
)
{
location
.
Delete
(
id
);
}
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
//TODO
}
}
return
new
ObjectResult
(
CommonEnum
.
Succefull
);
}
private
int
InsertLocation
(
siger_wms_storage_location
tmp
,
string
waveHouseName
)
{
int
id
=
0
;
location
.
Insert
(
tmp
);
if
(
_unitOfWork
.
Commit
()
<=
0
)
{
return
id
;
}
//更新编号、层级名称
var
sn
=
new
StringBuilder
();
sn
.
Append
(
tmp
.
id
);
var
parent
=
location
.
Get
(
f
=>
f
.
id
==
tmp
.
parentid
&&
tmp
.
parentid
!=
0
&&
f
.
projectid
==
ProjectId
&&
f
.
status
==
(
int
)
RowState
.
Valid
);
var
parentname
=
""
;
if
(
parent
!=
null
)
{
parentname
=
parent
.
name
;
}
while
(
parent
!=
null
)
{
sn
.
Insert
(
0
,
parent
.
id
+
"_"
);
parent
=
location
.
Get
(
f
=>
f
.
id
==
parent
.
parentid
&&
parent
.
parentid
!=
0
&&
f
.
projectid
==
ProjectId
&&
f
.
status
==
(
int
)
RowState
.
Valid
);
}
//仓库
sn
.
Insert
(
0
,
tmp
.
storageid
+
"_"
);
tmp
.
serial_number
=
sn
.
ToString
();
//上级为仓库
if
(
tmp
.
parentid
==
0
)
{
tmp
.
name
=
$"
{
waveHouseName
}
->
{
tmp
.
realname
}
"
;
}
else
{
tmp
.
name
=
$"
{
parentname
}
->
{
tmp
.
realname
}
"
;
}
location
.
Update
(
tmp
);
if
(
_unitOfWork
.
Commit
()
<=
0
)
{
return
id
;
}
return
tmp
.
id
;
}
[
HttpPost
]
public
IActionResult
UpdateLocation
([
FromBody
]
RequestAddLocationModel
req
)
{
if
(
req
.
storeID
.
ToInt
()
<=
0
||
req
.
locations
==
null
||
!
req
.
locations
.
Any
()
||
req
.
warehouseid
<=
0
)
{
throw
new
BadRequestException
(
RequestEnum
.
ParameterError
);
}
var
locationTypes
=
locationtype
.
GetList
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
).
ToList
();
if
(!
locationTypes
.
Any
())
{
throw
new
BadRequestException
(
RequestEnum
.
LocationTypeNotFound
);
}
var
sonLocationTypes
=
GetSonTypes
(
0
,
locationTypes
).
ToList
();
var
waveHouse
=
storage
.
Get
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
&&
q
.
id
==
req
.
warehouseid
);
if
(
waveHouse
==
null
)
{
throw
new
BadRequestException
(
RequestEnum
.
WaveHouseIDNotExist
);
}
if
(
req
.
locations
.
Count
!=
locationTypes
.
Count
)
{
throw
new
BadRequestException
(
RequestEnum
.
LocationCountError
);
}
foreach
(
var
Location
in
req
.
locations
)
{
var
loca
=
location
.
Get
(
q
=>
q
.
realname
==
Location
.
val
&&
q
.
projectid
==
ProjectId
&&
q
.
id
!=
Location
.
locationid
.
ToInt
());
if
(
loca
!=
null
)
{
throw
new
BadRequestException
(
RequestEnum
.
DataExist
);
}
}
var
ids
=
new
List
<
int
>();
foreach
(
var
locationType
in
sonLocationTypes
)
{
var
Location
=
req
.
locations
.
FirstOrDefault
(
q
=>
q
.
id
==
locationType
.
id
);
if
(
Location
==
null
)
{
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
//TODO
}
var
tmp
=
location
.
Get
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
id
==
Location
.
locationid
.
ToInt
());
tmp
.
status
=
req
.
status
==
(
int
)
RowState
.
Valid
?
(
int
)
RowState
.
Valid
:
(
int
)
RowState
.
Invalid
;
tmp
.
storageid
=
req
.
warehouseid
;
tmp
.
locationid
=
req
.
storeID
.
ToInt
();
tmp
.
realname
=
Location
.
val
;
if
(
tmp
.
parentid
==
0
)
{
tmp
.
name
=
$"
{
waveHouse
.
name
}
->
{
tmp
.
realname
}
"
;
}
location
.
Update
(
tmp
);
}
if
(
_unitOfWork
.
Commit
()
>
0
)
{
return
new
ObjectResult
(
CommonEnum
.
Succefull
);
}
else
{
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
}
}
private
IEnumerable
<
siger_wms_storage_location_type
>
GetSonTypes
(
int
id
,
List
<
siger_wms_storage_location_type
>
types
)
{
var
query
=
from
c
in
types
where
c
.
parentid
==
id
select
c
;
return
query
.
ToList
().
Concat
(
query
.
ToList
().
SelectMany
(
t
=>
GetSonTypes
(
t
.
id
,
types
)));
}
}
}
}
}
\ No newline at end of file
Server/Common/Siger.Middlelayer.Share/Enum/RequestEnum.cs
View file @
4835419a
...
@@ -1461,5 +1461,8 @@ namespace Siger.Middlelayer.Common
...
@@ -1461,5 +1461,8 @@ namespace Siger.Middlelayer.Common
UserNotExists
,
UserNotExists
,
[
Description
(
"默认展示已存在"
)]
[
Description
(
"默认展示已存在"
)]
DefaultDisplayExists
,
DefaultDisplayExists
,
[
Description
(
"未找到储位类别"
)]
LocationTypeNotFound
,
}
}
}
}
Server/Infrastructure/Repositories/Siger.Middlelayer.WmsRepository/Entities/siger_wms_storage_location.cs
View file @
4835419a
...
@@ -86,5 +86,7 @@ namespace Siger.Middlelayer.WmsRepository.Entities
...
@@ -86,5 +86,7 @@ namespace Siger.Middlelayer.WmsRepository.Entities
public
string
option
{
get
;
set
;
}
public
string
option
{
get
;
set
;
}
public
string
realname
{
get
;
set
;
}
public
string
realname
{
get
;
set
;
}
public
int
locationid
{
get
;
set
;
}
}
}
}
}
Server/Infrastructure/Repositories/Siger.Middlelayer.WmsRepository/Request/RequestAddLocation.cs
View file @
4835419a
using
Siger.Middlelayer.Common
;
using
Siger.Middlelayer.Common
;
using
System.Collections.Generic
;
namespace
Siger.Middlelayer.WmsRepository.Request
namespace
Siger.Middlelayer.WmsRepository.Request
{
{
...
@@ -13,4 +14,41 @@ namespace Siger.Middlelayer.WmsRepository.Request
...
@@ -13,4 +14,41 @@ namespace Siger.Middlelayer.WmsRepository.Request
public
LocationTypeEnum
type
{
get
;
set
;
}
public
LocationTypeEnum
type
{
get
;
set
;
}
}
}
public
class
RequestAddLocationModel
{
/// <summary>
/// 仓库ID
/// </summary>
public
int
warehouseid
{
get
;
set
;
}
/// <summary>
/// 储位ID
/// </summary>
public
string
storeID
{
get
;
set
;
}
/// <summary>
/// 是否停用0:停用 1:启用
/// </summary>
public
int
status
{
get
;
set
;
}
public
List
<
LocationModel
>
locations
{
get
;
set
;
}
=
new
List
<
LocationModel
>();
}
public
class
LocationModel
{
/// <summary>
/// 储位类别ID
/// </summary>
public
int
id
{
get
;
set
;
}
/// <summary>
/// 储位类别名称
/// </summary>
//public string name { get; set; }
/// <summary>
/// 储位名称
/// </summary>
public
string
val
{
get
;
set
;
}
/// <summary>
/// 储位自增ID
/// </summary>
public
string
locationid
{
get
;
set
;
}
}
}
}
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