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
45cbeee7
Commit
45cbeee7
authored
Oct 18, 2024
by
hongguangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MVP1.7.0 加特殊身份证
parent
1cf9b753
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
265 additions
and
0 deletions
+265
-0
TEmployeeInfoServiceImpl.java
.../yifu/archives/service/impl/TEmployeeInfoServiceImpl.java
+6
-0
TPreEmpMainServiceImpl.java
...v1/yifu/archives/service/impl/TPreEmpMainServiceImpl.java
+8
-0
DiyExcelImportUtil.java
...oud/plus/v1/yifu/common/core/util/DiyExcelImportUtil.java
+213
-0
ListStringVo.java
...a/com/yifu/cloud/plus/v1/yifu/salary/vo/ListStringVo.java
+19
-0
TSalaryStandardOriginalController.java
.../salary/controller/TSalaryStandardOriginalController.java
+11
-0
TSalaryStandardOriginalService.java
...1/yifu/salary/service/TSalaryStandardOriginalService.java
+2
-0
TSalaryStandardOriginalServiceImpl.java
...lary/service/impl/TSalaryStandardOriginalServiceImpl.java
+6
-0
No files found.
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TEmployeeInfoServiceImpl.java
View file @
45cbeee7
...
...
@@ -56,6 +56,7 @@ import com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprSalaryProperties;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.config.DaprUpmsProperties
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils
;
import
com.yifu.cloud.plus.v1.yifu.salary.vo.ListStringVo
;
import
com.yifu.cloud.plus.v1.yifu.salary.vo.TBankNameMapVo
;
import
lombok.RequiredArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
...
...
@@ -3111,6 +3112,11 @@ public class TEmployeeInfoServiceImpl extends ServiceImpl<TEmployeeInfoMapper, T
R
<
ExcelSheetVo
>
voR
;
ExcelSheetVo
vo
;
List
<
String
>
specialIdCardList
=
null
;
R
<
ListStringVo
>
specialRes
=
HttpDaprUtil
.
invokeMethodPost
(
salaryProperties
.
getAppUrl
()
,
salaryProperties
.
getAppId
(),
"/tsalarystandardoriginal/inner/getSpecialIdCardList"
,
null
,
ListStringVo
.
class
,
SecurityConstants
.
FROM_IN
);
if
(
Common
.
isNotNull
(
specialRes
)
&&
specialRes
.
getData
()
!=
null
&&
specialRes
.
getData
().
getListVo
()
!=
null
){
specialIdCardList
=
specialRes
.
getData
().
getListVo
();
}
int
maxRow
=
1000
;
if
(
filename
.
endsWith
(
".xlsx"
))
{
voR
=
DiyExcelImportUtil
.
readXlsx
(
inputStream
,
specialIdCardList
,
false
,
paramVo
.
getSheetName
(),
maxRow
);
...
...
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/TPreEmpMainServiceImpl.java
View file @
45cbeee7
...
...
@@ -54,6 +54,7 @@ import com.yifu.cloud.plus.v1.yifu.common.dapr.util.HttpDaprUtil;
import
com.yifu.cloud.plus.v1.yifu.common.mybatis.base.BaseEntity
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils
;
import
com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryEmployee
;
import
com.yifu.cloud.plus.v1.yifu.salary.vo.ListStringVo
;
import
com.yifu.cloud.plus.v1.yifu.salary.vo.TBankNameMapVo
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.log4j.Log4j2
;
...
...
@@ -2600,6 +2601,13 @@ public class TPreEmpMainServiceImpl extends ServiceImpl<TPreEmpMainMapper, TPreE
R
<
ExcelSheetVo
>
voR
=
null
;
ExcelSheetVo
vo
;
List
<
String
>
specialIdCardList
=
null
;
R
<
ListStringVo
>
specialRes
=
HttpDaprUtil
.
invokeMethodPost
(
salaryProperties
.
getAppUrl
()
,
salaryProperties
.
getAppId
(),
"/tsalarystandardoriginal/inner/getSpecialIdCardList"
,
null
,
ListStringVo
.
class
,
SecurityConstants
.
FROM_IN
);
if
(
Common
.
isNotNull
(
specialRes
)
&&
specialRes
.
getData
()
!=
null
&&
specialRes
.
getData
().
getListVo
()
!=
null
){
specialIdCardList
=
specialRes
.
getData
().
getListVo
();
}
int
maxRow
=
1000
;
if
(
filename
.
endsWith
(
".xlsx"
))
{
voR
=
DiyExcelImportUtil
.
readXlsx
(
inputStream
,
specialIdCardList
,
false
,
paramVo
.
getSheetName
(),
maxRow
);
...
...
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/util/DiyExcelImportUtil.java
View file @
45cbeee7
...
...
@@ -31,6 +31,12 @@ import java.util.regex.Pattern;
@Slf4j
public
class
DiyExcelImportUtil
implements
Serializable
{
/**
* @Description: 识别Excel,单行表头。
* @Author: hgw
* @Date: 2024/10/18 14:40
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.common.core.vo.ExcelSheetVo>
**/
public
static
R
<
ExcelSheetVo
>
readXlsx
(
InputStream
inputStream
,
List
<
String
>
specialIdCardList
,
boolean
titleFlag
,
String
sheetName
,
int
maxRow
)
throws
IOException
{
ExcelSheetVo
sheetVo
=
new
ExcelSheetVo
();
...
...
@@ -46,6 +52,213 @@ public class DiyExcelImportUtil implements Serializable {
// 存储每一列有值的表头
Map
<
String
,
String
>
titleMap
=
new
HashMap
<>();
sheets
=
StreamingReader
.
builder
().
rowCacheSize
(
1000
)
// 缓存到内存中的行数(默认是10)
.
bufferSize
(
10240
)
// 读取资源时,缓存到内存的字节大小(默认是1024)
.
open
(
inputStream
);
// 获取sheet数量
int
sheetNum
=
sheets
.
getNumberOfSheets
();
// 每个单元格内容
String
cellValue
;
// 内容行
int
dataRow
;
// 身份证所在列
int
idCardColumn
=
-
1
;
// 空白列起始号
int
nullColumn
;
// 上一个空白行
int
preNullColumn
;
// 空白列数(一旦数量达到 maxNullColumNum,将停止循环列,并删除title list与content)
int
nullColumnNum
;
// 极限空白列,超过阈值,将不继续循环列
int
maxNullColumNum
=
60
;
int
rowLastCellNum
;
String
idCardValue
;
// 超过极限空白列maxNullColumNum,只循环表头 true:未超越
boolean
nullFlag
=
true
;
// 极限空白表头列,超过阈值,将不继续循环列
int
maxTitleNullColumNum
=
1
;
// 极限空白身份证,超过将不循环行
int
maxIdCardNullRow
=
1
;
int
idCardNullNum
;
Cell
cell
;
// 循环每个sheet
Sheet
sheetAt
;
for
(
int
i
=
0
;
i
<
sheetNum
;
i
++)
{
sheetAt
=
sheets
.
getSheetAt
(
i
);
if
((
Common
.
isEmpty
(
sheetName
)
&&
i
==
0
)
||
(
Common
.
isNotNull
(
sheetAt
.
getSheetName
())
&&
Common
.
isNotNull
(
sheetName
)
&&
sheetName
.
equals
(
sheetAt
.
getSheetName
())))
{
if
(
sheetAt
.
getLastRowNum
()
>
maxRow
)
{
return
R
.
failed
(
"未避免等待较长时间,请单表不要上传超过"
+
maxRow
+
"行的数据!"
);
}
contentList
=
new
ArrayList
<>();
// 塞sheet名称
sheetVo
.
setSheetName
(
sheetAt
.
getSheetName
());
titleList
=
new
ArrayList
<>();
// 初始化每个sheet的数据行
dataRow
=
1
;
// 循环当前sheet的每行内容
idCardNullNum
=
0
;
int
rowNum
=
0
;
for
(
Row
row
:
sheetAt
)
{
nullColumn
=
-
1
;
preNullColumn
=
-
1
;
nullColumnNum
=
0
;
nullFlag
=
true
;
idCardValue
=
null
;
contentMap
=
new
HashMap
<>();
columnList
=
new
ArrayList
<>();
if
(
row
!=
null
)
{
rowLastCellNum
=
row
.
getLastCellNum
();
for
(
int
cellNum
=
0
;
cellNum
<
rowLastCellNum
;
cellNum
++)
{
columnVo
=
new
ExcelColumnVo
();
try
{
cell
=
row
.
getCell
(
cellNum
);
if
(
cell
==
null
)
{
cellValue
=
""
;
}
else
{
if
(
cell
.
getCellType
()
==
CellType
.
FORMULA
)
{
cellValue
=
String
.
valueOf
(
cell
.
getStringCellValue
());
}
else
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
)
{
cell
.
setCellType
(
CellType
.
STRING
);
cellValue
=
String
.
valueOf
(
row
.
getCell
(
cellNum
).
getStringCellValue
());
}
}
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
)
{
cellValue
=
""
;
//sheetVo.setErrorInfo("请注意单元格格式,第" + (i + 1) + "个sheet,第" + (rowNum + 1) + "行第" + (cellNum + 1) + "列。" + e.getMessage())
}
columnVo
.
setLineNum
(
cellNum
);
if
(
Common
.
isNotNull
(
cellValue
))
{
cellValue
=
cellValue
.
trim
().
replaceAll
(
"\\s+"
,
""
);
titleMap
.
put
(
String
.
valueOf
(
cellNum
),
cellValue
);
if
(
cellValue
.
contains
(
"身份证号"
))
{
idCardColumn
=
cellNum
;
}
}
columnVo
.
setContent
(
cellValue
);
if
(
nullFlag
)
{
contentMap
.
put
(
String
.
valueOf
(
cellNum
),
cellValue
);
if
(
Common
.
isEmpty
(
cellValue
))
{
if
(
preNullColumn
==
-
1
||
preNullColumn
+
1
==
cellNum
)
{
if
(
nullColumn
==
-
1
)
{
nullColumn
=
cellNum
;
}
preNullColumn
=
cellNum
;
nullColumnNum
++;
}
}
else
{
nullColumn
=
-
1
;
preNullColumn
=
-
1
;
nullColumnNum
=
0
;
columnList
.
add
(
columnVo
);
}
if
(
nullColumnNum
>=
maxNullColumNum
)
{
for
(
int
num
=
maxNullColumNum
-
1
;
num
>=
0
;
num
--)
{
contentMap
.
remove
(
String
.
valueOf
(
nullColumn
+
num
));
}
nullFlag
=
false
;
}
if
(
idCardColumn
!=
-
1
&&
cellNum
==
idCardColumn
)
{
idCardValue
=
cellValue
;
}
}
else
{
if
(
Common
.
isEmpty
(
cellValue
))
{
if
(
preNullColumn
==
-
1
||
preNullColumn
+
1
==
cellNum
)
{
if
(
nullColumn
==
-
1
)
{
nullColumn
=
cellNum
;
}
preNullColumn
=
cellNum
;
nullColumnNum
++;
}
}
else
{
nullColumn
=
-
1
;
preNullColumn
=
-
1
;
nullColumnNum
=
0
;
}
// 表头Map超过50,跳出当前行的列循环
if
(
nullColumnNum
>=
maxTitleNullColumNum
)
{
break
;
}
}
}
if
(
rowNum
>
0
)
{
if
(
idCardColumn
!=
-
1
)
{
if
(
Common
.
isEmpty
(
idCardValue
))
{
idCardNullNum
++;
}
if
(
Common
.
isNotNull
(
idCardValue
)
&&
(
regIdCard
(
idCardValue
)
// 特殊身份证允许识别
||
regSpecialIdCard
(
idCardValue
,
specialIdCardList
)
||
regIdCardError
(
idCardValue
)))
{
contentList
.
add
(
contentMap
);
}
}
}
else
{
titleList
=
new
ArrayList
<>(
columnList
);
}
}
rowNum
++;
if
(
titleFlag
)
{
break
;
}
if
(
idCardNullNum
>=
maxIdCardNullRow
)
{
break
;
}
}
sheetVo
.
setDataNum
(
dataRow
);
sheetVo
.
setTitleList
(
titleList
);
sheetVo
.
setContentList
(
contentList
);
return
R
.
ok
(
sheetVo
);
}
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
if
(
sheets
!=
null
)
{
sheets
.
close
();
}
}
finally
{
if
(
sheets
!=
null
)
{
sheets
.
close
();
}
}
return
R
.
ok
(
sheetVo
);
}
/**
* @Description: 智能识别数据行,但是有缺陷:身份证格式不对,会找不到数据行。
* @Author: hgw
* @Date: 2024/10/18 14:39
* @return: com.yifu.cloud.plus.v1.yifu.common.core.util.R<com.yifu.cloud.plus.v1.yifu.common.core.vo.ExcelSheetVo>
**/
public
static
R
<
ExcelSheetVo
>
readXlsxIntelligence
(
InputStream
inputStream
,
List
<
String
>
specialIdCardList
,
boolean
titleFlag
,
String
sheetName
,
int
maxRow
)
throws
IOException
{
ExcelSheetVo
sheetVo
=
new
ExcelSheetVo
();
Workbook
sheets
=
null
;
try
{
List
<
ExcelColumnVo
>
titleList
;
List
<
ExcelColumnVo
>
columnList
;
ExcelColumnVo
columnVo
;
// 内容list
List
<
Map
<
String
,
String
>>
contentList
;
// 每一行的内容map
Map
<
String
,
String
>
contentMap
;
// 存储每一列有值的表头
Map
<
String
,
String
>
titleMap
=
new
HashMap
<>();
sheets
=
StreamingReader
.
builder
().
rowCacheSize
(
1000
)
// 缓存到内存中的行数(默认是10)
.
bufferSize
(
10240
)
// 读取资源时,缓存到内存的字节大小(默认是1024)
.
open
(
inputStream
);
...
...
yifu-salary/yifu-salary-api/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/vo/ListStringVo.java
0 → 100644
View file @
45cbeee7
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
salary
.
vo
;
import
lombok.Data
;
import
java.util.List
;
import
java.util.Map
;
/**
* @Description: list String vo
* @Author: hgw
* @Date: 2024-10-18 15:15:55
* @return:
**/
@Data
public
class
ListStringVo
{
private
List
<
String
>
listVo
;
}
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/controller/TSalaryStandardOriginalController.java
View file @
45cbeee7
...
...
@@ -26,6 +26,7 @@ import com.yifu.cloud.plus.v1.yifu.common.core.util.R;
import
com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.MenuUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.log.annotation.SysLog
;
import
com.yifu.cloud.plus.v1.yifu.common.security.annotation.Inner
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils
;
import
com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginal
;
import
com.yifu.cloud.plus.v1.yifu.salary.entity.TSalaryStandardOriginalDetail
;
...
...
@@ -88,6 +89,16 @@ public class TSalaryStandardOriginalController {
return
new
R
<>(
tSalaryStandardOriginalService
.
getTSalaryStandardOriginalList
(
tSalaryStandardOriginal
));
}
@Operation
(
description
=
"获取特殊身份证"
)
@SysLog
(
"获取特殊身份证"
)
@Inner
@PostMapping
(
"/inner/getSpecialIdCardList"
)
public
ListStringVo
getSpecialIdCardList
()
{
ListStringVo
vo
=
new
ListStringVo
();
vo
.
setListVo
(
tSalaryStandardOriginalService
.
getSpecialIdCardList
());
return
vo
;
}
/**
* 通过id查询薪资原表识别
*
...
...
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/service/TSalaryStandardOriginalService.java
View file @
45cbeee7
...
...
@@ -45,6 +45,8 @@ public interface TSalaryStandardOriginalService extends IService<TSalaryStandard
List
<
TSalaryStandardOriginal
>
getTSalaryStandardOriginalList
(
TSalaryStandardOriginal
tSalaryStandardOriginal
);
List
<
String
>
getSpecialIdCardList
();
/**
* @param file
* @Description: 识别表头主类
...
...
yifu-salary/yifu-salary-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/salary/service/impl/TSalaryStandardOriginalServiceImpl.java
View file @
45cbeee7
...
...
@@ -111,6 +111,12 @@ public class TSalaryStandardOriginalServiceImpl extends ServiceImpl<TSalaryStand
return
baseMapper
.
getTSalaryStandardOriginalList
(
tSalaryStandardOriginal
);
}
@Override
public
List
<
String
>
getSpecialIdCardList
()
{
List
<
String
>
specialIdCardList
=
baseMapper
.
getSpecialIdCardList
();
return
specialIdCardList
;
}
/**
* @param file
* @Description: 核心解析
...
...
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