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
9c91da6a
Commit
9c91da6a
authored
Apr 24, 2022
by
ruyun.zhang@suvalue.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
核算单元校验优化
parent
d2a79135
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
82 additions
and
25 deletions
+82
-25
performance/Performance.Api/Controllers/ConfigController.cs
+17
-8
performance/Performance.Services/ConfigService.cs
+65
-17
No files found.
performance/Performance.Api/Controllers/ConfigController.cs
View file @
9c91da6a
...
@@ -626,8 +626,14 @@ public ApiResponse GetAccountingList([FromBody] AccoungingRequest request)
...
@@ -626,8 +626,14 @@ public ApiResponse GetAccountingList([FromBody] AccoungingRequest request)
[
HttpPost
]
[
HttpPost
]
public
ApiResponse
AccountingInsert
([
FromBody
]
cof_accounting
request
)
public
ApiResponse
AccountingInsert
([
FromBody
]
cof_accounting
request
)
{
{
if
(
request
.
AllotId
==
0
||
string
.
IsNullOrEmpty
(
request
.
Code
)
||
string
.
IsNullOrEmpty
(
request
.
UnitType
)
||
string
.
IsNullOrEmpty
(
request
.
AccountingUnit
))
if
(
request
.
AllotId
==
0
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"参数不允许为空"
);
return
new
ApiResponse
(
ResponseType
.
ParameterError
);
if
(
string
.
IsNullOrEmpty
(
request
.
UnitType
)
||
string
.
IsNullOrEmpty
(
request
.
AccountingUnit
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
"核算单元或组别必须填写"
);
if
(
string
.
IsNullOrEmpty
(
request
.
Code
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
"核算单元编码必须填写"
);
var
drugprop
=
_configService
.
AccountingInsert
(
request
);
var
drugprop
=
_configService
.
AccountingInsert
(
request
);
return
new
ApiResponse
(
ResponseType
.
OK
,
drugprop
);
return
new
ApiResponse
(
ResponseType
.
OK
,
drugprop
);
...
@@ -642,9 +648,16 @@ public ApiResponse AccountingInsert([FromBody] cof_accounting request)
...
@@ -642,9 +648,16 @@ public ApiResponse AccountingInsert([FromBody] cof_accounting request)
[
HttpPost
]
[
HttpPost
]
public
ApiResponse
AccountingUpdate
([
FromBody
]
cof_accounting
request
)
public
ApiResponse
AccountingUpdate
([
FromBody
]
cof_accounting
request
)
{
{
if
(
request
.
AllotId
==
0
||
string
.
IsNullOrEmpty
(
request
.
UnitType
)
||
string
.
IsNullOrEmpty
(
request
.
AccountingUnit
)
)
if
(
request
.
AllotId
==
0
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
);
return
new
ApiResponse
(
ResponseType
.
ParameterError
);
if
(
string
.
IsNullOrEmpty
(
request
.
UnitType
)
||
string
.
IsNullOrEmpty
(
request
.
AccountingUnit
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
"核算单元或组别必须填写"
);
if
(
string
.
IsNullOrEmpty
(
request
.
Code
))
return
new
ApiResponse
(
ResponseType
.
Fail
,
"核算单元编码必须填写"
);
var
drugprop
=
_configService
.
AccountingUpdate
(
request
);
var
drugprop
=
_configService
.
AccountingUpdate
(
request
);
return
new
ApiResponse
(
ResponseType
.
OK
,
drugprop
);
return
new
ApiResponse
(
ResponseType
.
OK
,
drugprop
);
}
}
...
@@ -700,11 +713,7 @@ public ApiResponse BatchCheckAccounting(int allotId)
...
@@ -700,11 +713,7 @@ public ApiResponse BatchCheckAccounting(int allotId)
[
HttpPost
]
[
HttpPost
]
public
ApiResponse
BatchSaveAccounting
(
int
allotId
,
[
FromBody
]
SaveCollectData
request
)
public
ApiResponse
BatchSaveAccounting
(
int
allotId
,
[
FromBody
]
SaveCollectData
request
)
{
{
var
result
=
_configService
.
BatchSaveAccounting
(
allotId
,
request
);
return
_configService
.
BatchSaveAccounting
(
allotId
,
request
);
if
(
result
)
return
new
ApiResponse
(
ResponseType
.
OK
);
else
return
new
ApiResponse
(
ResponseType
.
Error
,
"请选择正确的核算组别"
);
}
}
...
...
performance/Performance.Services/ConfigService.cs
View file @
9c91da6a
...
@@ -796,7 +796,7 @@ public List<cof_accounting> GetAccountingList(AccoungingRequest request)
...
@@ -796,7 +796,7 @@ public List<cof_accounting> GetAccountingList(AccoungingRequest request)
/// <returns></returns>
/// <returns></returns>
public
cof_accounting
AccountingInsert
(
cof_accounting
request
)
public
cof_accounting
AccountingInsert
(
cof_accounting
request
)
{
{
var
existed
=
cofaccountingRepository
.
GetEntity
(
w
=>
w
.
Code
==
request
.
Code
);
var
existed
=
cofaccountingRepository
.
GetEntity
(
w
=>
w
.
AllotId
==
request
.
AllotId
&&
w
.
Code
==
request
.
Code
);
if
(
existed
!=
null
)
throw
new
PerformanceException
(
"核算单元编码重复"
);
if
(
existed
!=
null
)
throw
new
PerformanceException
(
"核算单元编码重复"
);
existed
=
cofaccountingRepository
.
GetEntity
(
w
=>
w
.
AllotId
==
request
.
AllotId
&&
w
.
UnitType
==
request
.
UnitType
&&
w
.
AccountingUnit
==
request
.
AccountingUnit
);
existed
=
cofaccountingRepository
.
GetEntity
(
w
=>
w
.
AllotId
==
request
.
AllotId
&&
w
.
UnitType
==
request
.
UnitType
&&
w
.
AccountingUnit
==
request
.
AccountingUnit
);
...
@@ -807,7 +807,8 @@ public cof_accounting AccountingInsert(cof_accounting request)
...
@@ -807,7 +807,8 @@ public cof_accounting AccountingInsert(cof_accounting request)
AllotId
=
request
.
AllotId
,
AllotId
=
request
.
AllotId
,
Code
=
request
.
Code
,
Code
=
request
.
Code
,
UnitType
=
request
.
UnitType
,
UnitType
=
request
.
UnitType
,
AccountingUnit
=
request
.
AccountingUnit
AccountingUnit
=
request
.
AccountingUnit
,
IsVerify
=
1
,
};
};
if
(!
cofaccountingRepository
.
Add
(
entity
))
if
(!
cofaccountingRepository
.
Add
(
entity
))
throw
new
PerformanceException
(
"保存失败"
);
throw
new
PerformanceException
(
"保存失败"
);
...
@@ -825,10 +826,17 @@ public cof_accounting AccountingUpdate(cof_accounting request)
...
@@ -825,10 +826,17 @@ public cof_accounting AccountingUpdate(cof_accounting request)
if
(
null
==
entity
)
if
(
null
==
entity
)
throw
new
PerformanceException
(
$"ID不存在 :
{
request
.
Id
}
"
);
throw
new
PerformanceException
(
$"ID不存在 :
{
request
.
Id
}
"
);
var
existed
=
cofaccountingRepository
.
GetEntity
(
w
=>
w
.
Id
!=
request
.
Id
&&
w
.
AllotId
==
request
.
AllotId
&&
w
.
Code
==
request
.
Code
);
if
(
existed
!=
null
)
throw
new
PerformanceException
(
"核算单元编码重复"
);
existed
=
cofaccountingRepository
.
GetEntity
(
w
=>
w
.
Id
!=
request
.
Id
&&
w
.
AllotId
==
request
.
AllotId
&&
w
.
UnitType
==
request
.
UnitType
&&
w
.
AccountingUnit
==
request
.
AccountingUnit
);
if
(
existed
!=
null
)
throw
new
PerformanceException
(
"核算单元、核算组别已存在"
);
entity
.
AllotId
=
request
.
AllotId
;
entity
.
AllotId
=
request
.
AllotId
;
entity
.
Code
=
request
.
Code
;
entity
.
Code
=
request
.
Code
;
entity
.
UnitType
=
request
.
UnitType
;
entity
.
UnitType
=
request
.
UnitType
;
entity
.
AccountingUnit
=
request
.
AccountingUnit
;
entity
.
AccountingUnit
=
request
.
AccountingUnit
;
entity
.
IsVerify
=
1
;
if
(!
cofaccountingRepository
.
Update
(
entity
))
if
(!
cofaccountingRepository
.
Update
(
entity
))
throw
new
PerformanceException
(
"保存失败"
);
throw
new
PerformanceException
(
"保存失败"
);
...
@@ -877,7 +885,7 @@ public HandsonTable GetBatchAccountingStructrue(int AllotId)
...
@@ -877,7 +885,7 @@ public HandsonTable GetBatchAccountingStructrue(int AllotId)
return
result
;
return
result
;
}
}
public
bool
BatchSaveAccounting
(
int
allotId
,
SaveCollectData
request
)
public
ApiResponse
BatchSaveAccounting
(
int
allotId
,
SaveCollectData
request
)
{
{
var
dicData
=
CreateDataRow
(
0
,
allotId
,
request
,
Accounting
);
var
dicData
=
CreateDataRow
(
0
,
allotId
,
request
,
Accounting
);
if
(
dicData
==
null
||
!
dicData
.
Any
())
throw
new
PerformanceException
(
"未提交数据"
);
if
(
dicData
==
null
||
!
dicData
.
Any
())
throw
new
PerformanceException
(
"未提交数据"
);
...
@@ -886,19 +894,60 @@ public bool BatchSaveAccounting(int allotId, SaveCollectData request)
...
@@ -886,19 +894,60 @@ public bool BatchSaveAccounting(int allotId, SaveCollectData request)
var
unitType
=
EnumHelper
.
GetItems
<
UnitType
>().
Select
(
w
=>
w
.
Description
.
Replace
(
"行政后勤"
,
"行政工勤"
)).
ToArray
();
var
unitType
=
EnumHelper
.
GetItems
<
UnitType
>().
Select
(
w
=>
w
.
Description
.
Replace
(
"行政后勤"
,
"行政工勤"
)).
ToArray
();
var
json
=
JsonHelper
.
Serialize
(
dicData
);
var
json
=
JsonHelper
.
Serialize
(
dicData
);
var
accounts
=
JsonHelper
.
Deserialize
<
List
<
cof_accounting
>>(
json
);
var
accounts
=
JsonHelper
.
Deserialize
<
List
<
cof_accounting
>>(
json
)
.
Where
(
w
=>
!
string
.
IsNullOrEmpty
(
w
.
Code
)
||
!
string
.
IsNullOrEmpty
(
w
.
UnitType
)
||
!
string
.
IsNullOrEmpty
(
w
.
AccountingUnit
))
if
(
accounts
.
Any
(
w
=>
string
.
IsNullOrEmpty
(
w
.
Code
)))
throw
new
PerformanceException
(
"核算单元编码有空值"
);
.
ToList
();
if
(
accounts
.
GroupBy
(
t
=>
t
.
Code
).
Any
(
w
=>
w
.
Count
()
>
1
))
throw
new
PerformanceException
(
"核算单元编码有重复值"
);
if
(
accounts
.
Any
(
w
=>
string
.
IsNullOrEmpty
(
w
.
AccountingUnit
)))
throw
new
PerformanceException
(
"核算单元有空值"
);
if
(
accounts
.
Any
(
w
=>
string
.
IsNullOrEmpty
(
w
.
UnitType
)))
throw
new
PerformanceException
(
"核算单元类型有空值"
);
var
grouped
=
accounts
.
GroupBy
(
t
=>
new
{
t
.
AccountingUnit
,
t
.
UnitType
});
List
<
Dictionary
<
string
,
string
>>
error
=
new
List
<
Dictionary
<
string
,
string
>>();
for
(
int
i
=
0
;
i
<
accounts
.
Count
();
i
++)
if
(
grouped
.
Any
(
w
=>
w
.
Count
()
>
1
))
throw
new
PerformanceException
(
"核算单元、核算单元类型有重复值"
);
{
if
(
string
.
IsNullOrEmpty
(
accounts
[
i
].
Code
)
||
string
.
IsNullOrEmpty
(
accounts
[
i
].
UnitType
)
||
string
.
IsNullOrEmpty
(
accounts
[
i
].
AccountingUnit
))
{
error
.
Add
(
new
Dictionary
<
string
,
string
>
{
{
"行号"
,
$"第
{
i
+
1
}
行"
},
{
"核算单元编码"
,
accounts
[
i
].
Code
??
""
},
{
"核算组别"
,
accounts
[
i
].
UnitType
??
""
},
{
"核算单元"
,
accounts
[
i
].
AccountingUnit
??
""
},
{
"错误原因"
,
"“关键信息缺失”请补全或删除"
},
});
}
else
if
(
accounts
.
Count
(
w
=>
w
.
Code
==
accounts
[
i
].
Code
)
>
1
)
{
error
.
Add
(
new
Dictionary
<
string
,
string
>
{
{
"行号"
,
$"第
{
i
+
1
}
行"
},
{
"核算单元编码"
,
accounts
[
i
].
Code
??
""
},
{
"核算组别"
,
accounts
[
i
].
UnitType
??
""
},
{
"核算单元"
,
accounts
[
i
].
AccountingUnit
??
""
},
{
"错误原因"
,
"“核算单元编码”重复值,请修改或删除"
},
});
}
else
if
(
accounts
.
Count
(
w
=>
w
.
AccountingUnit
==
accounts
[
i
].
AccountingUnit
&&
w
.
UnitType
==
accounts
[
i
].
UnitType
)
>
1
)
{
error
.
Add
(
new
Dictionary
<
string
,
string
>
{
{
"行号"
,
$"第
{
i
+
1
}
行"
},
{
"核算单元编码"
,
accounts
[
i
].
Code
??
""
},
{
"核算组别"
,
accounts
[
i
].
UnitType
??
""
},
{
"核算单元"
,
accounts
[
i
].
AccountingUnit
??
""
},
{
"错误原因"
,
"“核算组别/核算单元”重复,请修改或删除"
},
});
}
else
if
(
getAccounts
.
Any
(
w
=>
w
.
Code
!=
accounts
[
i
].
Code
&&
w
.
AccountingUnit
==
accounts
[
i
].
AccountingUnit
&&
w
.
UnitType
==
accounts
[
i
].
UnitType
))
{
error
.
Add
(
new
Dictionary
<
string
,
string
>
{
{
"行号"
,
$"第
{
i
+
1
}
行"
},
{
"核算单元编码"
,
accounts
[
i
].
Code
??
""
},
{
"核算组别"
,
accounts
[
i
].
UnitType
??
""
},
{
"核算单元"
,
accounts
[
i
].
AccountingUnit
??
""
},
{
"错误原因"
,
"“核算组别/核算单元”重复但“核算单元编码”不同,请修改或删除"
},
});
}
}
if
(
error
.
Count
>
0
)
return
new
ApiResponse
(
ResponseType
.
WarningTable
,
"验证不通过,当前操作已拒绝"
,
error
);
var
delAccounts
=
new
List
<
cof_accounting
>();
var
delAccounts
=
new
List
<
cof_accounting
>();
...
@@ -920,8 +969,7 @@ public bool BatchSaveAccounting(int allotId, SaveCollectData request)
...
@@ -920,8 +969,7 @@ public bool BatchSaveAccounting(int allotId, SaveCollectData request)
});
});
cofaccountingRepository
.
AddRange
(
accounts
.
ToArray
());
cofaccountingRepository
.
AddRange
(
accounts
.
ToArray
());
}
}
return
new
ApiResponse
(
ResponseType
.
OK
);
return
true
;
}
}
public
bool
BatchCheckAccounting
(
int
allotId
)
public
bool
BatchCheckAccounting
(
int
allotId
)
...
...
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