Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
performance
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zry
performance
Commits
c1d74936
Commit
c1d74936
authored
Jun 09, 2020
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug修改 - 二次绩效数据保存,删除重复数据
parent
be771d58
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
27 deletions
+57
-27
performance/Performance.Api/Controllers/SecondAllotController.cs
+2
-2
performance/Performance.Services/SecondAllotService.cs
+55
-25
No files found.
performance/Performance.Api/Controllers/SecondAllotController.cs
View file @
c1d74936
...
@@ -49,8 +49,8 @@ public ApiResponse List()
...
@@ -49,8 +49,8 @@ public ApiResponse List()
[
HttpPost
]
[
HttpPost
]
public
ApiResponse
SaveValue
(
int
secondid
,
[
FromBody
]
List
<
ag_fixatitem
>
request
)
public
ApiResponse
SaveValue
(
int
secondid
,
[
FromBody
]
List
<
ag_fixatitem
>
request
)
{
{
if
(
secondid
!=
0
&&
(
request
==
null
||
request
.
Count
==
0
))
//
if (secondid != 0 && (request == null || request.Count == 0))
secondAllotService
.
DelValue
(
secondid
,
request
);
//
secondAllotService.DelValue(secondid, request);
var
allotCount
=
request
.
Where
(
t
=>
t
.
AllotId
>
0
).
Select
(
t
=>
t
.
AllotId
).
Distinct
().
Count
();
var
allotCount
=
request
.
Where
(
t
=>
t
.
AllotId
>
0
).
Select
(
t
=>
t
.
AllotId
).
Distinct
().
Count
();
if
(
allotCount
!=
1
||
request
.
Any
(
t
=>
t
.
AllotId
==
0
))
if
(
allotCount
!=
1
||
request
.
Any
(
t
=>
t
.
AllotId
==
0
))
...
...
performance/Performance.Services/SecondAllotService.cs
View file @
c1d74936
...
@@ -538,51 +538,81 @@ public bool SaveValue(List<ag_fixatitem> request)
...
@@ -538,51 +538,81 @@ public bool SaveValue(List<ag_fixatitem> request)
var
second
=
perforAgsecondallotRepository
.
GetEntity
(
t
=>
t
.
Id
==
secondId
);
var
second
=
perforAgsecondallotRepository
.
GetEntity
(
t
=>
t
.
Id
==
secondId
);
if
(
second
==
null
)
if
(
second
==
null
)
throw
new
PerformanceException
(
"二次绩效ID不存在"
);
throw
new
PerformanceException
(
"二次绩效ID不存在"
);
var
fixatitems
=
perforAgfixatitemRepository
.
GetEntities
(
t
=>
t
.
SecondId
==
secondId
);
var
fixatitems
=
perforAgfixatitemRepository
.
GetEntities
(
t
=>
t
.
SecondId
==
secondId
);
foreach
(
var
item
in
request
)
var
result
=
DelValue
(
fixatitems
,
request
);
List
<
ag_fixatitem
>
update
=
new
List
<
ag_fixatitem
>(),
insert
=
new
List
<
ag_fixatitem
>();
if
(
fixatitems
!=
null
&&
fixatitems
.
Any
())
{
{
if
(
fixatitems
!=
null
&&
fixatitems
.
Any
(
t
=>
t
.
SecondId
==
secondId
&&
t
.
RowNumber
==
item
.
RowNumber
&&
t
.
ItemName
==
item
.
ItemName
))
foreach
(
var
item
in
request
)
{
var
cellItem
=
fixatitems
.
First
(
t
=>
t
.
SecondId
==
secondId
&&
t
.
RowNumber
==
item
.
RowNumber
&&
t
.
ItemName
==
item
.
ItemName
);
cellItem
.
ItemValue
=
item
.
ItemValue
;
cellItem
.
Sort
=
item
.
Sort
;
cellItem
.
SourceType
=
item
.
SourceType
;
cellItem
.
Type
=
item
.
Type
;
cellItem
.
UnitType
=
item
.
UnitType
;
cellItem
.
SpecialAttr
=
item
.
SpecialAttr
;
perforAgfixatitemRepository
.
Update
(
cellItem
);
}
else
{
{
perforAgfixatitemRepository
.
Add
(
item
);
if
(
fixatitems
.
Any
(
t
=>
t
.
RowNumber
==
item
.
RowNumber
&&
t
.
ItemName
==
item
.
ItemName
))
{
var
cellItem
=
fixatitems
.
FirstOrDefault
(
t
=>
t
.
RowNumber
==
item
.
RowNumber
&&
t
.
ItemName
==
item
.
ItemName
);
if
(
cellItem
==
null
)
continue
;
cellItem
.
ItemValue
=
item
.
ItemValue
;
cellItem
.
Sort
=
item
.
Sort
;
cellItem
.
SourceType
=
item
.
SourceType
;
cellItem
.
Type
=
item
.
Type
;
cellItem
.
UnitType
=
item
.
UnitType
;
cellItem
.
SpecialAttr
=
item
.
SpecialAttr
;
update
.
Add
(
cellItem
);
}
else
{
insert
.
Add
(
item
);
}
}
}
}
}
return
DelValue
(
second
.
Id
,
request
);
else
insert
=
request
;
result
=
perforAgfixatitemRepository
.
UpdateRange
(
update
.
ToArray
());
result
=
perforAgfixatitemRepository
.
AddRange
(
insert
.
ToArray
());
return
result
;
}
}
/// <summary>
/// <summary>
/// 删除未保存的历史数据
/// 删除未保存的历史数据
/// </summary>
/// </summary>
/// <param name="
secondId">
</param>
/// <param name="
fixatlist">数据库中查询到的值
</param>
/// <param name="fixatitems"></param>
/// <param name="fixatitems">
需要保存的数据
</param>
/// <returns></returns>
/// <returns></returns>
public
bool
DelValue
(
int
secondId
,
List
<
ag_fixatitem
>
fixatitems
)
public
bool
DelValue
(
List
<
ag_fixatitem
>
fixatlist
,
List
<
ag_fixatitem
>
fixatitems
)
{
{
if
(
secondId
==
0
)
var
result
=
true
;
throw
new
PerformanceException
(
"二次绩效Id无效"
);
// 提交数据为空时,删除所有数据
var
fixatlist
=
perforAgfixatitemRepository
.
GetEntities
(
t
=>
t
.
SecondId
==
secondId
);
if
(
fixatitems
==
null
||
fixatitems
.
Count
==
0
)
if
(
fixatitems
==
null
||
fixatitems
.
Count
==
0
)
{
{
return
perforAgfixatitemRepository
.
RemoveRange
(
fixatlist
.
ToArray
());
if
(
fixatlist
!=
null
&&
fixatlist
.
Any
())
result
=
perforAgfixatitemRepository
.
RemoveRange
(
fixatlist
.
ToArray
());
return
result
;
}
}
if
(
fixatlist
!=
null
&&
fixatlist
.
Any
())
{
var
groupData
=
fixatlist
.
GroupBy
(
t
=>
new
{
t
.
RowNumber
,
t
.
ItemName
}).
Select
(
t
=>
new
{
t
.
Key
.
RowNumber
,
t
.
Key
.
ItemName
,
Count
=
t
.
Count
(),
Id
=
t
.
Max
(
group
=>
group
.
ID
)
});
// 删除重复数据
if
(
groupData
.
Any
(
t
=>
t
.
Count
>
1
))
{
var
delData
=
fixatlist
.
Where
(
t
=>
!
groupData
.
Select
(
w
=>
w
.
Id
).
Contains
(
t
.
ID
));
int
flag
=
fixatlist
.
RemoveAll
(
t
=>
!
groupData
.
Select
(
w
=>
w
.
Id
).
Contains
(
t
.
ID
));
result
=
perforAgfixatitemRepository
.
RemoveRange
(
delData
.
ToArray
());
}
}
// 删除行号不存在的数据
var
saveRows
=
fixatitems
.
Select
(
t
=>
t
.
RowNumber
).
Distinct
();
var
saveRows
=
fixatitems
.
Select
(
t
=>
t
.
RowNumber
).
Distinct
();
var
delRows
=
fixatlist
.
Select
(
t
=>
t
.
RowNumber
).
Distinct
().
Except
(
saveRows
);
var
delRows
=
fixatlist
.
Select
(
t
=>
t
.
RowNumber
).
Distinct
().
Except
(
saveRows
);
if
(
delRows
!=
null
&&
delRows
.
Count
()
>
0
)
if
(
delRows
!=
null
&&
delRows
.
Count
()
>
0
)
re
turn
perforAgfixatitemRepository
.
RemoveRange
(
fixatlist
.
Where
(
t
=>
delRows
.
Contains
(
t
.
RowNumber
)).
ToArray
());
re
sult
=
perforAgfixatitemRepository
.
RemoveRange
(
fixatlist
.
Where
(
t
=>
delRows
.
Contains
(
t
.
RowNumber
)).
ToArray
());
return
true
;
return
result
;
}
}
/// <summary>
/// <summary>
...
...
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