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
ccf568ab
Commit
ccf568ab
authored
Jun 11, 2024
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实缴修改
parent
6b1c50ad
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
131 deletions
+110
-131
TPaymentInfoServiceImpl.java
.../v1/yifu/social/service/impl/TPaymentInfoServiceImpl.java
+110
-131
No files found.
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TPaymentInfoServiceImpl.java
View file @
ccf568ab
...
...
@@ -1710,14 +1710,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
@Override
public
R
<
List
<
ErrorMessage
>>
importTaxSocialInfoDiy
(
InputStream
inputStream
)
{
YifuUser
user
=
SecurityUtils
.
getUser
();
String
sumNumKey
=
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
"sum_key"
;
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
sumNumKey
)))
{
redisUtil
.
remove
(
sumNumKey
);
}
String
importSuccessKey
=
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CommonConstants
.
PAYMENT_SOCIAL_WAIT_EXPORT
;
if
(
Common
.
isNotNull
(
redisUtil
.
get
(
importSuccessKey
)))
{
redisUtil
.
remove
(
importSuccessKey
);
}
//养老插入的集合
ConcurrentHashMap
<
String
,
TPaymentInfo
>
batchYlInsertList
=
new
ConcurrentHashMap
<>();
//工伤插入的集合
...
...
@@ -1801,8 +1793,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
*/
private
void
saveData
()
{
log
.
info
(
"{}条数据,开始存储数据库!"
,
cachedDataList
.
size
());
importTPaymentSocialTax
(
cachedDataList
,
errorMessageMap
,
rowNumber
,
pensionMoneyMap
,
birthMoneyMap
,
bigMoneyMap
,
unEmpMoneyMap
,
injuryMoneyMap
,
medicalMoneyMap
,
sumNumKey
,
importSuccessKey
importTPaymentSocialTax
(
cachedDataList
,
errorMessageMap
,
pensionMoneyMap
,
birthMoneyMap
,
bigMoneyMap
,
unEmpMoneyMap
,
injuryMoneyMap
,
medicalMoneyMap
,
batchGsInsertList
,
batchSyInsertList
,
batchYlInsertList
,
batchYyInsertList
,
batchBigInsertList
,
batchBirthInsertList
,
areaMap
,
areaMap2
,
domainMap
);
...
...
@@ -1819,35 +1811,47 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
areaMap2
.
clear
();
domainMap
.
clear
();
//批量插入数据
//养老
List
<
TPaymentInfo
>
list
;
if
(!
batchYlInsertList
.
isEmpty
())
{
this
.
saveBatch
(
batchYlInsertList
.
values
());
list
=
new
ArrayList
<>(
batchYlInsertList
.
values
());
this
.
saveBatch
(
list
);
batchYlInsertList
.
clear
();
list
.
clear
();
}
//工伤
if
(!
batchGsInsertList
.
isEmpty
())
{
this
.
saveBatch
(
batchGsInsertList
.
values
());
list
=
new
ArrayList
<>(
batchGsInsertList
.
values
());
this
.
saveBatch
(
list
);
batchGsInsertList
.
clear
();
list
.
clear
();
}
//医疗
if
(!
batchYyInsertList
.
isEmpty
())
{
this
.
saveBatch
(
batchYyInsertList
.
values
());
list
=
new
ArrayList
<>(
batchYyInsertList
.
values
());
this
.
saveBatch
(
list
);
batchYyInsertList
.
clear
();
list
.
clear
();
}
//失业
if
(!
batchSyInsertList
.
isEmpty
())
{
this
.
saveBatch
(
batchSyInsertList
.
values
());
list
=
new
ArrayList
<>(
batchSyInsertList
.
values
());
this
.
saveBatch
(
list
);
batchSyInsertList
.
clear
();
list
.
clear
();
}
//大病
if
(!
batchBigInsertList
.
isEmpty
())
{
this
.
saveBatch
(
batchBigInsertList
.
values
());
list
=
new
ArrayList
<>(
batchBigInsertList
.
values
());
this
.
saveBatch
(
list
);
batchBigInsertList
.
clear
();
list
.
clear
();
}
//生育
if
(!
batchBirthInsertList
.
isEmpty
())
{
this
.
saveBatch
(
batchBirthInsertList
.
values
());
list
=
new
ArrayList
<>(
batchBirthInsertList
.
values
());
this
.
saveBatch
(
list
);
batchBirthInsertList
.
clear
();
list
.
clear
();
}
}
catch
(
Exception
e
)
{
log
.
error
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
,
e
);
...
...
@@ -1858,93 +1862,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
return
this
.
judgeAllMessage1
(
errorMessageList
);
}
@Override
public
R
<
List
<
ErrorDetailVO
>>
batchImportPaymentFundInfo
(
InputStream
inputStream
)
{
List
<
ErrorDetailVO
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
TPaymentInfoVo
>
util1
=
new
ExcelUtil
<>(
TPaymentInfoVo
.
class
);
//批量插入的集合
List
<
TPaymentInfo
>
batchInsertList
=
new
ArrayList
<>();
//获取所有项目信息
Map
<
String
,
TSettleDomainSelectVo
>
domainMap
=
this
.
getSelectVoMap
();
//地区数据
HashMap
<
String
,
String
>
areaMap
=
new
HashMap
<>();
HashMap
<
String
,
String
>
areaMap2
=
new
HashMap
<>();
//公积金唯一性检验条件:身份证编码+公积金缴纳月份
HashMap
<
String
,
Object
>
paymentInfoMap
=
new
HashMap
<>();
R
<
AreaVo
>
areaListR
=
upmsDaprUtils
.
getAreaListR
();
if
(
Common
.
isNotNull
(
areaListR
))
{
AreaVo
areaList
=
areaListR
.
getData
();
if
(
null
!=
areaList
&&
!
areaList
.
getSysAreaList
().
isEmpty
())
{
for
(
SysArea
area
:
areaList
.
getSysAreaList
())
{
areaMap
.
put
(
Integer
.
toString
(
area
.
getId
()),
area
.
getAreaName
());
areaMap2
.
put
(
area
.
getAreaName
()
+
CommonConstants
.
DOWN_LINE_STRING
+
(
null
==
area
.
getParentId
()
?
"null"
:
(
0
==
area
.
getParentId
()
?
"null"
:
Integer
.
toString
(
area
.
getParentId
()))),
Integer
.
toString
(
area
.
getId
()));
}
}
}
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
TPaymentInfoVo
.
class
,
new
ReadListener
<
TPaymentInfoVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
TPaymentInfoVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
TPaymentInfoVo
data
,
AnalysisContext
context
)
{
ReadRowHolder
readRowHolder
=
context
.
readRowHolder
();
Integer
rowIndex
=
readRowHolder
.
getRowIndex
();
data
.
setRowIndex
(
rowIndex
+
1
);
ErrorMessage
errorMessage
=
util1
.
checkEntity
(
data
,
data
.
getRowIndex
());
if
(
Common
.
isNotNull
(
errorMessage
))
{
errorMessageList
.
add
(
new
ErrorDetailVO
(
errorMessage
.
getLineNum
(),
errorMessage
.
getMessage
()));
}
else
{
cachedDataList
.
add
(
data
);
}
if
(
cachedDataList
.
size
()
>=
BATCH_COUNT
)
{
saveData
();
// 存储完成清理 list
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
saveData
();
}
/**
* 加上存储数据库
*/
private
void
saveData
()
{
log
.
info
(
"{}条数据,开始存储数据库!"
,
cachedDataList
.
size
());
batchSavePaymentFundInfo
(
cachedDataList
,
errorMessageList
,
batchInsertList
,
areaMap
,
areaMap2
,
domainMap
,
paymentInfoMap
);
log
.
info
(
"存储数据库成功!"
);
}
}).
sheet
().
doRead
();
//批量插入数据
if
(!
batchInsertList
.
isEmpty
())
{
this
.
saveBatch
(
batchInsertList
);
batchInsertList
.
clear
();
}
areaMap
.
clear
();
areaMap2
.
clear
();
domainMap
.
clear
();
}
catch
(
Exception
e
)
{
log
.
error
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
,
e
);
return
R
.
failed
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
);
}
return
this
.
judgeAllMessage
(
errorMessageList
);
}
private
void
batchSavePaymentFundInfo
(
List
<
TPaymentInfoVo
>
list
,
List
<
ErrorDetailVO
>
errorMessageList
,
List
<
TPaymentInfo
>
batchInsertList
,
HashMap
<
String
,
String
>
areaMap
,
HashMap
<
String
,
String
>
areaMap2
,
Map
<
String
,
TSettleDomainSelectVo
>
domainMap
,
...
...
@@ -2214,16 +2131,101 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
}
@Override
public
R
<
List
<
ErrorDetailVO
>>
batchImportPaymentFundInfo
(
InputStream
inputStream
)
{
List
<
ErrorDetailVO
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
TPaymentInfoVo
>
util1
=
new
ExcelUtil
<>(
TPaymentInfoVo
.
class
);
//批量插入的集合
List
<
TPaymentInfo
>
batchInsertList
=
new
ArrayList
<>();
//获取所有项目信息
Map
<
String
,
TSettleDomainSelectVo
>
domainMap
=
this
.
getSelectVoMap
();
//地区数据
HashMap
<
String
,
String
>
areaMap
=
new
HashMap
<>();
HashMap
<
String
,
String
>
areaMap2
=
new
HashMap
<>();
//公积金唯一性检验条件:身份证编码+公积金缴纳月份
HashMap
<
String
,
Object
>
paymentInfoMap
=
new
HashMap
<>();
R
<
AreaVo
>
areaListR
=
upmsDaprUtils
.
getAreaListR
();
if
(
Common
.
isNotNull
(
areaListR
))
{
AreaVo
areaList
=
areaListR
.
getData
();
if
(
null
!=
areaList
&&
!
areaList
.
getSysAreaList
().
isEmpty
())
{
for
(
SysArea
area
:
areaList
.
getSysAreaList
())
{
areaMap
.
put
(
Integer
.
toString
(
area
.
getId
()),
area
.
getAreaName
());
areaMap2
.
put
(
area
.
getAreaName
()
+
CommonConstants
.
DOWN_LINE_STRING
+
(
null
==
area
.
getParentId
()
?
"null"
:
(
0
==
area
.
getParentId
()
?
"null"
:
Integer
.
toString
(
area
.
getParentId
()))),
Integer
.
toString
(
area
.
getId
()));
}
}
}
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
try
{
EasyExcel
.
read
(
inputStream
,
TPaymentInfoVo
.
class
,
new
ReadListener
<
TPaymentInfoVo
>()
{
/**
* 单次缓存的数据量
*/
public
static
final
int
BATCH_COUNT
=
CommonConstants
.
BATCH_COUNT
;
/**
*临时存储
*/
private
List
<
TPaymentInfoVo
>
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
@Override
public
void
invoke
(
TPaymentInfoVo
data
,
AnalysisContext
context
)
{
ReadRowHolder
readRowHolder
=
context
.
readRowHolder
();
Integer
rowIndex
=
readRowHolder
.
getRowIndex
();
data
.
setRowIndex
(
rowIndex
+
1
);
ErrorMessage
errorMessage
=
util1
.
checkEntity
(
data
,
data
.
getRowIndex
());
if
(
Common
.
isNotNull
(
errorMessage
))
{
errorMessageList
.
add
(
new
ErrorDetailVO
(
errorMessage
.
getLineNum
(),
errorMessage
.
getMessage
()));
}
else
{
cachedDataList
.
add
(
data
);
}
if
(
cachedDataList
.
size
()
>=
BATCH_COUNT
)
{
saveData
();
// 存储完成清理 list
cachedDataList
=
ListUtils
.
newArrayListWithExpectedSize
(
BATCH_COUNT
);
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
saveData
();
}
/**
* 加上存储数据库
*/
private
void
saveData
()
{
log
.
info
(
"{}条数据,开始存储数据库!"
,
cachedDataList
.
size
());
batchSavePaymentFundInfo
(
cachedDataList
,
errorMessageList
,
batchInsertList
,
areaMap
,
areaMap2
,
domainMap
,
paymentInfoMap
);
log
.
info
(
"存储数据库成功!"
);
}
}).
sheet
().
doRead
();
//批量插入数据
if
(!
batchInsertList
.
isEmpty
())
{
this
.
saveBatch
(
batchInsertList
);
batchInsertList
.
clear
();
}
areaMap
.
clear
();
areaMap2
.
clear
();
domainMap
.
clear
();
}
catch
(
Exception
e
)
{
log
.
error
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
,
e
);
return
R
.
failed
(
CommonConstants
.
IMPORT_DATA_ANALYSIS_ERROR
);
}
return
this
.
judgeAllMessage
(
errorMessageList
);
}
private
void
importTPaymentSocialTax
(
List
<
TPaymentTaxSocialVo
>
list
,
ConcurrentHashMap
<
String
,
ErrorMessage
>
errorMessageList
,
Integer
rowNumber
,
ConcurrentHashMap
<
String
,
BigDecimal
>
pensionMoneyMap
,
ConcurrentHashMap
<
String
,
BigDecimal
>
birthMoneyMap
,
ConcurrentHashMap
<
String
,
BigDecimal
>
bigMoneyMap
,
ConcurrentHashMap
<
String
,
BigDecimal
>
unEmpMoneyMap
,
ConcurrentHashMap
<
String
,
BigDecimal
>
injuryMoneyMap
,
ConcurrentHashMap
<
String
,
BigDecimal
>
medicalMoneyMap
,
String
sumNumKey
,
String
importSuccessKey
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
batchGsInsertList
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
batchSyInsertList
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
batchYlInsertList
,
...
...
@@ -2409,31 +2411,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List
<
CompletableFuture
<
ConcurrentHashMap
<
String
,
ErrorMessage
>>>
completableFutureList
=
new
ArrayList
<>();
// 创建一个数值格式化对象
NumberFormat
numberFormat
=
NumberFormat
.
getInstance
();
// 设置精确到小数点后2位
numberFormat
.
setMaximumFractionDigits
(
2
);
String
maerialRatio
=
""
;
Integer
bfInt
=
(
Integer
)
redisUtil
.
get
(
sumNumKey
);
if
(
Common
.
isNotNull
(
bfInt
))
{
if
(
rowNumber
>
bfInt
+
1
)
{
maerialRatio
=
numberFormat
.
format
(((
float
)
bfInt
/
(
float
)
rowNumber
)
*
100
);
bfInt
=
bfInt
+
100
;
redisUtil
.
set
(
sumNumKey
,
bfInt
,
360L
);
}
else
{
maerialRatio
=
"100"
;
}
}
else
{
if
(
rowNumber
>=
100
)
{
maerialRatio
=
numberFormat
.
format
(((
float
)
100
/
(
float
)
rowNumber
)
*
100
);
bfInt
=
100
;
redisUtil
.
set
(
sumNumKey
,
bfInt
,
360L
);
}
else
{
maerialRatio
=
"100"
;
}
}
redisUtil
.
set
(
importSuccessKey
,
maerialRatio
,
360L
);
try
{
// 1.list.size()不足100时直接执行
if
(
list
.
size
()
<
100
)
{
...
...
@@ -2478,6 +2455,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
paymentInfoUnEmpMap
.
clear
();
paymentInfoPensionMap
.
clear
();
paymentInfoMedicalMap
.
clear
();
paymentInfoBirthMap
.
clear
();
}
catch
(
Exception
e
)
{
log
.
error
(
"社保缴费库数据批量导入异常:"
+
e
);
paymentInfoBigMap
.
clear
();
...
...
@@ -2485,6 +2463,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
paymentInfoUnEmpMap
.
clear
();
paymentInfoPensionMap
.
clear
();
paymentInfoMedicalMap
.
clear
();
paymentInfoBirthMap
.
clear
();
}
}
}
...
...
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