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
932753f9
Commit
932753f9
authored
Oct 20, 2020
by
lcx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
获取workbook
parent
8e449b8b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
24 deletions
+94
-24
performance/Performance.Services/ExtractExcelService/ExtractHelper/ExtractHelper.cs
+4
-3
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
+4
-4
performance/Performance.Services/ExtractExcelService/ExtractService.cs
+30
-2
performance/Performance.Services/ExtractExcelService/SheetDataWrite/ExpendDataWrite.cs
+0
-10
performance/Performance.Services/ExtractExcelService/SheetDataWrite/IncomeDataWrite.cs
+29
-2
performance/Performance.Services/ExtractExcelService/SheetDataWrite/WorkloadDataWrite.cs
+27
-2
performance/Performance.Services/ExtractExcelService/WriteDataFactory.cs
+0
-1
No files found.
performance/Performance.Services/ExtractExcelService/ExtractHelper/ExtractHelper.cs
View file @
932753f9
...
@@ -12,12 +12,14 @@ namespace Performance.Services.ExtractExcelService
...
@@ -12,12 +12,14 @@ namespace Performance.Services.ExtractExcelService
{
{
public
class
ExtractHelper
public
class
ExtractHelper
{
{
public
static
(
string
template
,
string
filepath
)
GetExtractFile
(
int
hospitalId
,
string
allotFilePath
=
""
)
public
static
string
GetExtractFile
(
int
hospitalId
,
ref
string
newFilePath
,
string
allotFilePath
=
""
)
{
{
string
originalPath
=
string
.
IsNullOrEmpty
(
allotFilePath
)
string
originalPath
=
string
.
IsNullOrEmpty
(
allotFilePath
)
?
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"Template"
,
"医院绩效模板.xls"
)
?
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"Template"
,
"医院绩效模板.xls"
)
:
allotFilePath
;
:
allotFilePath
;
return
CopyOriginalFile
(
hospitalId
,
originalPath
);
var
(
tempPath
,
filePath
)
=
CopyOriginalFile
(
hospitalId
,
originalPath
);
newFilePath
=
filePath
;
return
tempPath
;
}
}
private
static
(
string
TempPath
,
string
FilePath
)
CopyOriginalFile
(
int
hospitalId
,
string
originalPath
)
private
static
(
string
TempPath
,
string
FilePath
)
CopyOriginalFile
(
int
hospitalId
,
string
originalPath
)
...
@@ -28,7 +30,6 @@ private static (string TempPath, string FilePath) CopyOriginalFile(int hospitalI
...
@@ -28,7 +30,6 @@ private static (string TempPath, string FilePath) CopyOriginalFile(int hospitalI
string
tempPath
=
Path
.
Combine
(
dpath
,
$"Template
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
)}{
ext
}
"
);
string
tempPath
=
Path
.
Combine
(
dpath
,
$"Template
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
)}{
ext
}
"
);
FileHelper
.
Copy
(
originalPath
,
tempPath
);
FileHelper
.
Copy
(
originalPath
,
tempPath
);
string
filePath
=
Path
.
Combine
(
dpath
,
$"绩效提取数据
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
)}
.xls"
);
string
filePath
=
Path
.
Combine
(
dpath
,
$"绩效提取数据
{
DateTime
.
Now
.
ToString
(
"yyyyMMddHHmmssfff"
)}
.xls"
);
return
(
tempPath
,
filePath
);
return
(
tempPath
,
filePath
);
}
}
...
...
performance/Performance.Services/ExtractExcelService/ExtractHelper/WriteDataHelper.cs
View file @
932753f9
...
@@ -177,7 +177,7 @@ public static string HasValue(params string[] list)
...
@@ -177,7 +177,7 @@ public static string HasValue(params string[] list)
}
}
/// <summary> 住院核算单元 </summary>
/// <summary> 住院核算单元 </summary>
private
readonly
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
fieldInpat
=
new
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
private
static
readonly
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
fieldInpat
=
new
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
{
{
{
"科室名称"
,
(
dto
)
=>
dto
.
Department
},
{
"科室名称"
,
(
dto
)
=>
dto
.
Department
},
{
"核算单元(医生组)"
,
(
dto
)
=>
new
string
[]{
dto
.
InpatDoctorAccounting
,
dto
.
OutDoctorAccounting
}.
FirstOrDefault
(
t
=>
!
string
.
IsNullOrEmpty
(
t
))
},
{
"核算单元(医生组)"
,
(
dto
)
=>
new
string
[]{
dto
.
InpatDoctorAccounting
,
dto
.
OutDoctorAccounting
}.
FirstOrDefault
(
t
=>
!
string
.
IsNullOrEmpty
(
t
))
},
...
@@ -186,7 +186,7 @@ public static string HasValue(params string[] list)
...
@@ -186,7 +186,7 @@ public static string HasValue(params string[] list)
};
};
/// <summary> 门诊核算单元 </summary>
/// <summary> 门诊核算单元 </summary>
private
readonly
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
fieldOut
=
new
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
private
static
readonly
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
fieldOut
=
new
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
{
{
{
"科室名称"
,
(
dto
)
=>
dto
.
Department
},
{
"科室名称"
,
(
dto
)
=>
dto
.
Department
},
{
"核算单元(医生组)"
,
(
dto
)
=>
new
string
[]{
dto
.
OutDoctorAccounting
,
dto
.
InpatDoctorAccounting
}.
FirstOrDefault
(
t
=>
!
string
.
IsNullOrEmpty
(
t
))
},
{
"核算单元(医生组)"
,
(
dto
)
=>
new
string
[]{
dto
.
OutDoctorAccounting
,
dto
.
InpatDoctorAccounting
}.
FirstOrDefault
(
t
=>
!
string
.
IsNullOrEmpty
(
t
))
},
...
@@ -195,7 +195,7 @@ public static string HasValue(params string[] list)
...
@@ -195,7 +195,7 @@ public static string HasValue(params string[] list)
};
};
/// <summary> 医生工作量 </summary>
/// <summary> 医生工作量 </summary>
private
readonly
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
fieldDoctor
=
new
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
private
static
readonly
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
fieldDoctor
=
new
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
{
{
{
"科室名称"
,
(
dto
)
=>
dto
.
Department
},
{
"科室名称"
,
(
dto
)
=>
dto
.
Department
},
{
"核算单元"
,
(
dto
)
=>
{
"核算单元"
,
(
dto
)
=>
...
@@ -208,7 +208,7 @@ public static string HasValue(params string[] list)
...
@@ -208,7 +208,7 @@ public static string HasValue(params string[] list)
};
};
/// <summary> 护理工作量 </summary>
/// <summary> 护理工作量 </summary>
private
readonly
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
fieldNurse
=
new
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
private
static
readonly
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
fieldNurse
=
new
Dictionary
<
string
,
Func
<
ExtractTransDto
,
string
>>
{
{
{
"科室名称"
,
(
dto
)
=>
dto
.
Department
},
{
"科室名称"
,
(
dto
)
=>
dto
.
Department
},
{
"核算单元"
,
(
dto
)
=>
new
string
[]{
dto
.
OutNurseAccounting
,
dto
.
InpatNurseAccounting
}.
FirstOrDefault
(
t
=>
!
string
.
IsNullOrEmpty
(
t
))
},
{
"核算单元"
,
(
dto
)
=>
new
string
[]{
dto
.
OutNurseAccounting
,
dto
.
InpatNurseAccounting
}.
FirstOrDefault
(
t
=>
!
string
.
IsNullOrEmpty
(
t
))
},
...
...
performance/Performance.Services/ExtractExcelService/ExtractService.cs
View file @
932753f9
using
Microsoft.Extensions.Logging
;
using
Microsoft.Extensions.Logging
;
using
Performance.DtoModels
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
Performance.EntityModels
;
using
Performance.Infrastructure
;
using
Performance.Repository
;
using
Performance.Repository
;
using
System
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
...
@@ -70,7 +72,8 @@ public string Main(int allotId, int hospitalId, string email, string groupName =
...
@@ -70,7 +72,8 @@ public string Main(int allotId, int hospitalId, string email, string groupName =
var
statesArray
=
new
int
[]
{
(
int
)
AllotStates
.
GenerateSucceed
,
(
int
)
AllotStates
.
Archive
};
var
statesArray
=
new
int
[]
{
(
int
)
AllotStates
.
GenerateSucceed
,
(
int
)
AllotStates
.
Archive
};
var
lastAllot
=
allots
.
Where
(
t
=>
statesArray
.
Contains
(
t
.
States
))?.
OrderByDescending
(
t
=>
t
.
Year
)?.
ThenByDescending
(
t
=>
t
.
Month
)?.
First
();
var
lastAllot
=
allots
.
Where
(
t
=>
statesArray
.
Contains
(
t
.
States
))?.
OrderByDescending
(
t
=>
t
.
Year
)?.
ThenByDescending
(
t
=>
t
.
Month
)?.
First
();
extractFilePath
=
lastAllot
!=
null
&&
!
string
.
IsNullOrEmpty
(
filePath
)
?
""
:
""
;
//extractFilePath = lastAllot != null && !string.IsNullOrEmpty(filePath) ? "" : "";
var
templateFilePath
=
ExtractHelper
.
GetExtractFile
(
hospitalId
,
ref
extractFilePath
,
filePath
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
@@ -84,13 +87,38 @@ public string Main(int allotId, int hospitalId, string email, string groupName =
...
@@ -84,13 +87,38 @@ public string Main(int allotId, int hospitalId, string email, string groupName =
return
extractFilePath
;
return
extractFilePath
;
}
}
private
void
WriteDataToFile
(
string
templateFile
,
string
extractFile
)
{
if
(!
FileHelper
.
IsExistFile
(
templateFile
)
||
!
FileHelper
.
IsExistFile
(
extractFile
))
throw
new
PerformanceException
(
""
);
private
void
WriteToTemplate
()
var
workbook
=
ExcelHelper
.
GetWorkbook
(
templateFile
);
if
(
workbook
==
null
)
throw
new
PerformanceException
(
"文件读取失败"
);
ExtractHelper
.
CreateNotExistSheet
(
new
List
<
ex_module
>(),
workbook
);
WriteDataFactory
factory
=
new
WriteDataFactory
();
for
(
int
sheetIndex
=
0
;
sheetIndex
<
workbook
.
NumberOfSheets
;
sheetIndex
++)
{
{
var
sheet
=
workbook
.
GetSheetAt
(
sheetIndex
);
var
sheetType
=
perSheetService
.
GetSheetType
(
sheet
.
SheetName
);
var
reader
=
PerSheetDataFactory
.
GetDataRead
(
sheetType
)?.
Point
;
var
customer
=
factory
.
GetWriteData
(
sheetType
);
customer
.
GetType
();
}
using
(
FileStream
file
=
new
FileStream
(
extractFile
,
FileMode
.
OpenOrCreate
))
{
workbook
.
Write
(
file
);
}
}
}
private
void
WriteToTemplate
()
{
}
private
void
WriteToAllotFile
()
private
void
WriteToAllotFile
()
{
{
...
...
performance/Performance.Services/ExtractExcelService/SheetDataWrite/ExpendDataWrite.cs
deleted
100644 → 0
View file @
8e449b8b
using
System
;
using
System.Collections.Generic
;
using
System.Text
;
namespace
Performance.Services.ExtractExcelService.SheetDataWrite
{
class
ExpendDataWrite
:
ISheetDataWrite
{
}
}
performance/Performance.Services/ExtractExcelService/SheetDataWrite/IncomeDataWrite.cs
View file @
932753f9
using
System
;
using
NPOI.SS.UserModel
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
namespace
Performance.Services.ExtractExcelService.SheetDataWrite
namespace
Performance.Services.ExtractExcelService.SheetDataWrite
{
{
class
IncomeDataWrite
:
ISheetDataWrite
public
class
IncomeDataWrite
:
ISheetDataWrite
{
{
public
void
WriteSheetData
(
ISheet
sheet
,
PerSheetPoint
point
,
SheetType
sheetType
,
object
data
,
List
<
ex_module
>
modules
,
List
<
ex_item
>
items
)
{
var
module
=
modules
.
FirstOrDefault
(
t
=>
t
.
SheetType
==
(
int
)
sheetType
);
if
(
module
==
null
)
return
;
var
modelItems
=
items
.
Where
(
t
=>
t
.
ModuleId
==
module
.
Id
);
if
(
modelItems
==
null
||
!
modelItems
.
Any
())
return
;
var
headers
=
modelItems
.
Select
(
t
=>
new
ExcelHeader
{
ColumnName
=
t
.
ItemName
,
DoctorFactor
=
t
.
FactorValue1
??
0
,
NurseFactor
=
t
.
FactorValue2
??
0
,
TechnicianFactor
=
t
.
FactorValue3
??
0
}).
ToList
();
WriteDataHelper
.
WriteSheetHeader
(
sheet
,
point
,
sheetType
,
headers
);
if
(
data
is
List
<
ExtractTransDto
>
extractDto
&&
extractDto
.
Any
())
{
var
columns
=
headers
.
Select
(
t
=>
t
.
ColumnName
).
ToList
();
WriteDataHelper
.
WriteSheetData
(
sheet
,
point
,
sheetType
,
columns
,
extractDto
);
}
}
}
}
}
}
performance/Performance.Services/ExtractExcelService/SheetDataWrite/WorkloadDataWrite.cs
View file @
932753f9
using
System
;
using
NPOI.SS.UserModel
;
using
Performance.DtoModels
;
using
Performance.EntityModels
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Text
;
namespace
Performance.Services.ExtractExcelService.SheetDataWrite
namespace
Performance.Services.ExtractExcelService.SheetDataWrite
{
{
class
WorkloadDataWrite
:
ISheetDataWrite
public
class
WorkloadDataWrite
:
ISheetDataWrite
{
{
public
void
WriteSheetData
(
ISheet
sheet
,
PerSheetPoint
point
,
SheetType
sheetType
,
object
data
,
List
<
ex_module
>
modules
,
List
<
ex_item
>
items
)
{
var
module
=
modules
.
FirstOrDefault
(
t
=>
t
.
SheetType
==
(
int
)
sheetType
);
if
(
module
==
null
)
return
;
var
modelItems
=
items
.
Where
(
t
=>
t
.
ModuleId
==
module
.
Id
);
if
(
modelItems
==
null
||
!
modelItems
.
Any
())
return
;
var
headers
=
modelItems
.
Select
(
t
=>
new
ExcelHeader
{
ColumnName
=
t
.
ItemName
,
WorkloadFactor
=
t
.
FactorValue1
??
0
}).
ToList
();
WriteDataHelper
.
WriteSheetHeader
(
sheet
,
point
,
sheetType
,
headers
);
if
(
data
is
List
<
ExtractTransDto
>
extractDto
&&
extractDto
.
Any
())
{
var
columns
=
headers
.
Select
(
t
=>
t
.
ColumnName
).
Intersect
(
extractDto
.
Select
(
t
=>
t
.
Category
))?.
ToList
();
WriteDataHelper
.
WriteSheetData
(
sheet
,
point
,
sheetType
,
columns
,
extractDto
);
}
}
}
}
}
}
performance/Performance.Services/ExtractExcelService/WriteDataFactory.cs
View file @
932753f9
...
@@ -8,7 +8,6 @@ namespace Performance.Services.ExtractExcelService
...
@@ -8,7 +8,6 @@ namespace Performance.Services.ExtractExcelService
{
{
public
class
WriteDataFactory
public
class
WriteDataFactory
{
{
public
ISheetDataWrite
GetWriteData
(
SheetType
sheetType
)
public
ISheetDataWrite
GetWriteData
(
SheetType
sheetType
)
{
{
ISheetDataWrite
factory
;
ISheetDataWrite
factory
;
...
...
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