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
abc0a987
Commit
abc0a987
authored
Jan 23, 2021
by
xin.yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some update
parent
9964d254
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
LocationController.cs
Server/Apis/Siger.ApiWMS/Controllers/LocationController.cs
+70
-0
No files found.
Server/Apis/Siger.ApiWMS/Controllers/LocationController.cs
View file @
abc0a987
...
...
@@ -1127,5 +1127,74 @@ namespace Siger.ApiWMS.Controllers
return
query
.
ToList
().
Concat
(
query
.
ToList
().
SelectMany
(
t
=>
GetSonTypes
(
t
.
id
,
types
)));
}
[
HttpGet
]
public
IActionResult
GetLocationTree
(
int
warehouseid
)
{
var
locationTypes
=
locationtype
.
GetList
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
).
ToList
();
var
sonLocationTypes
=
GetSonTypes
(
0
,
locationTypes
).
ToList
();
var
lastLocationId
=
sonLocationTypes
.
LastOrDefault
()?.
id
??
0
;
var
allLocas
=
location
.
GetList
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
).
ToList
();
var
locations
=
allLocas
.
Where
(
q
=>
q
.
typeid
==
lastLocationId
);
if
(
warehouseid
>
0
)
{
locations
=
locations
.
Where
(
q
=>
q
.
storageid
==
warehouseid
);
}
var
locationTreeList
=
new
List
<
LevelSectionTree
>();
foreach
(
var
loca
in
locations
)
{
var
locas
=
GetParentLocations
(
loca
.
id
,
allLocas
.
Select
(
q
=>
new
LevelSectionTree
{
id
=
q
.
id
,
pid
=
q
.
parentid
,
title
=
q
.
name
,
name
=
q
.
name
}));
locationTreeList
.
AddRange
(
locas
);
}
var
locationModels
=
locations
.
Select
(
q
=>
new
LevelSectionTree
{
id
=
q
.
id
,
pid
=
q
.
parentid
,
title
=
q
.
name
,
name
=
q
.
name
}).
ToList
();
var
locationTree
=
locationTreeList
.
GroupBy
(
q
=>
q
.
id
).
Select
(
q
=>
q
.
FirstOrDefault
()).
ToList
();
return
new
ObjectResult
(
ConvertToTree
(
locationTree
));
}
private
IEnumerable
<
LevelSectionTree
>
GetParentLocations
(
int
pid
,
IEnumerable
<
LevelSectionTree
>
types
)
{
var
query
=
from
c
in
types
where
c
.
id
==
pid
select
c
;
return
query
.
ToList
().
Concat
(
query
.
ToList
().
SelectMany
(
t
=>
GetParentLocations
(
t
.
pid
,
types
)));
}
private
IList
<
LevelSectionTree
>
ConvertToTree
(
IEnumerable
<
LevelSectionTree
>
models
)
{
var
section
=
new
Dictionary
<
int
,
LevelSectionTree
>();
foreach
(
var
item
in
models
)
{
section
.
Add
(
item
.
id
,
item
);
}
var
result
=
new
List
<
LevelSectionTree
>();
foreach
(
var
item
in
section
.
Values
)
{
if
(
item
.
pid
==
0
)
{
result
.
Add
(
item
);
}
else
{
if
(
section
.
ContainsKey
(
item
.
pid
))
{
section
[
item
.
pid
].
AddChilrden
(
item
);
}
}
}
return
result
;
}
}
}
\ No newline at end of file
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