Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
work2
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢春璐
work2
Commits
9be28960
Commit
9be28960
authored
Aug 03, 2018
by
谢春璐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
2d0f5649
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
12 deletions
+31
-12
src/main/java/com/zanchina/check/common/ExcelWrite.java
+20
-6
src/main/java/com/zanchina/check/service/impl/FileServiceImpl.java
+11
-6
No files found.
src/main/java/com/zanchina/check/common/ExcelWrite.java
View file @
9be28960
...
...
@@ -8,6 +8,8 @@ import lombok.extern.slf4j.Slf4j;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.poifs.filesystem.POIFSFileSystem
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.CellStyle
;
import
org.apache.poi.ss.usermodel.Font
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Workbook
;
...
...
@@ -43,24 +45,36 @@ public class ExcelWrite {
Sheet
sheet
=
null
;
if
(
null
!=
template
)
{
try
{
if
(
template
.
getName
().
contains
(
"."
)&&
template
.
getName
().
substring
(
template
.
getName
().
lastIndexOf
(
"."
)+
1
,
template
.
getName
().
length
()).
toLowerCase
().
equals
(
"xls"
))
{
if
(
template
.
getName
().
contains
(
"."
)
&&
template
.
getName
()
.
substring
(
template
.
getName
().
lastIndexOf
(
"."
)
+
1
,
template
.
getName
().
length
()).
toLowerCase
()
.
equals
(
"xls"
))
{
workbook
=
new
HSSFWorkbook
(
new
POIFSFileSystem
(
new
FileInputStream
(
template
)));
}
else
{
workbook
=
new
XSSFWorkbook
(
new
FileInputStream
(
template
));
}
else
{
workbook
=
new
XSSFWorkbook
(
new
FileInputStream
(
template
));
}
sheet
=
workbook
.
getSheetAt
(
0
);
sheet
.
setColumnWidth
(
0
,
3766
);
}
catch
(
Exception
e
)
{
}
}
else
{
if
(
out
.
getName
().
contains
(
"."
)&&
out
.
getName
().
substring
(
out
.
getName
().
lastIndexOf
(
"."
)+
1
,
out
.
getName
().
length
()).
toLowerCase
().
equals
(
"xls"
))
{
if
(
out
.
getName
().
contains
(
"."
)
&&
out
.
getName
()
.
substring
(
out
.
getName
().
lastIndexOf
(
"."
)
+
1
,
out
.
getName
().
length
()).
toLowerCase
().
equals
(
"xls"
))
{
workbook
=
new
HSSFWorkbook
();
}
else
{
workbook
=
new
XSSFWorkbook
();
}
else
{
workbook
=
new
XSSFWorkbook
();
}
sheet
=
workbook
.
createSheet
(
sheetName
);
}
if
(
null
!=
data
.
getTitles
()
&&
data
.
getTitles
().
length
>
0
)
{
Row
titleRow
=
sheet
.
createRow
(
0
);
CellStyle
cellStyle
=
workbook
.
createCellStyle
();
cellStyle
.
setFillForegroundColor
((
short
)
13
);
cellStyle
.
setFillPattern
(
CellStyle
.
ALIGN_JUSTIFY
);
Font
font
=
workbook
.
createFont
();
font
.
setBoldweight
(
Font
.
BOLDWEIGHT_BOLD
);
font
.
setFontHeightInPoints
((
short
)
16
);
cellStyle
.
setFont
(
font
);
titleRow
.
setRowStyle
(
cellStyle
);
for
(
int
j
=
0
;
j
<
data
.
getTitles
().
length
;
j
++)
{
Cell
busiDataCell
=
titleRow
.
createCell
(
j
);
busiDataCell
.
setCellValue
(
data
.
getTitles
()[
j
]);
...
...
src/main/java/com/zanchina/check/service/impl/FileServiceImpl.java
View file @
9be28960
...
...
@@ -245,10 +245,12 @@ public class FileServiceImpl implements FileService {
newWorkCheckList
.
add
(
w
);
});
newWorkCheckList
.
sort
(
Comparator
.
comparing
(
WorkCheck:
:
getDate
));
staff
.
setWorkCheckList
(
newWorkCheckList
);
newStaffList
.
add
(
staff
);
});
newStaffList
.
sort
(
Comparator
.
comparing
(
Staff:
:
getName
));
return
newStaffList
;
}
...
...
@@ -261,15 +263,18 @@ public class FileServiceImpl implements FileService {
titleList
.
add
(
"姓名"
);
// 取打卡记录中最早日期和最晚日期为标题的开始日期和结束日期
String
start
=
staffList
.
stream
().
min
(
Comparator
.
comparing
(
staff
->
staff
.
getWorkCheckList
().
get
(
0
).
getDate
()))
String
start
=
staffList
.
stream
().
min
(
Comparator
.
comparing
(
staff
->
DateUtils
.
parseDate
(
staff
.
getWorkCheckList
().
stream
()
.
min
(
Comparator
.
comparing
(
w
->
DateUtils
.
parseDate
(
w
.
getDate
()).
getTime
())).
get
().
getDate
())
.
getTime
()))
.
get
()
.
getWorkCheckList
().
get
(
0
).
getDate
();
List
<
WorkCheck
>
workCheckList
=
staffList
.
stream
()
.
max
(
Comparator
.
comparing
(
staff
->
staff
.
getWorkCheckList
().
get
(
staff
.
getWorkCheckList
().
size
()
-
1
).
getDate
()
))
.
get
(
)
.
getWorkCheckList
();
List
<
WorkCheck
>
workCheckList
=
staffList
.
stream
()
.
max
(
Comparator
.
comparing
(
staff
->
DateUtils
.
parseDate
(
staff
.
getWorkCheckList
().
stream
()
.
max
(
Comparator
.
comparing
(
w
->
DateUtils
.
parseDate
(
w
.
getDate
()).
getTime
())).
get
().
getDate
(
))
.
getTime
())
)
.
get
().
get
WorkCheckList
();
String
end
=
workCheckList
.
get
(
workCheckList
.
size
()
-
1
).
getDate
();
...
...
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