Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
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
fangxinjiang
yifu-mvp
Commits
7f780f22
Commit
7f780f22
authored
Apr 10, 2024
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MVP1.6.2-工资原表识别-主逻辑优化
parent
93c04356
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
6 deletions
+56
-6
ExcelSheetVo.java
...a/com/yifu/cloud/plus/v1/yifu/salary/vo/ExcelSheetVo.java
+2
-0
TSalaryStandardOriginalServiceImpl.java
...lary/service/impl/TSalaryStandardOriginalServiceImpl.java
+54
-6
No files found.
yifu-salary/yifu-salary-api/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/vo/ExcelSheetVo.java
View file @
7f780f22
...
@@ -18,6 +18,8 @@ public class ExcelSheetVo {
...
@@ -18,6 +18,8 @@ public class ExcelSheetVo {
private
int
dataNum
;
private
int
dataNum
;
// sheet名
// sheet名
private
String
sheetName
;
private
String
sheetName
;
// 解析过程发现的错误信息
private
String
errorInfo
;
// 标题行
// 标题行
private
List
<
ExcelColumnVo
>
titleList
;
private
List
<
ExcelColumnVo
>
titleList
;
// 内容行+列
// 内容行+列
...
...
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/service/impl/TSalaryStandardOriginalServiceImpl.java
View file @
7f780f22
...
@@ -35,9 +35,9 @@ import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants;
...
@@ -35,9 +35,9 @@ import com.yifu.cloud.plus.v1.yifu.salary.util.SalaryConstants;
import
com.yifu.cloud.plus.v1.yifu.salary.vo.*
;
import
com.yifu.cloud.plus.v1.yifu.salary.vo.*
;
import
lombok.AllArgsConstructor
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
import
lombok.extern.log4j.Log4j2
;
import
org.apache.poi.hssf.usermodel.
HSSFRow
;
import
org.apache.poi.hssf.usermodel.
*
;
import
org.apache.poi.
hssf.usermodel.HSSFSheet
;
import
org.apache.poi.
ss.usermodel.CellType
;
import
org.apache.poi.
hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.
xssf.usermodel.XSSFCell
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFRow
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFSheet
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
...
@@ -47,6 +47,7 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -47,6 +47,7 @@ import org.springframework.web.multipart.MultipartFile;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStream
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.DecimalFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
...
@@ -157,6 +158,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
...
@@ -157,6 +158,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
int
dataRow
;
int
dataRow
;
// 数据行是否被确认,true否
// 数据行是否被确认,true否
boolean
dataRowFlag
;
boolean
dataRowFlag
;
HSSFCell
cell
;
// 循环每个sheet
// 循环每个sheet
for
(
int
i
=
0
;
i
<
sheetNum
;
i
++)
{
for
(
int
i
=
0
;
i
<
sheetNum
;
i
++)
{
sheetAt
=
sheets
.
getSheetAt
(
i
);
sheetAt
=
sheets
.
getSheetAt
(
i
);
...
@@ -177,7 +179,30 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
...
@@ -177,7 +179,30 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if
(
row
!=
null
)
{
if
(
row
!=
null
)
{
for
(
int
cellNum
=
0
;
cellNum
<
row
.
getLastCellNum
();
cellNum
++)
{
for
(
int
cellNum
=
0
;
cellNum
<
row
.
getLastCellNum
();
cellNum
++)
{
columnVo
=
new
ExcelColumnVo
();
columnVo
=
new
ExcelColumnVo
();
cellValue
=
row
.
getCell
(
cellNum
).
getStringCellValue
();
try
{
cell
=
row
.
getCell
(
cellNum
);
if
(
CellType
.
STRING
==
cell
.
getCellType
())
{
cellValue
=
row
.
getCell
(
cellNum
).
getStringCellValue
();
}
else
if
(
CellType
.
NUMERIC
==
cell
.
getCellType
())
{
try
{
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getNumericCellValue
());
if
(
cellValue
.
contains
(
"E"
))
{
cellValue
=
String
.
valueOf
(
new
DecimalFormat
(
"#"
).
format
(
row
.
getCell
(
cellNum
).
getNumericCellValue
()));
}
}
catch
(
NumberFormatException
e
)
{
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getNumericCellValue
());
}
}
else
if
(
HSSFDateUtil
.
isCellDateFormatted
(
cell
))
{
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getDateCellValue
());
}
else
if
(
CellType
.
BOOLEAN
==
cell
.
getCellType
())
{
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getBooleanCellValue
());
}
else
{
cellValue
=
row
.
getCell
(
cellNum
).
getStringCellValue
();
}
}
catch
(
Exception
e
)
{
sheetVo
.
setErrorInfo
(
"请注意单元格格式,第"
+(
i
+
1
)
+
"个sheet,第"
+(
rowNum
+
1
)+
"行第"
+(
cellNum
+
1
)+
"列。"
+
e
.
getMessage
());
return
sheetVo
;
}
if
(
Common
.
isNotNull
(
cellValue
))
{
if
(
Common
.
isNotNull
(
cellValue
))
{
if
(
dataRowFlag
if
(
dataRowFlag
&&
(((
cellValue
.
length
()
==
15
||
cellValue
.
length
()
==
18
)
&&
regIdCard
(
cellValue
))
&&
(((
cellValue
.
length
()
==
15
||
cellValue
.
length
()
==
18
)
&&
regIdCard
(
cellValue
))
...
@@ -256,6 +281,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
...
@@ -256,6 +281,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
int
dataRow
;
int
dataRow
;
// 数据行是否被确认,true否
// 数据行是否被确认,true否
boolean
dataRowFlag
;
boolean
dataRowFlag
;
XSSFCell
cell
;
// 循环每个sheet
// 循环每个sheet
for
(
int
i
=
0
;
i
<
sheetNum
;
i
++)
{
for
(
int
i
=
0
;
i
<
sheetNum
;
i
++)
{
sheetAt
=
sheets
.
getSheetAt
(
i
);
sheetAt
=
sheets
.
getSheetAt
(
i
);
...
@@ -276,7 +302,30 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
...
@@ -276,7 +302,30 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if
(
row
!=
null
)
{
if
(
row
!=
null
)
{
for
(
int
cellNum
=
0
;
cellNum
<
row
.
getLastCellNum
();
cellNum
++)
{
for
(
int
cellNum
=
0
;
cellNum
<
row
.
getLastCellNum
();
cellNum
++)
{
columnVo
=
new
ExcelColumnVo
();
columnVo
=
new
ExcelColumnVo
();
cellValue
=
row
.
getCell
(
cellNum
).
getStringCellValue
();
try
{
cell
=
row
.
getCell
(
cellNum
);
if
(
CellType
.
STRING
==
cell
.
getCellType
())
{
cellValue
=
row
.
getCell
(
cellNum
).
getStringCellValue
();
}
else
if
(
CellType
.
NUMERIC
==
cell
.
getCellType
())
{
try
{
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getNumericCellValue
());
if
(
cellValue
.
contains
(
"E"
))
{
cellValue
=
String
.
valueOf
(
new
DecimalFormat
(
"#"
).
format
(
row
.
getCell
(
cellNum
).
getNumericCellValue
()));
}
}
catch
(
NumberFormatException
e
)
{
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getNumericCellValue
());
}
}
else
if
(
HSSFDateUtil
.
isCellDateFormatted
(
cell
))
{
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getDateCellValue
());
}
else
if
(
CellType
.
BOOLEAN
==
cell
.
getCellType
())
{
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getBooleanCellValue
());
}
else
{
cellValue
=
row
.
getCell
(
cellNum
).
getStringCellValue
();
}
}
catch
(
Exception
e
)
{
sheetVo
.
setErrorInfo
(
"请注意单元格格式,第"
+(
i
+
1
)
+
"个sheet,第"
+(
rowNum
+
1
)+
"行第"
+(
cellNum
+
1
)+
"列。"
+
e
.
getMessage
());
return
sheetVo
;
}
if
(
Common
.
isNotNull
(
cellValue
))
{
if
(
Common
.
isNotNull
(
cellValue
))
{
if
(
dataRowFlag
if
(
dataRowFlag
&&
(((
cellValue
.
length
()
==
15
||
cellValue
.
length
()
==
18
)
&&
regIdCard
(
cellValue
))
&&
(((
cellValue
.
length
()
==
15
||
cellValue
.
length
()
==
18
)
&&
regIdCard
(
cellValue
))
...
@@ -443,7 +492,6 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
...
@@ -443,7 +492,6 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
List
<
Map
<
String
,
String
>>
contentList
=
new
ArrayList
<>();
List
<
Map
<
String
,
String
>>
contentList
=
new
ArrayList
<>();
Map
<
String
,
String
>
newRowMap
;
Map
<
String
,
String
>
newRowMap
;
String
value
;
String
value
;
BigDecimal
valueBig
;
String
oldValue
;
String
oldValue
;
int
i
=
0
;
int
i
=
0
;
for
(
Map
<
String
,
String
>
rowMap
:
vo
.
getContentList
())
{
for
(
Map
<
String
,
String
>
rowMap
:
vo
.
getContentList
())
{
...
...
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