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
a26dec4d
Commit
a26dec4d
authored
May 04, 2025
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
huych-实缴推送优化
parent
095ac0af
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
230 additions
and
165 deletions
+230
-165
EkpSocialInfoServiceImpl.java
...ud/plus/v1/ekp/service/impl/EkpSocialInfoServiceImpl.java
+230
-165
No files found.
yifu-ekp/yifu-ekp-biz/src/main/java/com/yifu/cloud/plus/v1/ekp/service/impl/EkpSocialInfoServiceImpl.java
View file @
a26dec4d
...
@@ -10,6 +10,7 @@ import com.yifu.cloud.plus.v1.ekp.vo.EkpSocialPushInfoVo;
...
@@ -10,6 +10,7 @@ import com.yifu.cloud.plus.v1.ekp.vo.EkpSocialPushInfoVo;
import
com.yifu.cloud.plus.v1.ekp.vo.EkpSocialStatusUpdateVo
;
import
com.yifu.cloud.plus.v1.ekp.vo.EkpSocialStatusUpdateVo
;
import
com.yifu.cloud.plus.v1.ekp.vo.EkpSocialSumInfoVo
;
import
com.yifu.cloud.plus.v1.ekp.vo.EkpSocialSumInfoVo
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.redis.RedisDistributedLock
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.*
;
import
com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpPushSocialParam
;
import
com.yifu.cloud.plus.v1.yifu.ekp.vo.EkpPushSocialParam
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.TPaymentSocialPush
;
import
com.yifu.cloud.plus.v1.yifu.social.entity.TPaymentSocialPush
;
...
@@ -17,6 +18,7 @@ import lombok.extern.log4j.Log4j2;
...
@@ -17,6 +18,7 @@ import lombok.extern.log4j.Log4j2;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.text.ParseException
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
...
@@ -31,6 +33,9 @@ import java.util.stream.Collectors;
...
@@ -31,6 +33,9 @@ import java.util.stream.Collectors;
@Service
@Service
public
class
EkpSocialInfoServiceImpl
extends
ServiceImpl
<
EkpSocialInfoMapper
,
EkpSocialInfo
>
implements
EkpSocialInfoService
{
public
class
EkpSocialInfoServiceImpl
extends
ServiceImpl
<
EkpSocialInfoMapper
,
EkpSocialInfo
>
implements
EkpSocialInfoService
{
private
static
final
int
MAX_RETRY
=
3
;
// 最大重试次数
private
static
final
long
RETRY_DELAY_MS
=
200
;
// 重试间隔
/**
/**
//@Description: 社保明细推送至ekp
//@Description: 社保明细推送至ekp
//@Author: huyc
//@Author: huyc
...
@@ -39,25 +44,99 @@ public class EkpSocialInfoServiceImpl extends ServiceImpl<EkpSocialInfoMapper, E
...
@@ -39,25 +44,99 @@ public class EkpSocialInfoServiceImpl extends ServiceImpl<EkpSocialInfoMapper, E
**/
**/
public
EkpSocialPushInfoVo
pushSocialInfoToEkp
(
List
<
EkpPushSocialParam
>
unPushList
)
{
public
EkpSocialPushInfoVo
pushSocialInfoToEkp
(
List
<
EkpPushSocialParam
>
unPushList
)
{
//插入数据集合
List
<
EkpSocialInfo
>
socialInfoList
=
new
ArrayList
<>();
//社保推送记录表
//社保推送记录表
List
<
TPaymentSocialPush
>
socialPushList
=
new
ArrayList
<>();
List
<
TPaymentSocialPush
>
socialPushList
=
new
ArrayList
<>();
//社保id集合 用于更新社保状态
//社保id集合 用于更新社保状态
List
<
String
>
paymentIds
=
new
ArrayList
<>();
List
<
String
>
paymentIds
=
new
ArrayList
<>();
//获取ekp所有项目信息
//获取ekp所有项目信息
List
<
EkpDeptInfoVo
>
deptInfoVoList
=
baseMapper
.
getAllEkpDeptInfo
();
List
<
EkpDeptInfoVo
>
deptInfoVoList
=
baseMapper
.
getAllEkpDeptInfo
();
Map
<
String
,
EkpDeptInfoVo
>
map
=
new
HashMap
<>();
Map
<
String
,
EkpDeptInfoVo
>
map
=
new
HashMap
<>();
EkpDeptInfoVo
deptInfo
;
EkpSocialSumInfoVo
socialSumInfo
;
if
(
Optional
.
ofNullable
(
deptInfoVoList
).
isPresent
())
{
if
(
Optional
.
ofNullable
(
deptInfoVoList
).
isPresent
())
{
map
=
deptInfoVoList
.
stream
().
collect
(
Collectors
.
toMap
(
EkpDeptInfoVo:
:
getDeptNo
,
k
->
k
));
map
=
deptInfoVoList
.
stream
().
collect
(
Collectors
.
toMap
(
EkpDeptInfoVo:
:
getDeptNo
,
k
->
k
));
}
}
EkpSocialInfo
socialCount
;
try
{
try
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
StringBuilder
stringBuilder
=
new
StringBuilder
();
for
(
EkpPushSocialParam
socialParam
:
unPushList
)
{
if
(!
unPushList
.
isEmpty
())
{
Map
<
String
,
List
<
EkpPushSocialParam
>>
groups
=
unPushList
.
stream
()
.
collect
(
Collectors
.
groupingBy
(
a
->
a
.
getFd_3adfe8c7e4cf7a
()
+
"_"
+
a
.
getFd_3adfe8cb96c41e
()));
Map
<
String
,
EkpDeptInfoVo
>
finalMap
=
map
;
groups
.
forEach
((
key
,
group
)
->
{
String
[]
parts
=
key
.
split
(
"_"
);
String
idCard
=
parts
[
0
];
String
month
=
parts
[
1
];
String
lockKey
=
"B_LOCK:"
+
key
;
boolean
lockAcquired
=
false
;
int
retryCount
=
0
;
String
requestId
;
// 重试获取锁
while
(!
lockAcquired
&&
retryCount
<
MAX_RETRY
)
{
requestId
=
RedisDistributedLock
.
getLock
(
lockKey
,
"10"
);
if
(
null
!=
requestId
)
{
lockAcquired
=
true
;
try
{
processSingleGroup
(
idCard
,
month
,
group
,
finalMap
,
stringBuilder
,
socialPushList
,
paymentIds
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
finally
{
//主动释放锁
RedisDistributedLock
.
unlock
(
key
,
requestId
);
}
}
else
{
retryCount
++;
try
{
Thread
.
sleep
(
RETRY_DELAY_MS
);
// 间隔后重试
}
catch
(
InterruptedException
e
)
{
Thread
.
currentThread
().
interrupt
();
}
}
}
});
}
if
(!
socialPushList
.
isEmpty
())
{
//推送成功保存社保明细合并的数据对应关系
EkpSocialPushInfoVo
pushInfoVo
=
new
EkpSocialPushInfoVo
();
pushInfoVo
.
setUnPushInfo
(
socialPushList
);
pushInfoVo
.
setPaymentIds
(
paymentIds
);
pushInfoVo
.
setPaymentIdSum
(
stringBuilder
.
toString
());
return
pushInfoVo
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"社保明细推送失败"
,
e
);
return
null
;
}
return
null
;
}
private
void
processSingleGroup
(
String
idCard
,
String
month
,
List
<
EkpPushSocialParam
>
group
,
Map
<
String
,
EkpDeptInfoVo
>
map
,
StringBuilder
stringBuilder
,
List
<
TPaymentSocialPush
>
socialPushList
,
List
<
String
>
paymentIds
)
throws
ParseException
{
//插入数据集合
List
<
EkpSocialInfo
>
socialInfoList
=
new
ArrayList
<>();
EkpDeptInfoVo
deptInfo
;
EkpSocialInfo
socialCount
;
//获取社保订单明细合计
EkpSocialSumInfoVo
socialSumInfo
=
baseMapper
.
getCostSumInfo
(
idCard
,
month
);
//预估单位合计
BigDecimal
ygDwSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getYgDwSum
());
//实缴单位合计
BigDecimal
sjDwSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getSjDwSum
());
//实缴个人合计
BigDecimal
sjPersonSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getSjPersonSum
());
//预估合计
BigDecimal
ygSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getYgSum
());
//预估个人合计
BigDecimal
ygPersonSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getYgPersonSum
());
//实缴合计
BigDecimal
sjSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getSjSum
());
//应收
BigDecimal
ys
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getYs
());
//个人应收
BigDecimal
personYs
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getPersonYs
());
//单位应收
BigDecimal
dwYs
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getDwYs
());
for
(
EkpPushSocialParam
socialParam
:
group
)
{
//去重 防止重复推送
//去重 防止重复推送
socialCount
=
baseMapper
.
selectOne
(
Wrappers
.<
EkpSocialInfo
>
query
().
lambda
()
socialCount
=
baseMapper
.
selectOne
(
Wrappers
.<
EkpSocialInfo
>
query
().
lambda
()
.
eq
(
EkpSocialInfo:
:
getFd_3b0b716e771e06
,
socialParam
.
getFd_3b0afbe1f94a08
())
.
eq
(
EkpSocialInfo:
:
getFd_3b0b716e771e06
,
socialParam
.
getFd_3b0afbe1f94a08
())
...
@@ -93,27 +172,6 @@ public class EkpSocialInfoServiceImpl extends ServiceImpl<EkpSocialInfoMapper, E
...
@@ -93,27 +172,6 @@ public class EkpSocialInfoServiceImpl extends ServiceImpl<EkpSocialInfoMapper, E
}
}
//生成月份
//生成月份
socialInfo
.
setFd_3adfe8cb96c41e
(
dateStringInsert
(
socialInfo
.
getFd_3adfe8cb96c41e
()));
socialInfo
.
setFd_3adfe8cb96c41e
(
dateStringInsert
(
socialInfo
.
getFd_3adfe8cb96c41e
()));
//获取社保订单明细合计
socialSumInfo
=
baseMapper
.
getCostSumInfo
(
socialInfo
.
getFd_3adfe8c7e4cf7a
(),
socialInfo
.
getFd_3adfe8cb96c41e
());
//预估合计
BigDecimal
ygSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getYgSum
());
//预估个人合计
BigDecimal
ygPersonSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getYgPersonSum
());
//实缴合计
BigDecimal
sjSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getSjSum
());
//预估单位合计
BigDecimal
ygDwSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getYgDwSum
());
//实缴单位合计
BigDecimal
sjDwSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getSjDwSum
());
//实缴个人合计
BigDecimal
sjPersonSum
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getSjPersonSum
());
//应收
BigDecimal
ys
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getYs
());
//个人应收
BigDecimal
personYs
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getPersonYs
());
//单位应收
BigDecimal
dwYs
=
Common
.
isEmpty
(
socialSumInfo
)
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialSumInfo
.
getDwYs
());
//实缴单位合计
//实缴单位合计
BigDecimal
shdw
=
Common
.
isEmpty
(
socialInfo
.
getFd_3af9f2e9208e4e
())
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3af9f2e9208e4e
());
BigDecimal
shdw
=
Common
.
isEmpty
(
socialInfo
.
getFd_3af9f2e9208e4e
())
?
BigDecimal
.
ZERO
:
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3af9f2e9208e4e
());
//实缴个人合计
//实缴个人合计
...
@@ -206,6 +264,26 @@ public class EkpSocialInfoServiceImpl extends ServiceImpl<EkpSocialInfoMapper, E
...
@@ -206,6 +264,26 @@ public class EkpSocialInfoServiceImpl extends ServiceImpl<EkpSocialInfoMapper, E
//创建时间
//创建时间
socialInfo
.
setCreateTime
(
DateUtil
.
getCurrentDateTime
());
socialInfo
.
setCreateTime
(
DateUtil
.
getCurrentDateTime
());
socialInfoList
.
add
(
socialInfo
);
socialInfoList
.
add
(
socialInfo
);
//金额累加
//预估单位合计
ygDwSum
=
ygDwSum
.
add
(
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3adfeb4e8064a8
()));
//实缴单位合计
sjDwSum
=
sjDwSum
.
add
(
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3af9f2e9208e4e
()));
//实缴个人合计
sjPersonSum
=
sjPersonSum
.
add
(
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3af9f303037214
()));
//预估合计
ygSum
=
ygSum
.
add
(
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3af9f2883941b4
()));
//预估个人合计
ygPersonSum
=
ygPersonSum
.
add
(
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3af9f285ee1e38
()));
//实缴合计
sjSum
=
sjSum
.
add
(
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3af9f3059e5b9c
()));
//应收
ys
=
ys
.
add
(
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3adfeb7b624f06
()));
//个人应收
personYs
=
personYs
.
add
(
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3b35a57aee1428
()));
//单位应收
dwYs
=
dwYs
.
add
(
BigDecimal
.
valueOf
(
socialInfo
.
getFd_3b35a57b6e9d0a
()));
if
(
CommonConstants
.
ZERO_STRING
.
equals
(
socialParam
.
getYgFlag
()))
{
if
(
CommonConstants
.
ZERO_STRING
.
equals
(
socialParam
.
getYgFlag
()))
{
stringBuilder
.
append
(
socialParam
.
getSocialIds
()).
append
(
","
);
stringBuilder
.
append
(
socialParam
.
getSocialIds
()).
append
(
","
);
paymentIds
.
add
(
socialParam
.
getSocialIds
());
paymentIds
.
add
(
socialParam
.
getSocialIds
());
...
@@ -218,21 +296,8 @@ public class EkpSocialInfoServiceImpl extends ServiceImpl<EkpSocialInfoMapper, E
...
@@ -218,21 +296,8 @@ public class EkpSocialInfoServiceImpl extends ServiceImpl<EkpSocialInfoMapper, E
}
}
}
}
if
(!
socialInfoList
.
isEmpty
())
{
if
(!
socialInfoList
.
isEmpty
())
{
boolean
flag
=
this
.
saveBatch
(
socialInfoList
);
this
.
saveBatch
(
socialInfoList
);
if
(
flag
)
{
//推送成功保存社保明细合并的数据对应关系
EkpSocialPushInfoVo
pushInfoVo
=
new
EkpSocialPushInfoVo
();
pushInfoVo
.
setUnPushInfo
(
socialPushList
);
pushInfoVo
.
setPaymentIds
(
paymentIds
);
pushInfoVo
.
setPaymentIdSum
(
stringBuilder
.
toString
());
return
pushInfoVo
;
}
}
}
}
catch
(
Exception
e
)
{
log
.
error
(
"社保明细推送失败"
,
e
);
return
null
;
}
return
null
;
}
}
@Override
@Override
...
...
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