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
710905d9
Commit
710905d9
authored
Nov 04, 2021
by
钟博
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自定义表功能显示,保存
parent
1964832e
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
309 additions
and
6 deletions
+309
-6
performance/Performance.Api/Controllers/ConfigController.cs
+60
-0
performance/Performance.Api/wwwroot/Performance.Api.xml
+21
-0
performance/Performance.DtoModels/Request/CustomRequest.cs
+39
-0
performance/Performance.DtoModels/SaveCollectData.cs
+7
-1
performance/Performance.Repository/PerforReportRepository .cs
+53
-1
performance/Performance.Services/ConfigService.cs
+129
-4
No files found.
performance/Performance.Api/Controllers/ConfigController.cs
View file @
710905d9
...
...
@@ -851,5 +851,64 @@ public ApiResponse CopyDropDown()
};
;
return
new
ApiResponse
(
ResponseType
.
OK
,
result
);
}
/// <summary>
/// 自定义表Heads表头
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
HttpPost
(
"customheads"
)]
public
ApiResponse
CustomHeads
([
FromBody
]
CustomRequest
request
)
{
if
(
string
.
IsNullOrEmpty
(
request
.
TableName
))
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"表名为空"
);
var
result
=
_configService
.
QueryHandsCustom
(
request
.
TableName
);
if
(
result
==
null
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"不符合规范"
);
else
return
new
ApiResponse
(
ResponseType
.
OK
,
result
);
}
/// <summary>
/// 自定义表显示
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
HttpPost
(
"getcustomlist"
)]
public
ApiResponse
GetCustomList
([
FromBody
]
CustomPagingRequest
request
)
{
var
allot
=
_allotService
.
GetAllot
(
request
.
AllotId
);
if
(
allot
==
null
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"AllotID错误"
);
var
result
=
_configService
.
QueryCustom
(
request
);
if
(
result
.
isNorm
)
return
new
ApiResponse
(
ResponseType
.
OK
,
result
);
else
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"不符合规范"
);
}
/// <summary>
/// 保存自定义表数据
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
Route
(
"savecustom"
)]
[
HttpPost
]
public
ApiResponse
BatchSaveCustom
([
FromBody
]
SaveCustomData
request
)
{
var
allot
=
_allotService
.
GetAllot
(
request
.
AllotId
);
if
(
allot
==
null
)
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"AllotID错误"
);
else
if
(
string
.
IsNullOrEmpty
(
request
.
TableName
))
return
new
ApiResponse
(
ResponseType
.
ParameterError
,
"表名为空"
);
var
result
=
_configService
.
SaveCustomTable
(
request
);
if
(
result
)
return
new
ApiResponse
(
ResponseType
.
OK
);
else
return
new
ApiResponse
(
ResponseType
.
Error
);
}
}
}
\ No newline at end of file
performance/Performance.Api/wwwroot/Performance.Api.xml
View file @
710905d9
...
...
@@ -857,6 +857,27 @@
<param
name=
"request"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.ConfigController.CustomHeads(Performance.DtoModels.CustomRequest)"
>
<summary>
自定义表Heads表头
</summary>
<param
name=
"request"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.ConfigController.GetCustomList(Performance.DtoModels.CustomPagingRequest)"
>
<summary>
自定义表显示
</summary>
<param
name=
"request"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.ConfigController.BatchSaveCustom(Performance.DtoModels.SaveCustomData)"
>
<summary>
保存自定义表数据
</summary>
<param
name=
"request"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.CostTransferController.SubmitApplications(Performance.DtoModels.CostTransferRequest)"
>
<summary>
申请划拨
...
...
performance/Performance.DtoModels/Request/CustomRequest.cs
0 → 100644
View file @
710905d9
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.DtoModels
{
public
class
CustomRequest
{
public
int
AllotId
{
get
;
set
;
}
public
string
TableName
{
get
;
set
;
}
}
public
class
CustomPagingRequest
:
CustomRequest
{
public
int
PageIndex
{
get
;
set
;
}
=
1
;
public
int
PageSize
{
get
;
set
;
}
=
20
;
}
public
class
CustonPagingData
{
public
List
<
dynamic
>
DataList
{
get
;
set
;
}
public
int
TotalCount
{
get
;
set
;
}
}
public
class
CustomResponse
{
public
List
<
Heads
>
Heads
{
get
;
set
;
}
public
CustonPagingData
Datas
{
get
;
set
;
}
public
bool
isNorm
{
get
;
set
;
}
=
true
;
}
public
class
Heads
{
public
string
Cloumn
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
}
}
performance/Performance.DtoModels/SaveCollectData.cs
View file @
710905d9
...
...
@@ -22,5 +22,11 @@ public class UserCollectData
public
new
string
[][]
Data
{
get
;
set
;
}
}
public
class
SaveCustomData
{
public
int
AllotId
{
get
;
set
;
}
public
string
TableName
{
get
;
set
;
}
public
string
[]
ColHeaders
{
get
;
set
;
}
public
new
string
[][]
Data
{
get
;
set
;
}
}
}
performance/Performance.Repository/PerforReportRepository .cs
View file @
710905d9
using
Performance.DtoModels
;
using
Microsoft.EntityFrameworkCore
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
System.Collections.Generic
;
using
System.Linq
;
...
...
@@ -395,5 +396,56 @@ public List<dynamic> QueryCompute(int allotId, string viewName)
return
DapperQuery
<
dynamic
>(
sql
,
new
{
allotId
})?.
ToList
();
}
public
CustonPagingData
QueryCustom
(
CustomPagingRequest
request
)
{
var
result
=
new
CustonPagingData
();
var
sql
=
$@"SELECT * FROM
{
request
.
TableName
}
WHERE AllotId = @AllotId LIMIT
{(
request
.
PageIndex
-
1
)
*
request
.
PageSize
}
,
{
request
.
PageSize
}
"
;
result
.
DataList
=
DapperQuery
<
dynamic
>(
sql
,
new
{
request
.
AllotId
})?.
ToList
();
sql
=
$@"SELECT COUNT(*) FROM
{
request
.
TableName
}
WHERE AllotId = @AllotId "
;
result
.
TotalCount
=
DapperQuery
<
int
>(
sql
,
new
{
request
.
AllotId
})?.
FirstOrDefault
()
??
0
;
return
result
;
}
public
bool
QueryIsAllotId
(
string
tableName
)
{
var
database
=
context
.
Database
.
GetDbConnection
().
Database
;
var
sql
=
$@"SELECT column_name FROM information_schema.COLUMNS s
WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND column_name='allotId';"
;
var
isExist
=
DapperQuery
<
string
>(
sql
,
new
{
database
=
database
,
table_name
=
tableName
})?.
Count
()>
0
;
return
isExist
;
}
public
List
<
dynamic
>
QueryCustomColumn
(
string
tableName
)
{
var
database
=
context
.
Database
.
GetDbConnection
().
Database
;
var
sql
=
$@"SELECT column_name,column_comment FROM information_schema.`COLUMNS` WHERE table_schema = @table_schema AND table_name = @table_name AND COLUMN_KEY <> 'PRI' "
;
var
result
=
DapperQuery
<
dynamic
>(
sql
,
new
{
table_schema
=
database
,
table_name
=
tableName
})?.
ToList
();
return
result
;
}
public
bool
CreatCustom
(
int
AllotId
,
string
tableName
,
List
<
dynamic
>
datas
)
{
var
sql
=
$@"DELETE FROM
{
tableName
}
WHERE allotId=@AllotId "
;
Execute
(
sql
,
new
{
AllotId
});
var
database
=
context
.
Database
.
GetDbConnection
().
Database
;
sql
=
$@"SELECT column_name FROM information_schema.COLUMNS s
WHERE table_name = @table_name AND TABLE_SCHEMA = @database AND COLUMN_KEY <> 'PRI';"
;
var
columns
=
DapperQuery
<
string
>(
sql
,
new
{
database
=
database
,
table_name
=
tableName
})?.
ToList
();
sql
=
$"INSERT INTO
{
tableName
}
(
{
string
.
Join
(
","
,
columns
.
ToArray
())}
) VALUES(
{
string
.
Join
(
","
,
columns
.
Select
(
t
=>
"@"
+
t
))}
);"
;
var
success
=
Execute
(
sql
,
datas
);
if
(
success
>
0
)
return
true
;
else
return
false
;
}
}
}
performance/Performance.Services/ConfigService.cs
View file @
710905d9
...
...
@@ -41,6 +41,7 @@ public class ConfigService : IAutoInjection
private
readonly
PerforExmoduleRepository
perforExmoduleRepository
;
private
readonly
PerforCofdrugtypefactorRepository
cofdrugtypefactorRepository
;
private
readonly
PerforPerallotRepository
perallotRepository
;
private
readonly
PerforReportRepository
perforReport
;
public
ConfigService
(
PerforCofdirectorRepository
cofdirectorRepository
,
//PerforCofdrugpropRepository cofdrugpropRepository,
...
...
@@ -65,7 +66,8 @@ public class ConfigService : IAutoInjection
ExConfigService
exConfigService
,
PerforExmoduleRepository
perforExmoduleRepository
,
PerforCofdrugtypefactorRepository
cofdrugtypefactorRepository
,
PerforPerallotRepository
perallotRepository
)
PerforPerallotRepository
perallotRepository
,
PerforReportRepository
perforReport
)
{
this
.
_directorRepository
=
cofdirectorRepository
;
//this._drugpropRepository = cofdrugpropRepository;
...
...
@@ -91,6 +93,7 @@ public class ConfigService : IAutoInjection
this
.
perforExmoduleRepository
=
perforExmoduleRepository
;
this
.
cofdrugtypefactorRepository
=
cofdrugtypefactorRepository
;
this
.
perallotRepository
=
perallotRepository
;
this
.
perforReport
=
perforReport
;
}
#
endregion
...
...
@@ -1096,7 +1099,7 @@ public void NewCopy(CopyRequest request)
break
;
case
"drugTypes"
:
logger
.
LogInformation
(
$"copy drugTypes"
);
var
drugTypes
=
_drugtypeRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allot
.
ID
&&
t
.
HospitalId
==
allot
.
HospitalId
);
var
drugTypes
=
_drugtypeRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allot
.
ID
&&
t
.
HospitalId
==
allot
.
HospitalId
);
if
(
drugTypes
==
null
||
!
drugTypes
.
Any
())
{
drugTypes
=
_drugtypeRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allotId
)
??
_drugtypeRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
-
1
);
...
...
@@ -1109,7 +1112,7 @@ public void NewCopy(CopyRequest request)
break
;
case
"drugTypeDisburses"
:
logger
.
LogInformation
(
$"copy drugTypeDisburses"
);
var
drugTypeDisburses
=
drugtypeDisburseRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allot
.
ID
&&
t
.
HospitalId
==
allot
.
HospitalId
);
var
drugTypeDisburses
=
drugtypeDisburseRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allot
.
ID
&&
t
.
HospitalId
==
allot
.
HospitalId
);
if
(
drugTypeDisburses
==
null
||
!
drugTypeDisburses
.
Any
())
{
drugTypeDisburses
=
drugtypeDisburseRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
allotId
)
??
drugtypeDisburseRepository
.
GetEntities
(
t
=>
t
.
AllotID
==
-
1
);
...
...
@@ -1432,7 +1435,8 @@ public void SaveSecondaryAlias(SaveCollectData request)
{
// 创建固定数据列
Dictionary
<
string
,
string
>
baseData
=
CreateBaseData
(
request
,
config
,
r
);
baseData
.
Add
(
nameof
(
cof_hrp_department
.
AllotId
),
allotId
.
ToString
());
baseData
.
Add
(
nameof
(
cof_hrp_department
.
HospitalId
),
hospitalId
.
ToString
());
allData
.
Add
(
baseData
);
...
...
@@ -1769,5 +1773,126 @@ public void SaveDrugtypeFactor(DrugtypeFactorRequest request)
}
#
endregion
#
region
自定义表
public
HandsonTable
QueryHandsCustom
(
string
tableName
)
{
var
custom
=
perforReport
.
QueryCustomColumn
(
tableName
);
var
isExist
=
perforReport
.
QueryIsAllotId
(
tableName
);
if
(
custom
==
null
||
isExist
==
false
)
return
null
;
var
dicCustom
=
new
List
<
string
>();
for
(
int
i
=
0
;
i
<
custom
.
Count
();
i
++)
{
var
dic
=
((
IDictionary
<
string
,
object
>)
custom
.
ElementAt
(
i
)).
Values
;
dicCustom
.
Add
(
dic
.
ElementAt
(
1
).
ToString
());
}
var
result
=
new
HandsonTable
((
int
)
SheetType
.
Unidentifiable
,
dicCustom
.
ToArray
(),
dicCustom
.
Select
(
t
=>
new
collect_permission
{
HeadName
=
t
,
Visible
=
1
}).
ToList
());
return
result
;
}
public
bool
SaveCustomTable
(
SaveCustomData
request
)
{
var
custom
=
perforReport
.
QueryCustomColumn
(
request
.
TableName
);
var
dicCustom
=
new
Dictionary
<
string
,
object
>();
for
(
int
i
=
0
;
i
<
custom
.
Count
();
i
++)
{
var
dic
=
((
IDictionary
<
string
,
object
>)
custom
.
ElementAt
(
i
)).
Values
;
if
(
dic
.
ElementAt
(
0
).
ToString
().
ToLower
()
==
"allotid"
)
continue
;
dicCustom
.
Add
(
dic
.
ElementAt
(
0
).
ToString
(),
dic
.
ElementAt
(
1
).
ToString
());
}
var
dicData
=
CreateCustomRow
(
request
.
AllotId
,
request
,
dicCustom
);
var
datas
=
new
List
<
dynamic
>();
foreach
(
var
item
in
dicData
)
{
var
json
=
JsonHelper
.
Serialize
(
item
);
var
data
=
JsonHelper
.
Deserialize
<
dynamic
>(
json
);
var
convertData
=
JsonHelper
.
Deserialize
<
Dictionary
<
string
,
object
>>(
JsonHelper
.
Serialize
(
data
));
datas
.
Add
(
convertData
);
}
if
(
datas
.
Any
())
perforReport
.
CreatCustom
(
request
.
AllotId
,
request
.
TableName
,
datas
);
return
true
;
}
public
CustomResponse
QueryCustom
(
CustomPagingRequest
request
)
{
var
result
=
new
CustomResponse
();
var
heads
=
perforReport
.
QueryCustomColumn
(
request
.
TableName
);
var
isExist
=
perforReport
.
QueryIsAllotId
(
request
.
TableName
);
if
(
isExist
==
false
||
heads
==
null
)
{
result
.
isNorm
=
false
;
return
result
;
}
var
headList
=
new
List
<
Heads
>();
for
(
int
i
=
0
;
i
<
heads
.
Count
();
i
++)
{
var
dic
=
((
IDictionary
<
string
,
object
>)
heads
.
ElementAt
(
i
)).
Values
;
if
(
dic
.
ElementAt
(
0
).
ToString
().
ToLower
()
==
"allotid"
)
continue
;
var
head
=
new
Heads
();
head
.
Cloumn
=
dic
.
ElementAt
(
0
).
ToString
().
ToLower
();
head
.
Name
=
dic
.
ElementAt
(
1
).
ToString
();
headList
.
Add
(
head
);
}
result
.
Heads
=
headList
;
result
.
Datas
=
perforReport
.
QueryCustom
(
request
);
return
result
;
}
private
List
<
Dictionary
<
string
,
string
>>
CreateCustomRow
(
int
allotId
,
SaveCustomData
request
,
Dictionary
<
string
,
object
>
config
)
{
List
<
Dictionary
<
string
,
string
>>
allData
=
new
List
<
Dictionary
<
string
,
string
>>();
for
(
int
r
=
0
;
r
<
request
.
Data
.
Length
;
r
++)
{
// 创建固定数据列
Dictionary
<
string
,
string
>
baseData
=
CreateCustomData
(
request
,
config
,
r
);
baseData
.
Add
(
nameof
(
cof_hrp_department
.
AllotId
),
allotId
.
ToString
());
allData
.
Add
(
baseData
);
}
return
allData
;
}
private
Dictionary
<
string
,
string
>
CreateCustomData
(
SaveCustomData
request
,
Dictionary
<
string
,
object
>
config
,
int
rownumber
)
{
Dictionary
<
string
,
string
>
result
=
new
Dictionary
<
string
,
string
>();
for
(
int
c
=
0
;
c
<
request
.
ColHeaders
.
Length
;
c
++)
{
var
header
=
request
.
ColHeaders
[
c
];
var
first
=
config
.
FirstOrDefault
(
w
=>
w
.
Value
.
ToString
()
==
header
);
if
(!
default
(
KeyValuePair
<
string
,
string
>).
Equals
(
first
)
&&
!
result
.
ContainsKey
(
header
)
&&
request
.
Data
[
rownumber
].
Length
>
c
)
{
result
.
Add
(
first
.
Key
,
request
.
Data
[
rownumber
][
c
]);
}
}
return
result
;
}
#
endregion
}
}
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