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
cacffe87
Commit
cacffe87
authored
Nov 04, 2022
by
Licx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
导入数据 下载
parent
11af742c
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
154 additions
and
12 deletions
+154
-12
performance/Performance.Api/Controllers/ConfigController.cs
+34
-3
performance/Performance.Api/wwwroot/Performance.Api.xml
+7
-0
performance/Performance.Repository/PerforReportRepository .cs
+26
-1
performance/Performance.Services/ConfigService.cs
+87
-6
performance/Performance.Services/UserService.cs
+0
-2
No files found.
performance/Performance.Api/Controllers/ConfigController.cs
View file @
cacffe87
using
FluentValidation.AspNetCore
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.AspNetCore.Mvc.ApiExplorer
;
using
Microsoft.AspNetCore.StaticFiles
;
using
Microsoft.Extensions.Caching.Memory
;
using
Microsoft.Extensions.Options
;
using
Newtonsoft.Json.Linq
;
...
...
@@ -11,6 +12,7 @@
using
Performance.Services.ExtractExcelService
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
namespace
Performance.Api.Controllers
...
...
@@ -321,7 +323,7 @@ public ApiResponse DrugtypeDelete([CustomizeValidator(RuleSet = "Delete"), FromB
[
HttpPost
]
public
ApiResponse
GetDrugtypeDisburseList
([
CustomizeValidator
(
RuleSet
=
"Select"
),
FromBody
]
DrugpropRequest
request
)
{
var
list
=
_configService
.
GetDrugtypeDisburseList
(
request
.
HospitalId
,
request
.
AllotID
).
OrderBy
(
t
=>
t
.
ID
);
var
list
=
_configService
.
GetDrugtypeDisburseList
(
request
.
HospitalId
,
request
.
AllotID
).
OrderBy
(
t
=>
t
.
ID
);
var
listpage
=
list
.
Skip
(
request
.
PageSize
*
(
request
.
CurrentPage
-
1
)).
Take
(
request
.
PageSize
).
ToList
();
return
new
ApiResponse
(
ResponseType
.
OK
,
"ok"
,
new
{
...
...
@@ -384,7 +386,7 @@ public ApiResponse DrugtypeDisburseDelete([CustomizeValidator(RuleSet = "Delete"
[
HttpPost
]
public
ApiResponse
GetAgainList
([
CustomizeValidator
(
RuleSet
=
"Select"
),
FromBody
]
CofAgainRequest
request
)
{
var
list
=
_configService
.
GetAgainList
(
request
.
AllotID
).
OrderBy
(
t
=>
t
.
ID
);
var
list
=
_configService
.
GetAgainList
(
request
.
AllotID
).
OrderBy
(
t
=>
t
.
ID
);
var
listpage
=
list
.
Skip
(
request
.
PageSize
*
(
request
.
CurrentPage
-
1
)).
Take
(
request
.
PageSize
).
ToList
();
return
new
ApiResponse
(
ResponseType
.
OK
,
"ok"
,
new
{
...
...
@@ -447,7 +449,7 @@ public ApiResponse AgainDelete([CustomizeValidator(RuleSet = "Delete"), FromBody
[
HttpPost
]
public
ApiResponse
GetWorkItems
([
CustomizeValidator
(
RuleSet
=
"Select"
),
FromBody
]
WorkItemRequest
request
)
{
var
list
=
_configService
.
GetWorkItems
(
request
.
AllotID
,
request
.
Type
).
OrderBy
(
t
=>
t
.
ID
);
var
list
=
_configService
.
GetWorkItems
(
request
.
AllotID
,
request
.
Type
).
OrderBy
(
t
=>
t
.
ID
);
var
listpage
=
list
.
Skip
(
request
.
PageSize
*
(
request
.
CurrentPage
-
1
)).
Take
(
request
.
PageSize
).
ToList
();
return
new
ApiResponse
(
ResponseType
.
OK
,
"ok"
,
new
{
...
...
@@ -956,5 +958,33 @@ public ApiResponse BatchSaveCustom([FromBody] SaveCustomData request)
return
_configService
.
SaveCustomTable
(
request
);
}
/// <summary>
/// 自定义表显示
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[
HttpPost
(
"customlist/download"
)]
public
IActionResult
CustomDownload
([
FromBody
]
CustomPagingRequest
request
)
{
var
allot
=
_allotService
.
GetAllot
(
request
.
AllotId
);
if
(
allot
==
null
)
throw
new
PerformanceException
(
"AllotID错误"
);
string
filepath
=
_configService
.
CustomDownloadFile
(
_claim
.
GetUserId
(),
request
,
allot
);
if
(!
FileHelper
.
IsExistFile
(
filepath
))
throw
new
PerformanceException
(
"获取导入数据失败"
);
var
memoryStream
=
new
MemoryStream
();
using
(
var
stream
=
new
FileStream
(
filepath
,
FileMode
.
Open
))
{
stream
.
CopyToAsync
(
memoryStream
).
Wait
();
}
memoryStream
.
Seek
(
0
,
SeekOrigin
.
Begin
);
var
provider
=
new
FileExtensionContentTypeProvider
();
FileInfo
fileInfo
=
new
FileInfo
(
filepath
);
var
memi
=
provider
.
Mappings
[
".xlsx"
];
return
File
(
memoryStream
,
memi
,
Path
.
GetFileName
(
fileInfo
.
Name
));
}
}
}
\ No newline at end of file
performance/Performance.Api/wwwroot/Performance.Api.xml
View file @
cacffe87
...
...
@@ -989,6 +989,13 @@
<param
name=
"request"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.ConfigController.CustomDownload(Performance.DtoModels.CustomPagingRequest)"
>
<summary>
自定义表显示
</summary>
<param
name=
"request"
></param>
<returns></returns>
</member>
<member
name=
"M:Performance.Api.Controllers.CostTransferController.SubmitApplications(Performance.DtoModels.CostTransferRequest)"
>
<summary>
申请划拨
...
...
performance/Performance.Repository/PerforReportRepository .cs
View file @
cacffe87
...
...
@@ -468,7 +468,7 @@ public List<dynamic> QueryComputeByDateAndTotal(string viewName, HospitalGrantSu
}
//sql = $"select {string.Join(",", request.GroupBy)}, {string.Join(",", request.SumBy.Select(t => $"sum({t}) {t}"))} from ({sql}) tab group by {string.Join(",", request.GroupBy)}";
return
DapperQuery
<
dynamic
>(
sql
,
new
{
beginTime
=
request
.
BeginTime
,
endTime
=
request
.
EndTime
},
commandTimeout
:
60
*
10
).
ToList
();
return
DapperQuery
<
dynamic
>(
sql
,
new
{
beginTime
=
request
.
BeginTime
,
endTime
=
request
.
EndTime
},
commandTimeout
:
60
*
10
).
ToList
();
}
public
(
List
<
dynamic
>
list
,
int
count
)
QueryComputePageData
(
string
query
,
object
param
=
null
)
...
...
@@ -495,6 +495,31 @@ public List<dynamic> QueryComputeByDateAndTotal(string viewName, HospitalGrantSu
/// <param name="allotId"></param>
/// <param name="accountingUnit"></param>
/// <param name="unitType"></param>
/// <returns></returns>
public
List
<
dynamic
>
QueryCustom
(
string
tableName
,
int
allotId
,
string
accountingUnit
,
string
[]
unitType
)
{
string
querySql
=
$@"select * from
{
tableName
}
where allotid = @allotid "
;
if
(!
string
.
IsNullOrEmpty
(
accountingUnit
))
querySql
+=
" and accountingunit = @accountingunit"
;
if
(
unitType
!=
null
&&
unitType
.
Any
())
querySql
+=
" and unittype in @unittype"
;
querySql
+=
" order by unittype,accountingunit"
;
var
result
=
DapperQuery
<
dynamic
>(
querySql
,
new
{
allotId
,
accountingUnit
,
unitType
},
commandTimeout
:
60
*
10
)?.
ToList
();
return
result
;
}
/// <summary>
/// 科室
/// </summary>
/// <param name="tableName"></param>
/// <param name="allotId"></param>
/// <param name="accountingUnit"></param>
/// <param name="unitType"></param>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <returns></returns>
...
...
performance/Performance.Services/ConfigService.cs
View file @
cacffe87
using
AutoMapper
;
using
Microsoft.AspNetCore.Hosting
;
using
NPOI.SS.Formula.Functions
;
using
NPOI.SS.UserModel
;
using
NPOI.XSSF.UserModel
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.EntityModels.Other
;
...
...
@@ -6,8 +10,10 @@
using
Performance.Infrastructure.Models
;
using
Performance.Repository
;
using
Performance.Repository.Repository
;
using
Performance.Services.ExtractExcelService
;
using
System
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Linq.Expressions
;
using
System.Text.RegularExpressions
;
...
...
@@ -41,6 +47,7 @@ public class ConfigService : IAutoInjection
private
readonly
PerforCofdrugtypeDisburseRepository
_drugtypeDisburseRepository
;
private
readonly
PerforExmoduleRepository
_perforExmoduleRepository
;
private
readonly
PerforCofdrugtypefactorRepository
_cofdrugtypefactorRepository
;
private
readonly
IWebHostEnvironment
_evn
;
public
ConfigService
(
IMapper
mapper
,
...
...
@@ -66,7 +73,8 @@ public class ConfigService : IAutoInjection
PerforCofaliasRepository
perforCofaliasRepository
,
PerforCofaccountingRepository
cofaccountingRepository
,
PerforCofdrugtypeDisburseRepository
drugtypeDisburseRepository
,
PerforCofdrugtypefactorRepository
cofdrugtypefactorRepository
)
PerforCofdrugtypefactorRepository
cofdrugtypefactorRepository
,
IWebHostEnvironment
evn
)
{
_mapper
=
mapper
;
_userService
=
userService
;
...
...
@@ -92,6 +100,7 @@ public class ConfigService : IAutoInjection
_drugtypeDisburseRepository
=
drugtypeDisburseRepository
;
_perforExmoduleRepository
=
perforExmoduleRepository
;
_cofdrugtypefactorRepository
=
cofdrugtypefactorRepository
;
_evn
=
evn
;
}
#
endregion
...
...
@@ -1075,17 +1084,17 @@ public SheetExportResponse GetDrugtypeFactor(AllotDeptRequest request)
index
++;
}
sheet
.
Header
=
new
List
<
Row
>
sheet
.
Header
=
new
List
<
DtoModels
.
Row
>
{
new
Row
(
0
){
Data
=
mergeCells
},
new
Row
(
1
){
Data
=
cells
}
new
DtoModels
.
Row
(
0
){
Data
=
mergeCells
},
new
DtoModels
.
Row
(
1
){
Data
=
cells
}
};
#
endregion
#
region
data
List
<
Row
>
rows
=
new
List
<
Row
>();
List
<
DtoModels
.
Row
>
rows
=
new
List
<
DtoModels
.
Row
>();
var
querydata
=
_directorRepository
.
QueryCategoryFactor
(
request
.
HospitalId
,
request
.
AllotId
)?.
ToList
();
if
(
querydata
!=
null
&&
querydata
.
Any
())
{
...
...
@@ -1127,7 +1136,7 @@ public SheetExportResponse GetDrugtypeFactor(AllotDeptRequest request)
}
i
++;
}
rows
.
Add
(
new
Row
(
index
)
{
Data
=
rowcells
});
rows
.
Add
(
new
DtoModels
.
Row
(
index
)
{
Data
=
rowcells
});
index
++;
}
}
...
...
@@ -1515,6 +1524,78 @@ public ApiResponse QueryCustom(int userId, CustomPagingRequest request)
return
result
;
}
public
string
CustomDownloadFile
(
int
userId
,
CustomPagingRequest
request
,
per_allot
allot
)
{
var
dpath
=
Path
.
Combine
(
_evn
.
ContentRootPath
,
"Files"
,
"Dictionary"
,
$"
{
allot
.
HospitalId
}
"
);
FileHelper
.
CreateDirectory
(
dpath
);
string
filename
=
$"
{
allot
.
Year
}{
allot
.
Month
.
ToString
().
PadLeft
(
2
,
'0'
)}
导入数据-
{
DateTime
.
Now
.
ToString
(
"yyyyMMddhhmmss"
)}
.xlsx"
;
string
filepath
=
Path
.
Combine
(
dpath
,
filename
);
FileStream
stream
=
new
FileStream
(
filepath
,
FileMode
.
Create
);
var
user
=
_userService
.
GetUser
(
userId
);
var
roleType
=
_roleService
.
GetUserRole
(
userId
)?.
FirstOrDefault
()?.
Type
??
0
;
var
heads
=
_perforReport
.
QueryCustomColumn
(
request
.
TableName
)
??
new
List
<
ColumnEntity
>();
if
(
heads
!=
null
&&
heads
.
Any
(
w
=>
string
.
IsNullOrEmpty
(
w
.
Comment
)))
heads
.
RemoveAll
(
w
=>
string
.
IsNullOrEmpty
(
w
.
Comment
));
var
unitTypes
=
UnitTypeUtil
.
GetMaps
(
roleType
);
var
data
=
_perforReport
.
QueryCustom
(
request
.
TableName
,
request
.
AllotId
,
user
?.
Department
??
""
,
unitTypes
)
??
new
List
<
dynamic
>();
try
{
XSSFWorkbook
workbook
=
new
XSSFWorkbook
();
ExcelStyle
excelStyle
=
new
ExcelStyle
(
workbook
);
var
style
=
excelStyle
.
SetBgkColorAndFormat
(
excelStyle
.
GetCellStyle
());
ISheet
sheet
=
workbook
.
CreateSheet
(
"人员字典"
);
var
header
=
sheet
.
CreateRow
(
0
);
int
cellIndex
=
0
;
foreach
(
var
item
in
heads
)
{
var
cell
=
header
.
CreateCell
(
cellIndex
);
cell
.
SetCellValue
(
item
.
Comment
);
cell
.
CellStyle
=
style
;
cellIndex
++;
}
if
(
data
!=
null
&&
data
.
Any
())
{
var
retult
=
JsonHelper
.
Deserialize
<
List
<
Dictionary
<
string
,
object
>>>(
JsonHelper
.
Serialize
(
data
));
int
startIndex
=
1
;
foreach
(
var
item
in
retult
)
{
var
row
=
sheet
.
CreateRow
(
startIndex
);
cellIndex
=
0
;
foreach
(
var
field
in
heads
.
Select
(
w
=>
w
.
Name
.
ToLower
()))
{
var
cell
=
row
.
CreateCell
(
cellIndex
);
cell
.
CellStyle
=
style
;
cellIndex
++;
if
(!
item
.
Keys
.
Contains
(
field
))
continue
;
cell
.
SetCellOValue
(
item
[
field
]);
}
startIndex
++;
}
}
workbook
.
Write
(
stream
);
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
"写入异常"
+
ex
);
}
finally
{
stream
.
Close
();
}
return
filepath
;
}
#
endregion
}
}
performance/Performance.Services/UserService.cs
View file @
cacffe87
...
...
@@ -517,8 +517,6 @@ public UserResponse InsertUser(UserRequest request, int userid)
if
(
roleArray
.
Intersect
(
request
.
RoleArr
).
Any
()
&&
string
.
IsNullOrEmpty
(
request
.
Department
))
throw
new
PerformanceException
(
"二次绩效管理员科室不能为空"
);
var
user
=
_mapper
.
Map
<
sys_user
>(
request
);
user
.
CreateDate
=
DateTime
.
Now
;
user
.
CreateUser
=
userid
;
...
...
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