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
1a8ca625
Commit
1a8ca625
authored
Apr 28, 2024
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MVP1.6.3 特殊导入-优化
parent
91d9c1ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
24 deletions
+75
-24
TSalaryStandardOriginalServiceImpl.java
...lary/service/impl/TSalaryStandardOriginalServiceImpl.java
+75
-24
No files found.
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/service/impl/TSalaryStandardOriginalServiceImpl.java
View file @
1a8ca625
...
...
@@ -124,9 +124,9 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
InputStream
inputStream
=
file
.
getInputStream
();
//根据文件格式 对应不同的api解析
if
(
filename
.
endsWith
(
".xlsx"
))
{
voR
=
readXlsx
(
inputStream
,
specialIdCardList
,
true
,
sheetName
,
-
1
);
voR
=
readXlsx
(
inputStream
,
specialIdCardList
,
true
,
sheetName
,
-
1
,
null
);
}
else
{
voR
=
readXls
(
inputStream
,
specialIdCardList
,
true
,
sheetName
,
-
1
);
voR
=
readXls
(
inputStream
,
specialIdCardList
,
true
,
sheetName
,
-
1
,
null
);
}
if
(
voR
!=
null
&&
voR
.
getCode
()
==
CommonConstants
.
SUCCESS
)
{
vo
=
voR
.
getData
();
...
...
@@ -146,6 +146,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
}
/**
* @param maxColumn 表格表头长度 + 10 (有可能含有未配置的新员工之类的系统表头,放宽10列)
* @param inputStream
* @param specialIdCardList
* @param titleFlag true:返回title;false:返回content
...
...
@@ -155,7 +156,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
* @return: com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo
**/
private
R
<
ExcelSheetVo
>
readXls
(
InputStream
inputStream
,
List
<
String
>
specialIdCardList
,
boolean
titleFlag
,
String
sheetName
,
int
idCardNum
)
throws
IOException
{
,
String
sheetName
,
int
idCardNum
,
Integer
maxColumn
)
throws
IOException
{
HSSFWorkbook
sheets
=
null
;
ExcelSheetVo
sheetVo
=
new
ExcelSheetVo
();
try
{
...
...
@@ -188,6 +189,11 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
int
nullColumnNum
=
0
;
// 极限空白列,超过阈值,将不继续循环列
int
maxNullColumNum
=
30
;
int
rowLastCellNum
=
-
1
;
if
(
Common
.
isNotNull
(
maxColumn
))
{
maxNullColumNum
=
maxColumn
;
rowLastCellNum
=
maxColumn
;
}
String
idCardValue
=
null
;
// 数据行是否被确认,true否
boolean
dataRowFlag
;
...
...
@@ -213,7 +219,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
dataRowFlag
=
true
;
idCardNullNum
=
0
;
// 循环当前sheet的每行内容
for
(
int
rowNum
=
0
;
rowNum
<=
sheetAt
.
getLastRowNum
();
rowNum
++)
{
if
(
Common
.
isNotNull
(
maxColumn
))
{
rowLastCellNum
=
maxColumn
;
}
else
{
rowLastCellNum
=
sheetAt
.
getLastRowNum
();
}
for
(
int
rowNum
=
0
;
rowNum
<=
rowLastCellNum
;
rowNum
++)
{
nullColumn
=
-
1
;
preNullColumn
=
-
1
;
...
...
@@ -260,6 +271,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
//sheetVo.setErrorInfo("请注意单元格格式,第" + (i + 1) + "个sheet,第" + (rowNum + 1) + "行第" + (cellNum + 1) + "列。" + e.getMessage())
//return sheetVo
}
columnVo
.
setLineNum
(
cellNum
);
if
(
Common
.
isNotNull
(
cellValue
))
{
cellValue
=
cellValue
.
trim
().
replaceAll
(
"\\s+"
,
""
);
titleMap
.
put
(
String
.
valueOf
(
cellNum
),
cellValue
);
}
columnVo
.
setContent
(
cellValue
);
if
(
dataRowFlag
)
{
if
(
idCardColumn
!=
-
1
)
{
if
(
idCardColumn
==
cellNum
&&
Common
.
isNotNull
(
cellValue
)
&&
...
...
@@ -280,12 +297,6 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
}
}
}
columnVo
.
setLineNum
(
cellNum
);
if
(
Common
.
isNotNull
(
cellValue
))
{
cellValue
=
cellValue
.
trim
().
replaceAll
(
"\\s+"
,
""
);
titleMap
.
put
(
String
.
valueOf
(
cellNum
),
cellValue
);
}
columnVo
.
setContent
(
cellValue
);
if
(
nullFlag
)
{
contentMap
.
put
(
String
.
valueOf
(
cellNum
),
cellValue
);
if
(
dataRowFlag
)
{
...
...
@@ -360,7 +371,11 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if
(
Common
.
isEmpty
(
idCardValue
))
{
idCardNullNum
++;
}
if
(
Common
.
isNotNull
(
idCardValue
))
{
if
(
Common
.
isNotNull
(
idCardValue
)
&&
(
regIdCard
(
idCardValue
)
// 特殊身份证允许识别
||
regSpecialIdCard
(
idCardValue
,
specialIdCardList
)
||
regIdCardError
(
idCardValue
)
))
{
contentList
.
add
(
contentMap
);
}
}
...
...
@@ -379,6 +394,9 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
}
}
if
(
dataRowFlag
)
{
if
(
idCardNum
!=
-
1
)
{
return
R
.
failed
(
"您配置的身份证列第【"
+(
idCardNum
+
1
)+
"】列未找到身份证,请确认表头配置或表格数据!!"
);
}
return
R
.
failed
(
"未找到身份证所在的数据行,请检查表数据!!"
);
}
sheetVo
.
setDataNum
(
dataRow
);
...
...
@@ -401,6 +419,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
}
/**
* @param maxColumn 表格表头长度 + 10 (有可能含有未配置的新员工之类的系统表头,放宽10列)
* @param inputStream
* @param specialIdCardList
* @param titleFlag true:返回title;false:返回content
...
...
@@ -410,7 +429,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
* @return: com.yifu.cloud.plus.v1.yifu.salary.vo.ExcelVo
**/
private
R
<
ExcelSheetVo
>
readXlsx
(
InputStream
inputStream
,
List
<
String
>
specialIdCardList
,
boolean
titleFlag
,
String
sheetName
,
int
idCardNum
)
throws
IOException
{
,
String
sheetName
,
int
idCardNum
,
Integer
maxColumn
)
throws
IOException
{
ExcelSheetVo
sheetVo
=
new
ExcelSheetVo
();
Workbook
sheets
=
null
;
try
{
...
...
@@ -447,7 +466,11 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
// 空白列数(一旦数量达到 maxNullColumNum,将停止循环列,并删除title list与content)
int
nullColumnNum
=
0
;
// 极限空白列,超过阈值,将不继续循环列
int
maxNullColumNum
=
10
;
int
maxNullColumNum
=
30
;
int
rowLastCellNum
=
-
1
;
if
(
Common
.
isNotNull
(
maxColumn
))
{
maxNullColumNum
=
maxColumn
;
}
String
idCardValue
=
null
;
// 数据行是否被确认,true否
boolean
dataRowFlag
;
...
...
@@ -490,7 +513,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
contentMap
=
new
HashMap
<>();
columnList
=
new
ArrayList
<>();
if
(
row
!=
null
)
{
for
(
int
cellNum
=
0
;
cellNum
<
row
.
getLastCellNum
();
cellNum
++)
{
if
(
Common
.
isNotNull
(
maxColumn
))
{
rowLastCellNum
=
maxColumn
;
}
else
{
rowLastCellNum
=
row
.
getLastCellNum
();
}
for
(
int
cellNum
=
0
;
cellNum
<
rowLastCellNum
;
cellNum
++)
{
columnVo
=
new
ExcelColumnVo
();
try
{
cell
=
row
.
getCell
(
cellNum
);
...
...
@@ -524,6 +552,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
//sheetVo.setErrorInfo("请注意单元格格式,第" + (i + 1) + "个sheet,第" + (rowNum + 1) + "行第" + (cellNum + 1) + "列。" + e.getMessage())
//return sheetVo
}
columnVo
.
setLineNum
(
cellNum
);
if
(
Common
.
isNotNull
(
cellValue
))
{
cellValue
=
cellValue
.
trim
().
replaceAll
(
"\\s+"
,
""
);
titleMap
.
put
(
String
.
valueOf
(
cellNum
),
cellValue
);
}
columnVo
.
setContent
(
cellValue
);
if
(
dataRowFlag
)
{
if
(
idCardColumn
!=
-
1
)
{
if
(
idCardColumn
==
cellNum
&&
Common
.
isNotNull
(
cellValue
)
&&
...
...
@@ -544,12 +578,6 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
}
}
}
columnVo
.
setLineNum
(
cellNum
);
if
(
Common
.
isNotNull
(
cellValue
))
{
cellValue
=
cellValue
.
trim
().
replaceAll
(
"\\s+"
,
""
);
titleMap
.
put
(
String
.
valueOf
(
cellNum
),
cellValue
);
}
columnVo
.
setContent
(
cellValue
);
if
(
nullFlag
)
{
contentMap
.
put
(
String
.
valueOf
(
cellNum
),
cellValue
);
if
(
dataRowFlag
)
{
...
...
@@ -624,7 +652,11 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
if
(
Common
.
isEmpty
(
idCardValue
))
{
idCardNullNum
++;
}
if
(
Common
.
isNotNull
(
idCardValue
))
{
if
(
Common
.
isNotNull
(
idCardValue
)
&&
(
regIdCard
(
idCardValue
)
// 特殊身份证允许识别
||
regSpecialIdCard
(
idCardValue
,
specialIdCardList
)
||
regIdCardError
(
idCardValue
)
))
{
contentList
.
add
(
contentMap
);
}
}
...
...
@@ -644,6 +676,9 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
}
}
if
(
dataRowFlag
)
{
if
(
idCardNum
!=
-
1
)
{
return
R
.
failed
(
"您配置的身份证列第【"
+(
idCardNum
+
1
)+
"】列未找到身份证,请确认表头配置或表格数据!!"
);
}
return
R
.
failed
(
"未找到身份证所在的数据行,请检查表数据!!"
);
}
sheetVo
.
setDataNum
(
dataRow
);
...
...
@@ -702,6 +737,18 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
return
flag
;
}
/**
* @param content
* @Description: 判断类似身份证的数据,进识别行,提示客服该行错误:14位数字
* 格式正确返回true
* @Author: hgw
* @Date: 2022/5/13 11:53
* @return: boolean
**/
private
static
boolean
regIdCardError
(
String
content
)
{
return
content
.
matches
(
"^.*\\d{14}.*$"
);
}
/**
* @param excelVo
* @Description: 新版原表识别导入
...
...
@@ -736,6 +783,10 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
List
<
TSalaryStandardOriginalDetail
>
detailList
=
tSalaryStandardOriginalDetailService
.
getTSalaryStandardOriginalDetailByOrgId
(
originalId
);
Map
<
String
,
TSalaryStandardOriginalDetail
>
detailMap
=
new
HashMap
<>();
int
idCardNum
=
-
1
;
if
(
detailList
==
null
||
detailList
.
isEmpty
()
||
detailList
.
size
()
<
4
)
{
return
R
.
failed
(
"请检查表头配置!"
);
}
int
maxColumn
=
detailList
.
size
()
+
10
;
for
(
TSalaryStandardOriginalDetail
detail
:
detailList
)
{
if
(
Common
.
isEmpty
(
detail
.
getModelName
())
&&
(
"是否新员工(默认否)"
.
equals
(
detail
.
getExcelName
())
...
...
@@ -774,9 +825,9 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
ExcelSheetVo
vo
;
//根据文件格式 对应不同的api解析
if
(
filename
.
endsWith
(
".xlsx"
))
{
voR
=
readXlsx
(
inputStream
,
specialIdCardList
,
false
,
sheetName
,
idCardNum
);
voR
=
readXlsx
(
inputStream
,
specialIdCardList
,
false
,
sheetName
,
idCardNum
,
maxColumn
);
}
else
{
voR
=
readXls
(
inputStream
,
specialIdCardList
,
false
,
sheetName
,
idCardNum
);
voR
=
readXls
(
inputStream
,
specialIdCardList
,
false
,
sheetName
,
idCardNum
,
maxColumn
);
}
if
(
voR
!=
null
&&
voR
.
getCode
()
==
CommonConstants
.
SUCCESS
)
{
vo
=
voR
.
getData
();
...
...
@@ -797,7 +848,7 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
&&
!
"开户行支行"
.
equals
(
title
.
getContent
())
&&
!
"银行卡号"
.
equals
(
title
.
getContent
())
&&
!
"手机号码"
.
equals
(
title
.
getContent
())
&&
!
"计税月份"
.
equals
(
title
.
getContent
()))
{
&&
!
"计税月份"
.
equals
(
title
.
getContent
())
&&
title
.
getLineNum
()
<
detailList
.
size
()
)
{
return
R
.
failed
(
"未找到对应配置的表头,请核实导入的原表信息后,重新尝试!"
);
//return R.failed("表头与导入的不一致,第" + title.getLineNum() + "列表头【" + title.getContent() + "】未找到配置,请先配置表头!");
...
...
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