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
e333ca53
Commit
e333ca53
authored
Feb 01, 2021
by
xin.yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
13ff601f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
9 deletions
+49
-9
LocationController.cs
Server/Apis/Siger.ApiWMS/Controllers/LocationController.cs
+49
-9
No files found.
Server/Apis/Siger.ApiWMS/Controllers/LocationController.cs
View file @
e333ca53
...
...
@@ -995,6 +995,7 @@ namespace Siger.ApiWMS.Controllers
}
var
ids
=
new
List
<
int
>();
var
delIds
=
new
List
<
int
>();
var
parentid
=
0
;
foreach
(
var
locationType
in
sonLocationTypes
)
{
...
...
@@ -1028,7 +1029,7 @@ namespace Siger.ApiWMS.Controllers
status
=
req
.
status
==
(
int
)
RowState
.
Valid
?
(
int
)
RowState
.
Valid
:
(
int
)
RowState
.
Invalid
,
locationid
=
Location
.
id
==
locationTypeId
?
req
.
storeID
.
ToInt
()
:
0
};
parentid
=
InsertLocation
(
tmp
,
waveHouse
.
name
);
parentid
=
InsertLocation
(
tmp
,
waveHouse
.
name
,
delIds
);
if
(
parentid
>
0
)
{
ids
.
Add
(
parentid
);
...
...
@@ -1043,7 +1044,7 @@ namespace Siger.ApiWMS.Controllers
{
tmp
.
status
=
req
.
status
==
(
int
)
RowState
.
Valid
?
(
int
)
RowState
.
Valid
:
(
int
)
RowState
.
Invalid
;
tmp
.
locationid
=
Location
.
id
==
locationTypeId
?
req
.
storeID
.
ToInt
()
:
0
;
parentid
=
InsertLocation
(
tmp
,
waveHouse
.
name
);
parentid
=
InsertLocation
(
tmp
,
waveHouse
.
name
,
delIds
);
if
(
parentid
>
0
)
{
continue
;
...
...
@@ -1056,7 +1057,7 @@ namespace Siger.ApiWMS.Controllers
}
return
new
ObjectResult
(
CommonEnum
.
Succefull
);
}
private
int
InsertLocation
(
siger_wms_storage_location
tmp
,
string
waveHouseName
)
private
int
InsertLocation
(
siger_wms_storage_location
tmp
,
string
waveHouseName
,
List
<
int
>
delIds
)
{
int
id
=
tmp
.
id
;
if
(
id
==
0
)
...
...
@@ -1066,6 +1067,10 @@ namespace Siger.ApiWMS.Controllers
{
return
id
;
}
else
{
delIds
.
Add
(
tmp
.
id
);
}
}
//更新编号、层级名称
...
...
@@ -1165,21 +1170,24 @@ namespace Siger.ApiWMS.Controllers
//}
}
var
ids
=
new
List
<
int
>();
//只有新增的数据才会加进这个列表,可以用于判断是否有新增数据
var
ids
=
new
List
<
int
>();
var
delIds
=
new
List
<
int
>();
var
parentid
=
0
;
foreach
(
var
locationType
in
sonLocationTypes
)
{
var
Location
=
req
.
storeArr
.
FirstOrDefault
(
q
=>
q
.
id
==
locationType
.
id
);
if
(
Location
==
null
)
{
DelInsertFailLocations
(
delIds
);
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
}
var
tmp1
=
location
.
Get
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
&&
q
.
realname
==
Location
.
val
&&
q
.
typeid
==
locationType
.
id
&&
q
.
parentid
==
parentid
&&
q
.
storageid
==
req
.
warehouseid
&&
q
.
id
!=
Location
.
locationid
.
ToInt
());
var
tmp
=
location
.
Get
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
&&
q
.
realname
==
Location
.
val
&&
q
.
typeid
==
locationType
.
id
&&
q
.
parentid
==
parentid
&&
q
.
storageid
==
req
.
warehouseid
&&
q
.
id
==
Location
.
locationid
.
ToInt
());
var
tmp
=
location
.
Get
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
&&
(
q
.
realname
!=
Location
.
val
&&
q
.
typeid
==
locationType
.
id
||
q
.
realname
==
Location
.
val
)
&&
q
.
typeid
==
locationType
.
id
&&
q
.
parentid
==
parentid
&&
q
.
storageid
==
req
.
warehouseid
&&
q
.
id
==
Location
.
locationid
.
ToInt
());
if
(
tmp1
!=
null
&&
tmp1
.
typeid
==
locationTypeId
&&
!
ids
.
Any
()
&&
tmp1
.
name
==
Location
.
val
)
{
DelInsertFailLocations
(
delIds
);
throw
new
BadRequestException
(
RequestEnum
.
DataExist
);
}
if
(
tmp
==
null
)
...
...
@@ -1207,10 +1215,11 @@ namespace Siger.ApiWMS.Controllers
q
.
locationid
==
req
.
storeID
.
ToInt
()
&&
q
.
storageid
==
req
.
warehouseid
);
if
(
locationIdExist
!=
null
)
{
DelInsertFailLocations
(
delIds
);
throw
new
BadRequestException
(
RequestEnum
.
IDExist
);
}
}
parentid
=
InsertLocation
(
tmp
,
waveHouse
.
name
);
parentid
=
InsertLocation
(
tmp
,
waveHouse
.
name
,
delIds
);
if
(
parentid
>
0
)
{
ids
.
Add
(
parentid
);
...
...
@@ -1218,35 +1227,66 @@ namespace Siger.ApiWMS.Controllers
}
else
{
DelInsertFailLocations
(
delIds
);
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
}
}
else
{
if
(
Location
.
id
==
locationTypeId
)
if
(
Location
.
id
==
locationTypeId
&&
!
delIds
.
Any
())
//如果父级无新增,delIds无数据代表父级无新增
{
var
locationIdExist
=
location
.
Get
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
&&
q
.
typeid
==
locationTypeId
&&
q
.
locationid
==
req
.
storeID
.
ToInt
()
&&
q
.
id
!=
Location
.
locationid
.
ToInt
()
&&
q
.
storageid
==
req
.
warehouseid
);
if
(
locationIdExist
!=
null
)
{
DelInsertFailLocations
(
delIds
);
throw
new
BadRequestException
(
RequestEnum
.
IDExist
);
}
var
locationIdExist1
=
location
.
Get
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
&&
q
.
typeid
==
locationTypeId
&&
q
.
realname
==
Location
.
val
&&
q
.
id
!=
Location
.
locationid
.
ToInt
()
&&
q
.
storageid
==
req
.
warehouseid
);
if
(
locationIdExist1
!=
null
)
{
DelInsertFailLocations
(
delIds
);
throw
new
BadRequestException
(
RequestEnum
.
DataExist
);
}
}
else
if
(
Location
.
id
==
locationTypeId
)
//如果父级有新增
{
var
locationIdExist
=
location
.
Get
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
&&
q
.
typeid
==
locationTypeId
&&
q
.
locationid
==
req
.
storeID
.
ToInt
()
&&
q
.
id
!=
Location
.
locationid
.
ToInt
()
&&
q
.
storageid
==
req
.
warehouseid
);
if
(
locationIdExist
!=
null
)
{
DelInsertFailLocations
(
delIds
);
throw
new
BadRequestException
(
RequestEnum
.
IDExist
);
}
}
tmp
.
status
=
req
.
status
==
(
int
)
RowState
.
Valid
?
(
int
)
RowState
.
Valid
:
(
int
)
RowState
.
Invalid
;
tmp
.
locationid
=
Location
.
id
==
locationTypeId
?
req
.
storeID
.
ToInt
()
:
0
;
parentid
=
InsertLocation
(
tmp
,
waveHouse
.
name
);
tmp
.
realname
=
Location
.
val
;
parentid
=
InsertLocation
(
tmp
,
waveHouse
.
name
,
delIds
);
if
(
parentid
>
0
)
{
continue
;
}
else
{
DelInsertFailLocations
(
delIds
);
throw
new
BadRequestException
(
CommonEnum
.
Fail
);
}
}
}
return
new
ObjectResult
(
CommonEnum
.
Succefull
);
}
private
void
DelInsertFailLocations
(
List
<
int
>
DelIds
)
{
foreach
(
var
id
in
DelIds
)
{
var
entity
=
location
.
Get
(
q
=>
q
.
projectid
==
ProjectId
&&
q
.
status
==
(
int
)
RowState
.
Valid
&&
id
==
q
.
id
);
entity
.
status
=
(
int
)
RowState
.
Invalid
;
location
.
Update
(
entity
);
_unitOfWork
.
Commit
();
}
}
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
;
...
...
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