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
2d1e86cd
Commit
2d1e86cd
authored
Oct 12, 2018
by
谢春璐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
加班信息导入
parent
0d4c5114
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
12 deletions
+102
-12
src/main/java/com/zanchina/check/controller/FileController.java
+10
-3
src/main/java/com/zanchina/check/service/FileService.java
+7
-1
src/main/java/com/zanchina/check/service/impl/FileServiceImpl.java
+77
-8
src/main/resources/static/index.html
+8
-0
No files found.
src/main/java/com/zanchina/check/controller/FileController.java
View file @
2d1e86cd
...
@@ -7,8 +7,11 @@ import com.zanchina.check.service.FileService;
...
@@ -7,8 +7,11 @@ import com.zanchina.check.service.FileService;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
...
@@ -49,10 +52,11 @@ public class FileController {
...
@@ -49,10 +52,11 @@ public class FileController {
.
getFiles
(
"file"
);
.
getFiles
(
"file"
);
List
<
Staff
>
staffList
=
new
ArrayList
<>();
List
<
Staff
>
staffList
=
new
ArrayList
<>();
Map
<
String
,
Set
<
String
>>
overtimeMap
=
new
HashMap
<>();
files
=
files
.
stream
().
filter
(
f
->
StringUtils
.
isNotBlank
(
f
.
getOriginalFilename
()))
files
=
files
.
stream
().
filter
(
f
->
StringUtils
.
isNotBlank
(
f
.
getOriginalFilename
()))
.
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
f
iles
.
forEach
(
file
->
{
f
or
(
MultipartFile
file
:
files
)
{
try
{
try
{
InputStream
inputStream
=
file
.
getInputStream
();
InputStream
inputStream
=
file
.
getInputStream
();
...
@@ -66,6 +70,9 @@ public class FileController {
...
@@ -66,6 +70,9 @@ public class FileController {
}
else
if
(
fileName
.
contains
(
"外出打卡_日报"
))
{
}
else
if
(
fileName
.
contains
(
"外出打卡_日报"
))
{
data
=
inst
.
parse
(
inputStream
,
fileName
,
false
,
2
);
data
=
inst
.
parse
(
inputStream
,
fileName
,
false
,
2
);
staffs
=
fileService
.
wechatWorkOutStatistics
(
data
);
staffs
=
fileService
.
wechatWorkOutStatistics
(
data
);
}
else
if
(
fileName
.
contains
(
"审批记录"
))
{
//加班
data
=
inst
.
parse
(
inputStream
,
fileName
,
false
,
0
);
overtimeMap
=
fileService
.
overtimeRecord
(
data
);
}
else
if
(
fileName
.
contains
(
"考勤导出"
))
{
}
else
if
(
fileName
.
contains
(
"考勤导出"
))
{
data
=
inst
.
parse
(
inputStream
,
fileName
,
false
,
0
);
data
=
inst
.
parse
(
inputStream
,
fileName
,
false
,
0
);
staffs
=
fileService
.
workRecord
(
data
);
staffs
=
fileService
.
workRecord
(
data
);
...
@@ -78,10 +85,10 @@ public class FileController {
...
@@ -78,10 +85,10 @@ public class FileController {
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
);
}
List
<
Staff
>
staffList1
=
fileService
.
staffListCollect
(
staffList
);
List
<
Staff
>
staffList1
=
fileService
.
staffListCollect
(
staffList
);
return
fileService
.
checkExport
(
staffList1
);
return
fileService
.
checkExport
(
staffList1
,
overtimeMap
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
try
{
try
{
...
...
src/main/java/com/zanchina/check/service/FileService.java
View file @
2d1e86cd
...
@@ -3,7 +3,11 @@ package com.zanchina.check.service;
...
@@ -3,7 +3,11 @@ package com.zanchina.check.service;
import
com.zanchina.check.common.ExcelData
;
import
com.zanchina.check.common.ExcelData
;
import
com.zanchina.check.domain.Staff
;
import
com.zanchina.check.domain.Staff
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.xml.crypto.Data
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.ResponseEntity
;
/**
/**
...
@@ -12,7 +16,7 @@ import org.springframework.http.ResponseEntity;
...
@@ -12,7 +16,7 @@ import org.springframework.http.ResponseEntity;
public
interface
FileService
{
public
interface
FileService
{
ResponseEntity
<
byte
[]>
checkExport
(
List
<
Staff
>
staffList
)
throws
Exception
;
ResponseEntity
<
byte
[]>
checkExport
(
List
<
Staff
>
staffList
,
Map
<
String
,
Set
<
String
>>
map
)
throws
Exception
;
List
<
Staff
>
wechatWorkOutStatistics
(
ExcelData
data
);
List
<
Staff
>
wechatWorkOutStatistics
(
ExcelData
data
);
...
@@ -23,4 +27,6 @@ public interface FileService {
...
@@ -23,4 +27,6 @@ public interface FileService {
List
<
Staff
>
staffListCollect
(
List
<
Staff
>
staffList
);
List
<
Staff
>
staffListCollect
(
List
<
Staff
>
staffList
);
List
<
Staff
>
dingdingWorkStatistics
(
ExcelData
data
);
List
<
Staff
>
dingdingWorkStatistics
(
ExcelData
data
);
Map
<
String
,
Set
<
String
>>
overtimeRecord
(
ExcelData
data
);
}
}
src/main/java/com/zanchina/check/service/impl/FileServiceImpl.java
View file @
2d1e86cd
...
@@ -8,13 +8,21 @@ import com.zanchina.check.domain.WorkCheck;
...
@@ -8,13 +8,21 @@ import com.zanchina.check.domain.WorkCheck;
import
com.zanchina.check.service.FileService
;
import
com.zanchina.check.service.FileService
;
import
java.io.File
;
import
java.io.File
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.time.LocalDate
;
import
java.time.temporal.ChronoUnit
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.Comparator
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
import
javax.xml.crypto.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
...
@@ -316,7 +324,8 @@ public class FileServiceImpl implements FileService {
...
@@ -316,7 +324,8 @@ public class FileServiceImpl implements FileService {
}
}
@Override
@Override
public
ResponseEntity
<
byte
[]>
checkExport
(
List
<
Staff
>
staffList
)
throws
Exception
{
public
ResponseEntity
<
byte
[]>
checkExport
(
List
<
Staff
>
staffList
,
Map
<
String
,
Set
<
String
>>
overtimeMap
)
throws
Exception
{
ExcelData
data
=
new
ExcelData
();
ExcelData
data
=
new
ExcelData
();
...
@@ -357,6 +366,9 @@ public class FileServiceImpl implements FileService {
...
@@ -357,6 +366,9 @@ public class FileServiceImpl implements FileService {
staffList
.
forEach
(
staff
->
{
staffList
.
forEach
(
staff
->
{
String
[]
d
=
new
String
[
titleStrArr
.
length
];
String
[]
d
=
new
String
[
titleStrArr
.
length
];
//查看此人是否有加班数据
Set
<
String
>
strings
=
overtimeMap
.
get
(
staff
.
getName
());
for
(
String
title
:
titleList
)
{
for
(
String
title
:
titleList
)
{
if
(
"姓名"
.
equalsIgnoreCase
(
title
))
{
if
(
"姓名"
.
equalsIgnoreCase
(
title
))
{
d
[
0
]
=
staff
.
getName
().
concat
(
"("
).
concat
(
staff
.
getDepartment
()).
concat
(
")"
);
d
[
0
]
=
staff
.
getName
().
concat
(
"("
).
concat
(
staff
.
getDepartment
()).
concat
(
")"
);
...
@@ -368,18 +380,33 @@ public class FileServiceImpl implements FileService {
...
@@ -368,18 +380,33 @@ public class FileServiceImpl implements FileService {
boolean
isWeekend
=
week
.
equalsIgnoreCase
(
Integer
.
toString
(
6
))
||
week
boolean
isWeekend
=
week
.
equalsIgnoreCase
(
Integer
.
toString
(
6
))
||
week
.
equalsIgnoreCase
(
Integer
.
toString
(
7
));
.
equalsIgnoreCase
(
Integer
.
toString
(
7
));
String
today
=
title
.
substring
(
0
,
title
.
indexOf
(
"("
));
String
detail
=
""
;
Boolean
isOverTime
=
false
;
// 判断当天是否有加班数据
if
(
Objects
.
nonNull
(
strings
)
&&
!
strings
.
isEmpty
())
{
List
<
String
>
overtime
=
strings
.
stream
().
filter
(
s
->
s
.
equalsIgnoreCase
(
today
))
.
collect
(
Collectors
.
toList
());
if
(
Objects
.
nonNull
(
overtime
)
&&
overtime
.
size
()
>
0
)
{
isOverTime
=
true
;
}
}
for
(
WorkCheck
check
:
staff
.
getWorkCheckList
())
{
for
(
WorkCheck
check
:
staff
.
getWorkCheckList
())
{
if
(
title
.
substring
(
0
,
title
.
indexOf
(
"("
)).
equalsIgnoreCase
(
if
(
today
.
equalsIgnoreCase
(
DateUtils
.
format
(
DateUtils
.
parseDate
(
check
.
getDate
()),
DateUtils
.
yyyyMMdd
)))
{
DateUtils
.
format
(
DateUtils
.
parseDate
(
check
.
getDate
()),
DateUtils
.
yyyyMMdd
)))
{
isExist
=
true
;
isExist
=
true
;
String
detail
=
""
;
if
(!
isWeekend
)
{
if
(!
isWeekend
)
{
detail
=
check
.
getState
().
concat
(
","
).
concat
(
check
.
getApprove
());
detail
=
check
.
getState
().
concat
(
","
).
concat
(
check
.
getApprove
());
}
}
if
(
is
Exist
&&
isWeekend
)
{
if
(
is
OverTime
)
{
detail
=
"加班"
;
detail
.
concat
(
"加班"
)
;
}
}
d
[
index
]
=
detail
.
concat
(
"("
)
d
[
index
]
=
detail
.
concat
(
"("
)
...
@@ -396,10 +423,14 @@ public class FileServiceImpl implements FileService {
...
@@ -396,10 +423,14 @@ public class FileServiceImpl implements FileService {
}
}
if
(!
isExist
)
{
if
(!
isExist
)
{
if
(!
isWeekend
)
{
if
(
isWeekend
)
{
d
[
index
]
=
"无记录"
;
if
(
isOverTime
)
{
d
[
index
]
=
"加班"
;
}
else
{
d
[
index
]
=
"未加班"
;
}
}
else
{
}
else
{
d
[
index
]
=
"
未加班
"
;
d
[
index
]
=
"
无记录
"
;
}
}
}
}
}
}
...
@@ -420,4 +451,42 @@ public class FileServiceImpl implements FileService {
...
@@ -420,4 +451,42 @@ public class FileServiceImpl implements FileService {
headers
.
setContentDispositionFormData
(
"attachment"
,
dfileName
);
headers
.
setContentDispositionFormData
(
"attachment"
,
dfileName
);
return
new
ResponseEntity
<>(
FileUtils
.
readFileToByteArray
(
dst
),
headers
,
HttpStatus
.
CREATED
);
return
new
ResponseEntity
<>(
FileUtils
.
readFileToByteArray
(
dst
),
headers
,
HttpStatus
.
CREATED
);
}
}
@Override
public
Map
<
String
,
Set
<
String
>>
overtimeRecord
(
ExcelData
data
)
{
//1. 根据员工姓名分组
Map
<
String
,
List
<
String
[]>>
map
=
data
.
getDatas
().
stream
().
collect
(
Collectors
.
groupingBy
(
d
->
d
[
2
]));
Map
<
String
,
Set
<
String
>>
overtimeData
=
new
HashMap
<>();
map
.
entrySet
().
forEach
(
entry
->
{
String
name
=
entry
.
getKey
();
List
<
String
[]>
value
=
entry
.
getValue
();
Set
<
String
>
dateList
=
new
HashSet
<>();
value
.
stream
().
filter
(
strings
->
strings
[
9
].
equalsIgnoreCase
(
"已通过"
))
.
forEach
(
strings1
->
{
try
{
String
start
=
DateUtils
.
formatDate
(
DateUtils
.
parseDate
(
strings1
[
6
],
DateUtils
.
yyyyMMddHHmm1
),
DateUtils
.
yyyyMMdd
);
String
end
=
DateUtils
.
formatDate
(
DateUtils
.
parseDate
(
strings1
[
7
],
DateUtils
.
yyyyMMddHHmm1
),
DateUtils
.
yyyyMMdd
);
dateList
.
addAll
(
DateUtils
.
getAllDatesOfTwoDate
(
start
,
end
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
});
overtimeData
.
put
(
name
,
dateList
);
});
return
overtimeData
;
}
}
}
src/main/resources/static/index.html
View file @
2d1e86cd
...
@@ -23,6 +23,14 @@
...
@@ -23,6 +23,14 @@
<td><input
type=
"file"
name=
"file"
/></td>
<td><input
type=
"file"
name=
"file"
/></td>
</tr>
</tr>
<tr>
<tr>
<th
scope=
"row"
>
企业微信加班审批记录:
</th>
<td><input
type=
"file"
name=
"file"
/></td>
</tr>
<tr>
<th
scope=
"row"
>
企业微信请假审批记录:
</th>
<td><input
type=
"file"
name=
"file"
/></td>
</tr>
<tr>
<th
scope=
"row"
>
打卡机考勤记录:
</th>
<th
scope=
"row"
>
打卡机考勤记录:
</th>
<td><input
type=
"file"
name=
"file"
/></td>
<td><input
type=
"file"
name=
"file"
/></td>
</tr>
</tr>
...
...
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