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
3aaf5093
Commit
3aaf5093
authored
Aug 02, 2022
by
huyuchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
缴费库 代码修改
parent
f9cd21b5
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
335 additions
and
681 deletions
+335
-681
LdapProperties.java
...cloud/plus/v1/yifu/common/ldap/config/LdapProperties.java
+25
-0
PersonVo.java
.../yifu/cloud/plus/v1/yifu/common/ldap/entity/PersonVo.java
+2
-2
LdapCheck.java
...m/yifu/cloud/plus/v1/yifu/common/ldap/util/LdapCheck.java
+0
-121
LdapUtil.java
...om/yifu/cloud/plus/v1/yifu/common/ldap/util/LdapUtil.java
+17
-20
spring.factories
...-common-ldap/src/main/resources/META-INF/spring.factories
+1
-1
ldapConfig.properties
...yifu-common-ldap/src/main/resources/ldapConfig.properties
+6
-0
TPaymentInfoServiceImpl.java
.../v1/yifu/social/service/impl/TPaymentInfoServiceImpl.java
+262
-531
SysDeptServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysDeptServiceImpl.java
+7
-4
SysUserServiceImpl.java
...d.plus.v1/yifu/admin/service/impl/SysUserServiceImpl.java
+6
-1
SysUserMapper.xml
...yifu-upms-biz/src/main/resources/mapper/SysUserMapper.xml
+9
-1
No files found.
yifu-common/yifu-common-ldap/src/main/java/com/yifu/cloud/plus/v1/yifu/common/ldap/config/LdapProperties.java
0 → 100644
View file @
3aaf5093
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
ldap
.
config
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.context.annotation.PropertySource
;
import
org.springframework.stereotype.Component
;
@Data
@Component
@PropertySource
(
"classpath:ldapConfig.properties"
)
@ConfigurationProperties
(
value
=
"ldap"
,
ignoreInvalidFields
=
false
)
public
class
LdapProperties
{
String
url
;
String
dn
;
String
password
;
Integer
port
;
String
userName
;
String
baseDn
;
}
yifu-common/yifu-common-ldap/src/main/java/com/yifu/cloud/plus/v1/yifu/common/ldap/entity/PersonVo.java
View file @
3aaf5093
...
...
@@ -56,13 +56,13 @@ public class PersonVo {
private
String
homeDirectory
;
/**
*
主键
*
部门名称
*/
@Attribute
(
name
=
"ou"
)
private
String
deptName
;
/**
*
主键
*
用户密码
*/
@Attribute
(
name
=
"userPassword"
)
private
String
password
;
...
...
yifu-common/yifu-common-ldap/src/main/java/com/yifu/cloud/plus/v1/yifu/common/ldap/util/LdapCheck.java
deleted
100644 → 0
View file @
f9cd21b5
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
ldap
.
util
;
import
javax.naming.AuthenticationException
;
import
javax.naming.Context
;
import
javax.naming.NamingEnumeration
;
import
javax.naming.NamingException
;
import
javax.naming.directory.SearchControls
;
import
javax.naming.directory.SearchResult
;
import
javax.naming.ldap.Control
;
import
javax.naming.ldap.InitialLdapContext
;
import
javax.naming.ldap.LdapContext
;
import
java.util.Hashtable
;
/**
* 用户登陆认证,LDAP跨域认证,通过LDAP对用户进行更新
*
*/
public
class
LdapCheck
{
private
static
LdapContext
ctx
=
null
;
private
static
Control
[]
connCtls
=
null
;
/**** 定义LDAP的基本连接信息 ******/
// LDAP的连接地址(ldap://ip:port/)port默认为389
private
static
String
URL
=
"192.168.1.65"
;
//port
private
static
String
port
=
"389"
;
// LDAP的根DN
private
static
String
BASEDN
=
"dc=worfu,dc=com"
;
// LDAP的连接账号(身份认证管理平台添加的应用账号,应用账号格式:uid=?,ou=?,dc=????)
private
static
String
PRINCIPAL
=
"cn=admin,dc=worfu,dc=com"
;
// LDAP的连接账号的密码(身份认证管理平台添加的应用账号的密码)
private
static
String
PASSWORD
=
"yifu123456!"
;
// 校验用户名密码的方法
public
static
boolean
authenticate
(
String
usr
,
String
pwd
)
{
boolean
valide
=
false
;
if
(
pwd
==
null
||
pwd
==
""
)
return
false
;
if
(
ctx
==
null
)
{
getCtx
();
}
String
userDN
=
getUserDN
(
usr
);
if
(
""
.
equals
(
userDN
)
||
userDN
==
null
)
{
return
false
;
}
try
{
ctx
.
addToEnvironment
(
Context
.
SECURITY_PRINCIPAL
,
userDN
);
ctx
.
addToEnvironment
(
Context
.
SECURITY_CREDENTIALS
,
pwd
);
ctx
.
reconnect
(
connCtls
);
valide
=
true
;
closeCtx
();
}
catch
(
AuthenticationException
e
)
{
System
.
out
.
println
(
userDN
+
" is not authenticated"
);
System
.
out
.
println
(
e
.
toString
());
valide
=
false
;
}
catch
(
NamingException
e
)
{
System
.
out
.
println
(
userDN
+
" is not authenticated"
);
valide
=
false
;
}
return
valide
;
}
public
static
void
getCtx
()
{
if
(
ctx
!=
null
)
{
return
;
}
Hashtable
<
String
,
String
>
env
=
new
Hashtable
<
String
,
String
>();
env
.
put
(
Context
.
INITIAL_CONTEXT_FACTORY
,
"com.sun.jndi.ldap.LdapCtxFactory"
);
env
.
put
(
Context
.
PROVIDER_URL
,
URL
+
":"
+
port
+
BASEDN
);
env
.
put
(
Context
.
SECURITY_AUTHENTICATION
,
"simple"
);
env
.
put
(
Context
.
SECURITY_PRINCIPAL
,
PRINCIPAL
);
env
.
put
(
Context
.
SECURITY_CREDENTIALS
,
PASSWORD
);
try
{
// 链接ldap
ctx
=
new
InitialLdapContext
(
env
,
connCtls
);
}
catch
(
AuthenticationException
e
)
{
System
.
out
.
println
(
"Authentication faild: "
+
e
.
toString
());
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Something wrong while authenticating: "
+
e
.
toString
());
}
}
public
static
void
closeCtx
()
{
try
{
if
(
ctx
!=
null
)
ctx
.
close
();
}
catch
(
NamingException
ex
)
{
}
}
public
static
String
getUserDN
(
String
uid
)
{
String
userDN
=
""
;
try
{
SearchControls
constraints
=
new
SearchControls
();
constraints
.
setSearchScope
(
SearchControls
.
SUBTREE_SCOPE
);
NamingEnumeration
<?>
en
=
ctx
.
search
(
""
,
"uid="
+
uid
,
constraints
);
if
(
en
==
null
)
{
System
.
out
.
println
(
"Have no NamingEnumeration."
);
}
if
(!
en
.
hasMoreElements
())
{
System
.
out
.
println
(
"Have no element."
);
}
while
(
en
!=
null
&&
en
.
hasMoreElements
())
{
Object
obj
=
en
.
nextElement
();
if
(
obj
instanceof
SearchResult
)
{
SearchResult
si
=
(
SearchResult
)
obj
;
userDN
+=
si
.
getName
();
userDN
+=
","
+
BASEDN
;
}
else
{
System
.
out
.
println
(
obj
);
}
System
.
out
.
println
();
}
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"Exception in search():"
+
e
);
}
return
userDN
;
}
}
\ No newline at end of file
yifu-common/yifu-common-ldap/src/main/java/com/yifu/cloud/plus/v1/yifu/common/ldap/util/LdapUtil.java
View file @
3aaf5093
...
...
@@ -2,10 +2,12 @@ package com.yifu.cloud.plus.v1.yifu.common.ldap.util;
import
com.unboundid.ldap.sdk.*
;
import
com.unboundid.ldap.sdk.controls.SubentriesRequestControl
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.config.LdapProperties
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.entity.PersonVo
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.mapper.PersonAttributesMapper
;
import
lombok.extern.log4j.Log4j2
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.context.properties.EnableConfigurationProperties
;
import
org.springframework.ldap.core.LdapTemplate
;
import
javax.naming.AuthenticationException
;
...
...
@@ -23,26 +25,19 @@ import java.util.List;
import
static
org
.
springframework
.
ldap
.
query
.
LdapQueryBuilder
.
query
;
@Log4j2
@EnableConfigurationProperties
(
LdapProperties
.
class
)
public
class
LdapUtil
{
@Autowired
private
LdapTemplate
ldapTemplate
;
@Autowired
private
LdapProperties
ldapProperties
;
private
static
LdapContext
ctx
=
null
;
private
static
Control
[]
connCtls
=
null
;
/**** 定义LDAP的基本连接信息 ******/
// LDAP的连接地址(ldap://ip:port/)port默认为389
private
static
String
URL
=
"ldap://192.168.1.65:389/"
;
// LDAP的根DN
private
static
String
BASEDN
=
"dc=worfu,dc=com"
;
// LDAP的连接账号(身份认证管理平台添加的应用账号,应用账号格式:uid=?,ou=?,dc=????)
private
static
String
PRINCIPAL
=
"cn=admin,dc=worfu,dc=com"
;
// LDAP的连接账号的密码(身份认证管理平台添加的应用账号的密码)
private
static
String
PASSWORD
=
"yifu123456!"
;
/**
* @return List<SearchResultEntry>
* @author huyc
...
...
@@ -52,8 +47,9 @@ public class LdapUtil {
public
List
<
SearchResultEntry
>
getAllPersonNamesWithTraditionalWay
()
{
List
<
SearchResultEntry
>
result
=
new
ArrayList
<
SearchResultEntry
>();
try
{
LDAPConnection
connection
=
new
LDAPConnection
(
"192.168.1.65"
,
389
,
"cn=admin,dc=worfu,dc=com"
,
"yifu123456!"
);
SearchRequest
searchRequest
=
new
SearchRequest
(
"ou=安徽皖信人力资源管理有限公司,ou=wanxin,dc=worfu,dc=com"
,
SearchScope
.
SUB
,
"(objectclass=*)"
);
LDAPConnection
connection
=
new
LDAPConnection
(
ldapProperties
.
getUrl
(),
ldapProperties
.
getPort
(),
ldapProperties
.
getUserName
(),
ldapProperties
.
getPassword
());
SearchRequest
searchRequest
=
new
SearchRequest
(
ldapProperties
.
getBaseDn
(),
SearchScope
.
SUB
,
"(objectclass=*)"
);
searchRequest
.
addControl
(
new
SubentriesRequestControl
());
SearchResult
searchResult
=
connection
.
search
(
searchRequest
);
for
(
SearchResultEntry
entry
:
searchResult
.
getSearchEntries
())
{
...
...
@@ -99,16 +95,17 @@ public class LdapUtil {
return
valide
;
}
public
static
void
getCtx
()
{
public
void
getCtx
()
{
if
(
ctx
!=
null
)
{
return
;
}
Hashtable
<
String
,
String
>
env
=
new
Hashtable
<
String
,
String
>();
env
.
put
(
Context
.
INITIAL_CONTEXT_FACTORY
,
"com.sun.jndi.ldap.LdapCtxFactory"
);
env
.
put
(
Context
.
PROVIDER_URL
,
URL
+
BASEDN
);
env
.
put
(
Context
.
PROVIDER_URL
,
"ldap://"
+
ldapProperties
.
getUrl
()
+
":"
+
ldapProperties
.
getPort
()
+
"/"
+
ldapProperties
.
getDn
());
env
.
put
(
Context
.
SECURITY_AUTHENTICATION
,
"simple"
);
env
.
put
(
Context
.
SECURITY_PRINCIPAL
,
PRINCIPAL
);
env
.
put
(
Context
.
SECURITY_CREDENTIALS
,
PASSWORD
);
env
.
put
(
Context
.
SECURITY_PRINCIPAL
,
ldapProperties
.
getUserName
()
);
env
.
put
(
Context
.
SECURITY_CREDENTIALS
,
ldapProperties
.
getPassword
()
);
try
{
// 链接ldap
ctx
=
new
InitialLdapContext
(
env
,
connCtls
);
...
...
@@ -117,12 +114,12 @@ public class LdapUtil {
}
}
public
static
void
closeCtx
()
throws
NamingException
{
public
void
closeCtx
()
throws
NamingException
{
if
(
ctx
!=
null
)
ctx
.
close
();
}
public
static
String
getUserDN
(
String
uid
)
{
public
String
getUserDN
(
String
uid
)
{
String
userDN
=
""
;
try
{
SearchControls
constraints
=
new
SearchControls
();
...
...
@@ -133,7 +130,7 @@ public class LdapUtil {
if
(
obj
instanceof
javax
.
naming
.
directory
.
SearchResult
)
{
javax
.
naming
.
directory
.
SearchResult
si
=
(
javax
.
naming
.
directory
.
SearchResult
)
obj
;
userDN
+=
si
.
getName
();
userDN
+=
","
+
BASEDN
;
userDN
+=
","
+
ldapProperties
.
getDn
()
;
}
}
}
catch
(
Exception
e
)
{
...
...
yifu-common/yifu-common-ldap/src/main/resources/META-INF/spring.factories
View file @
3aaf5093
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.ldap.
config.LdapAutoConfigue
\
com.yifu.cloud.plus.v1.yifu.common.ldap.
util.LdapUtil
\
yifu-common/yifu-common-ldap/src/main/resources/ldapConfig.properties
0 → 100644
View file @
3aaf5093
ldap.url
=
192.168.1.65
ldap.port
=
389
ldap.userName
=
cn=admin,dc=worfu,dc=com
ldap.password
=
yifu123456!
ldap.dn
=
dc=worfu,dc=com
ldap.baseDn
=
ou=
\u
5B89
\u
5FBD
\u7696\u
4FE1
\u
4EBA
\u
529B
\u
8D44
\u
6E90
\u
7BA1
\u7406\u6709\u9650\u
516C
\u
53F8,ou=wanxin,dc=worfu,dc=com
\ No newline at end of file
yifu-social/yifu-social-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/social/service/impl/TPaymentInfoServiceImpl.java
View file @
3aaf5093
...
...
@@ -30,7 +30,6 @@ import com.yifu.cloud.plus.v1.yifu.common.core.vo.YifuUser;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.ArchivesDaprUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.dapr.util.UpmsDaprUtils
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils
;
import
com.yifu.cloud.plus.v1.yifu.insurances.vo.Dept
;
import
com.yifu.cloud.plus.v1.yifu.social.concurrent.threadpool.YFSocialImportThreadPoolExecutor
;
import
com.yifu.cloud.plus.v1.yifu.social.constants.PaymentConstants
;
import
com.yifu.cloud.plus.v1.yifu.social.constants.SocialConstants
;
...
...
@@ -369,13 +368,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
else
{
redisUtil
.
set
(
key
,
user
.
getId
(),
1800L
);
Map
<
String
,
TPaymentInfoVo
>
listMap
=
new
HashMap
<>();
initListToMap
(
list
,
listMap
);
// 把初步校验的内容返回给前端
if
(
Common
.
isNotNull
(
errorMessageList
))
{
getIntegerErrorMessageHashMap
(
user
,
errorMessageList
,
key
,
random
,
listMap
);
}
// 导入前做队列空闲判断,防止队列不足出现数据丢失的场景
if
(
CollUtil
.
isNotEmpty
(
list
))
{
int
taskSize
=
list
.
size
()
/
partSize
+
CommonConstants
.
ONE_INT
;
...
...
@@ -383,7 +375,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if
(
taskSize
>
residualCapacity
)
{
errorMessageList
.
add
(
new
ErrorMessage
(-
1
,
MsgUtils
.
getMessage
(
ErrorCodes
.
SOCIALINFO_LIST_NUM_LARGE
)));
}
}
else
{
}
else
{
// -----------------------------生成paymentInfoMap本段开始--------------------------------
//已存在的档案数据
List
<
String
>
monthList
=
Common
.
listObjectToStrList
(
list
,
ExcelAttributeConstants
.
SOCIAL_PAY_MONTH
).
stream
().
distinct
().
collect
(
Collectors
.
toList
());
...
...
@@ -490,22 +482,14 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List
<
TPaymentInfoVo
>
tempList
=
new
ArrayList
<>();
AtomicInteger
atomicLine
=
new
AtomicInteger
(
CommonConstants
.
ZERO_INT
);
List
<
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>>
completableFutureList
=
new
ArrayList
<>();
try
{
// 1.list.size()不足partSize,直接执行
if
(
list
.
size
()
<
partSize
)
{
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>
listCompletableFuture
=
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialList
(
user
,
atomicLine
,
random
,
list
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoBigMap
,
paymentInfoBirMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
CommonConstants
.
ONE_INT
),
yfSocialImportThreadPoolExecutor
)
.
whenComplete
((
result
,
e
)
->
{
if
(
CollectionUtils
.
isNotEmpty
(
result
))
{
this
.
tPaymentInfoImportLogService
.
saveBatch
(
result
);
}
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList
.
add
(
listCompletableFuture
);
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialList
(
user
,
atomicLine
,
random
,
list
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoBigMap
,
paymentInfoBirMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
CommonConstants
.
ONE_INT
,
errorMessageList
),
yfSocialImportThreadPoolExecutor
);
}
// 2.list.size()大于partSize,循环分批执行
...
...
@@ -513,19 +497,12 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if
(
partSize
<=
list
.
size
())
{
// 处理第一个0位元素
final
List
<
TPaymentInfoVo
>
finalList
=
list
.
subList
(
0
,
1
);
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>
oneCompletableFuture
=
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialList
(
user
,
atomicLine
,
random
,
list
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoBigMap
,
paymentInfoBirMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
CommonConstants
.
ONE_INT
),
yfSocialImportThreadPoolExecutor
)
.
whenComplete
((
result
,
e
)
->
{
if
(
CollectionUtils
.
isNotEmpty
(
result
))
{
this
.
tPaymentInfoImportLogService
.
saveBatch
(
result
);
}
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialList
(
user
,
atomicLine
,
random
,
list
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoBigMap
,
paymentInfoBirMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
CommonConstants
.
ONE_INT
,
errorMessageList
),
yfSocialImportThreadPoolExecutor
);
lastIdx
=
1
;
completableFutureList
.
add
(
oneCompletableFuture
);
for
(
int
i
=
1
;
i
<
list
.
size
();
i
++)
{
// partSize数量的list为一个执行单元
tempList
.
add
(
list
.
get
(
i
));
...
...
@@ -533,19 +510,11 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
lastIdx
=
i
;
List
<
TPaymentInfoVo
>
finalTempList
=
tempList
;
final
int
idx
=
i
-
partSize
+
2
;
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>
listCompletableFuture
=
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialList
(
user
,
atomicLine
,
random
,
list
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoBigMap
,
paymentInfoBirMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
idx
),
yfSocialImportThreadPoolExecutor
)
.
whenComplete
((
result
,
e
)
->
{
if
(
CollectionUtils
.
isNotEmpty
(
result
))
{
this
.
tPaymentInfoImportLogService
.
saveBatch
(
result
);
}
//todo
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList
.
add
(
listCompletableFuture
);
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialList
(
user
,
atomicLine
,
random
,
list
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoBigMap
,
paymentInfoBirMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
idx
,
errorMessageList
),
yfSocialImportThreadPoolExecutor
);
tempList
=
new
ArrayList
<>();
}
}
...
...
@@ -567,40 +536,19 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
List
<
TPaymentInfoVo
>
finalTempList
=
tempList
;
int
finalLastIdx
=
lastIdx
+
1
;
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>
listCompletableFuture
=
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialList
(
user
,
atomicLine
,
random
,
list
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoBigMap
,
paymentInfoBirMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
finalLastIdx
),
yfSocialImportThreadPoolExecutor
)
.
whenComplete
((
result
,
e
)
->
{
if
(
CollectionUtils
.
isNotEmpty
(
result
))
{
this
.
tPaymentInfoImportLogService
.
saveBatch
(
result
);
}
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList
.
add
(
listCompletableFuture
);
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialList
(
user
,
atomicLine
,
random
,
list
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoBigMap
,
paymentInfoBirMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
finalLastIdx
,
errorMessageList
),
yfSocialImportThreadPoolExecutor
);
}
// 阻塞当前线程,等待所有的线程执行完毕
boolean
computeFlag
;
do
{
computeFlag
=
false
;
for
(
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>
listCompletableFuture
:
completableFutureList
)
{
if
(!
listCompletableFuture
.
isDone
())
{
computeFlag
=
true
;
}
}
}
while
(
computeFlag
);
String
importSuccessKey
=
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CommonConstants
.
PAYMENT_SOCIAL_WAIT_EXPORT
;
redisUtil
.
set
(
importSuccessKey
,
random
,
1800L
);
}
catch
(
Exception
e
)
{
log
.
error
(
"社保缴费库数据批量导入异常:"
+
e
);
redisUtil
.
remove
(
key
);
errorMessageList
.
add
(
new
ErrorMessage
(-
1
,
"数据批量导入异常:"
+
e
));
// errorMessageHashMap = ServiceUtil.initErrorMessage(
// errorMessageHashMap, new ErrorMessage(-1, "数据批量导入异常:" + e), remotePushService, pushParam);
}
finally
{
paymentInfoPensionMap
.
clear
();
paymentInfoBigMap
.
clear
();
...
...
@@ -612,37 +560,38 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// -----------------------------线程池处理list,批量保存社保信息结束--------------------------------
//最后一个推送
log
.
info
(
"社保批量导入耗时:{}"
,
(
System
.
currentTimeMillis
()
-
start
)
+
""
);
// pushParam.setTips(null == errorMessageHashMap.get(list.size()) ? "导入完成!" :
// errorMessageHashMap.get(list.size()).getMessage());
// ServiceUtil.initErrorMessage(list.size(), remotePushService, pushParam);
redisUtil
.
remove
(
key
);
}
}
}
private
void
initListToMap
(
List
<
TPaymentInfoVo
>
list
,
Map
<
String
,
TPaymentInfoVo
>
listMap
)
{
if
(
Common
.
isNotNull
(
list
))
{
for
(
TPaymentInfoVo
vo
:
list
)
{
listMap
.
put
(
String
.
valueOf
(
list
.
indexOf
(
vo
)
+
2
),
vo
);
}
}
}
private
void
getIntegerErrorMessageHashMap
(
YifuUser
user
,
List
<
ErrorMessage
>
errorInfo
,
String
key
,
String
random
,
Map
<
String
,
TPaymentInfoVo
>
listMap
)
{
List
<
TPaymentInfoImportLog
>
logList
=
new
ArrayList
<>();
TPaymentInfoVo
vo
=
null
;
for
(
ErrorMessage
error
:
errorInfo
)
{
vo
=
listMap
.
get
(
error
.
getLineNum
().
toString
());
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
null
==
vo
?
""
:
vo
.
getEmpName
(),
null
==
vo
?
""
:
vo
.
getEmpIdcard
(),
error
.
getMessage
(),
vo
.
getRowIndex
(),
random
));
/**
* 转换缴纳地址为省市县ID
**/
private
TPaymentInfoVo
initAddress
(
String
[]
areaArray
,
HashMap
<
String
,
String
>
areaMap2
,
TPaymentInfoVo
s
)
{
if
(
null
==
areaArray
||
null
==
areaMap2
||
null
==
s
)
{
return
s
;
}
if
(
Common
.
isNotNull
(
logList
))
{
this
.
tPaymentInfoImportLogService
.
saveBatch
(
logList
);
String
temp
=
null
;
if
(
areaArray
.
length
>=
CommonConstants
.
TWO_INT
)
{
temp
=
areaMap2
.
get
(
areaArray
[
0
]
+
CommonConstants
.
DOWN_LINE_STRING
+
"null"
);
if
(
Common
.
isNotNull
(
temp
))
{
s
.
setSocialProvince
(
temp
);
}
temp
=
areaMap2
.
get
(
areaArray
[
1
]
+
CommonConstants
.
DOWN_LINE_STRING
+
(
null
==
s
.
getSocialProvince
()
?
"null"
:
s
.
getSocialProvince
()));
if
(
Common
.
isNotNull
(
temp
))
{
s
.
setSocialCity
(
temp
);
}
if
(
areaArray
.
length
>=
CommonConstants
.
THREE_INT
)
{
temp
=
areaMap2
.
get
(
areaArray
[
2
]
+
CommonConstants
.
DOWN_LINE_STRING
+
(
null
==
s
.
getSocialCity
()
?
"null"
:
s
.
getSocialCity
()));
if
(
Common
.
isNotNull
(
temp
))
{
s
.
setSocialTown
(
temp
);
}
}
}
redisUtil
.
set
(
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CommonConstants
.
PAYMENT_SOCIAL_WAIT_EXPORT
,
random
,
1800L
);
redisUtil
.
remove
(
key
);
return
s
;
}
/**
...
...
@@ -656,23 +605,22 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
* @description:
* @author: huyc
* @date: 2022/7/25
* @return:
List<TPaymentInfoImportLog>
* @return:
*/
private
List
<
TPaymentInfoImportLog
>
executeImportSocialList
(
YifuUser
user
,
AtomicInteger
atomicLine
,
String
random
,
List
<
TPaymentInfoVo
>
list
,
HashMap
<
String
,
String
>
areaMap
,
HashMap
<
String
,
String
>
areaMap2
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoPensionMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoBigMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoBirMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoMedicalMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoUnEmpMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoInjuryMap
,
int
idx
)
{
private
List
<
ErrorMessage
>
executeImportSocialList
(
YifuUser
user
,
AtomicInteger
atomicLine
,
String
random
,
List
<
TPaymentInfoVo
>
list
,
HashMap
<
String
,
String
>
areaMap
,
HashMap
<
String
,
String
>
areaMap2
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoPensionMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoBigMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoBirMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoMedicalMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoUnEmpMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoInjuryMap
,
int
idx
,
List
<
ErrorMessage
>
errorMessageList
)
{
int
i
=
idx
;
List
<
TPaymentInfoImportLog
>
logList
=
new
ArrayList
<>();
if
(
Common
.
isNotNull
(
list
))
{
TPaymentInfo
paymentInfo
=
null
;
TSocialInfo
socialInfo
=
null
;
...
...
@@ -741,18 +689,15 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
//导入校验
if
(!
Common
.
isNotNull
(
infoVo
.
getSocialPayMonth
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"社保缴纳月份不可为空!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"社保缴纳月份不可为空!"
));
continue
;
}
if
(!
Common
.
isNotNull
(
infoVo
.
getSocialCreateMonth
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"社保生成月份不可为空!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"社保生成月份不可为空!"
));
continue
;
}
if
(!
Common
.
isNotNull
(
infoVo
.
getSocialPayAddr
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"社保缴纳地不可为空!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"社保缴纳地不可为空!"
));
continue
;
}
//无对应员工的社保数据
...
...
@@ -769,13 +714,11 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
//对身份证与人员姓名的对应关系进行校验
if
(
socialInfo
!=
null
&&
!
socialInfo
.
getEmpName
().
equals
(
infoVo
.
getEmpName
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"姓名与身份证信息不一致,请核实后再次尝试!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"姓名与身份证信息不一致,请核实后再次尝试!"
));
continue
;
}
if
(
socialInfo
!=
null
&&
socialInfo
.
getSocialStartDate
()
==
null
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
infoVo
.
getEmpIdcard
()
+
"的社保起缴日期为空!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
infoVo
.
getEmpIdcard
()
+
"的社保起缴日期为空!"
));
continue
;
}
if
(
null
==
socialInfo
||
(
null
!=
socialInfo
&&
!
ServiceUtil
.
checkMothForPaymentImport
(
...
...
@@ -788,8 +731,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
?
"null"
:
infoVo
.
getSocialTown
()));
//对身份证与人员姓名的对应关系进行校验
if
(
socialInfo
!=
null
&&
!
socialInfo
.
getEmpName
().
equals
(
infoVo
.
getEmpName
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"姓名与身份证信息不一致,请核实后再次尝试!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
infoVo
.
getEmpIdcard
()
+
"姓名与身份证信息不一致,请核实后再次尝试!"
));
continue
;
}
if
(
null
!=
socialInfo
&&
!
ServiceUtil
.
checkMothForPaymentImport
(
socialInfo
.
getSocialStartDate
()
...
...
@@ -809,23 +752,20 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
}
if
(
null
==
socialInfo
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"无对应员工"
+
infoVo
.
getEmpIdcard
()
+
"的社保数据(请查验社保办理状态|缴纳地|起缴月份|停缴月份)"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
infoVo
.
getEmpIdcard
()
+
"无对应员工"
+
infoVo
.
getEmpIdcard
()
+
"的社保数据(请查验社保办理状态|缴纳地|起缴月份|停缴月份)"
));
continue
;
}
//如果导入项目数大于办理成功项目数给提示,少于给进,有问题自行删除后导入
checkRes
=
checkRepeatInfo
(
socialInfo
,
infoVo
);
if
(
null
!=
checkRes
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
checkRes
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
checkRes
));
continue
;
}
//查看缴纳月是否为空
if
(!
Common
.
isNotNull
(
infoVo
.
getSocialPayMonth
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"必填项校验失败:社保缴纳月份不可为空!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"必填项校验失败:社保缴纳月份不可为空!"
));
continue
;
}
...
...
@@ -848,9 +788,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getPersonalPensionMoney
())),
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
paymentInfo
.
getUnitPensionMoney
()),
BigDecimalUtils
.
isNullToZero
(
paymentInfo
.
getPersonalPensionMoney
()))).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的养老缴费数据,请勿重复导入!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的养老缴费数据,请勿重复导入!"
));
continue
;
}
else
{
paymentInfo
=
null
;
...
...
@@ -875,9 +814,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getPersonalUnemploymentMoney
())),
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
paymentInfo
.
getUnitUnemploymentMoney
()),
BigDecimalUtils
.
isNullToZero
(
paymentInfo
.
getPersonalUnemploymentMoney
()))).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的失业缴费数据,请勿重复导入!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的失业缴费数据,请勿重复导入!"
));
continue
;
}
else
{
paymentInfo
=
null
;
...
...
@@ -902,9 +840,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getPersonalMedicalMoney
())),
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
paymentInfo
.
getUnitMedicalMoney
()),
BigDecimalUtils
.
isNullToZero
(
paymentInfo
.
getPersonalMedicalMoney
()))).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的医保缴费数据,请勿重复导入!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的医保缴费数据,请勿重复导入!"
));
continue
;
}
else
{
paymentInfo
=
null
;
...
...
@@ -929,9 +866,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getPersonalBigmailmentMoney
())),
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
paymentInfo
.
getUnitBigmailmentMoney
()),
BigDecimalUtils
.
isNullToZero
(
paymentInfo
.
getPersonalBigmailmentMoney
()))).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的医疗救助金缴费数据,请勿重复导入!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的医疗救助金缴费数据,请勿重复导入!"
));
continue
;
}
else
{
paymentInfo
=
null
;
...
...
@@ -952,9 +888,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
//存在社保缴费数据
if
(
null
!=
paymentInfo
&&
BigDecimalUtils
.
safeMultiply
(
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getUnitInjuryMoney
()),
BigDecimalUtils
.
isNullToZero
(
paymentInfo
.
getUnitInjuryMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的单位工伤缴费数据,请勿重复导入!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的单位工伤缴费数据,请勿重复导入!"
));
continue
;
}
else
{
paymentInfo
=
null
;
...
...
@@ -975,9 +910,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
//存在社保缴费数据
if
(
null
!=
paymentInfo
&&
BigDecimalUtils
.
safeMultiply
(
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getUnitBirthMoney
()),
BigDecimalUtils
.
isNullToZero
(
paymentInfo
.
getUnitBirthMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的单位生育缴费数据,请勿重复导入!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的单位生育缴费数据,请勿重复导入!"
));
continue
;
}
else
{
paymentInfo
=
null
;
...
...
@@ -1080,60 +1014,21 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if
(
null
!=
paymentInfo
&&
Common
.
isNotNull
(
paymentInfo
.
getId
()))
{
res
=
baseMapper
.
updateById
(
paymentInfo
);
if
(
res
<
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
infoVo
.
getEmpName
()
+
"_缴费库更新失败!"
,
i
,
random
));
continue
;
}
else
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
infoVo
.
getEmpName
()
+
"_缴费库更新成功!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
infoVo
.
getEmpName
()
+
"_缴费库更新失败!"
));
continue
;
}
}
else
{
res
=
insertAndSTimestamp
(
paymentInfo
);
if
(
res
<
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
infoVo
.
getEmpName
()
+
"_缴费库保存失败!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
infoVo
.
getEmpName
()
+
"_缴费库保存失败!"
));
continue
;
}
}
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
SUCCESS_MSG_PREFIX
+
"保存成功!"
,
i
,
random
));
}
itemMap
.
clear
();
cusMap
.
clear
();
}
else
{
return
null
;
}
return
logList
;
}
/**
* 转换缴纳地址为省市县ID
**/
private
TPaymentInfoVo
initAddress
(
String
[]
areaArray
,
HashMap
<
String
,
String
>
areaMap2
,
TPaymentInfoVo
s
)
{
if
(
null
==
areaArray
||
null
==
areaMap2
||
null
==
s
)
{
return
s
;
}
String
temp
=
null
;
if
(
areaArray
.
length
>=
CommonConstants
.
TWO_INT
)
{
temp
=
areaMap2
.
get
(
areaArray
[
0
]
+
CommonConstants
.
DOWN_LINE_STRING
+
"null"
);
if
(
Common
.
isNotNull
(
temp
))
{
s
.
setSocialProvince
(
temp
);
}
temp
=
areaMap2
.
get
(
areaArray
[
1
]
+
CommonConstants
.
DOWN_LINE_STRING
+
(
null
==
s
.
getSocialProvince
()
?
"null"
:
s
.
getSocialProvince
()));
if
(
Common
.
isNotNull
(
temp
))
{
s
.
setSocialCity
(
temp
);
}
if
(
areaArray
.
length
>=
CommonConstants
.
THREE_INT
)
{
temp
=
areaMap2
.
get
(
areaArray
[
2
]
+
CommonConstants
.
DOWN_LINE_STRING
+
(
null
==
s
.
getSocialCity
()
?
"null"
:
s
.
getSocialCity
()));
if
(
Common
.
isNotNull
(
temp
))
{
s
.
setSocialTown
(
temp
);
}
}
}
return
s
;
return
errorMessageList
;
}
//比对缴纳地是否一致
...
...
@@ -1245,7 +1140,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
YifuUser
user
=
SecurityUtils
.
getUser
();
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
TPaymentHeFeiVo
>
util1
=
new
ExcelUtil
<>(
TPaymentHeFeiVo
.
class
);
;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
...
...
@@ -1304,7 +1198,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
YifuUser
user
=
SecurityUtils
.
getUser
();
List
<
ErrorMessage
>
errorMessageList
=
new
ArrayList
<>();
ExcelUtil
<
TPaymentInfoVo
>
util1
=
new
ExcelUtil
<>(
TPaymentInfoVo
.
class
);
;
// 写法2:
// 匿名内部类 不用额外写一个DemoDataListener
// 这里 需要指定读用哪个class去读,然后读取第一个sheet 文件流会自动关闭
...
...
@@ -1646,7 +1539,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
private
void
importTPaymentSocialHeFei
(
List
<
TPaymentHeFeiVo
>
list
,
List
<
ErrorMessage
>
errorMessageList
,
String
random
,
YifuUser
user
,
String
type
)
{
long
start
=
System
.
currentTimeMillis
();
HashMap
<
String
,
String
>
areaMap
=
new
HashMap
<
String
,
String
>();
HashMap
<
String
,
String
>
areaMap2
=
new
HashMap
<
String
,
String
>();
...
...
@@ -1666,13 +1558,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
// 判断是否有相同的用户在导入社保费用 存在提示稍后重试
String
key
=
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CommonConstants
.
PAYMENT_SOCIAL_IMPORT
;
Map
<
String
,
TPaymentHeFeiVo
>
listMap
=
new
HashMap
<>();
initListToMapThree
(
list
,
listMap
);
// 把初步校验的内容返回给前端
if
(
Common
.
isNotNull
(
errorMessageList
))
{
getErrorMessageHashMapThree
(
user
,
random
,
errorMessageList
,
key
,
listMap
);
}
// 将以下代码提取出来,使用paymentInfoMap提升性能,避免list多次循环查询数据库浪费性能
// 导入前做队列空闲判断,防止队列不足出现数据丢失的场景
if
(
CollUtil
.
isNotEmpty
(
list
))
{
...
...
@@ -1680,248 +1565,177 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
int
residualCapacity
=
yfSocialImportThreadPoolExecutor
.
getResidualCapacity
();
if
(
taskSize
>
residualCapacity
)
{
errorMessageList
.
add
(
new
ErrorMessage
(-
1
,
MsgUtils
.
getMessage
(
ErrorCodes
.
SOCIALINFO_LIST_NUM_LARGE
)));
}
}
}
else
{
// -----------------------------生成paymentInfoMap本段开始--------------------------------
//已存在的档案数据
List
<
String
>
monthList
=
Common
.
listObjectToStrList
(
list
,
ExcelAttributeConstants
.
SOCIAL_PAY_MONTH
).
stream
().
distinct
().
collect
(
Collectors
.
toList
());
//已存在社保缴费库数据 非删除状态
List
<
TPaymentInfo
>
paymentInfos
=
baseMapper
.
selectListForPaymentImport
(
monthList
,
Common
.
listObjectToStrList
(
list
,
ExcelAttributeConstants
.
EMPIDCARD
));
//养老
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoPensionMap
=
new
ConcurrentHashMap
<>();
//大病救助金
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoBigMap
=
new
ConcurrentHashMap
<>();
//失业
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoUnEmpMap
=
new
ConcurrentHashMap
<>();
//工伤
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoInjuryMap
=
new
ConcurrentHashMap
<>();
//医保
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoMedicalMap
=
new
ConcurrentHashMap
<>();
if
(
Common
.
isNotNull
(
paymentInfos
))
{
for
(
TPaymentInfo
info
:
paymentInfos
)
{
// -----------------------------生成paymentInfoMap本段开始--------------------------------
//已存在的档案数据
List
<
String
>
monthList
=
Common
.
listObjectToStrList
(
list
,
ExcelAttributeConstants
.
SOCIAL_PAY_MONTH
).
stream
().
distinct
().
collect
(
Collectors
.
toList
());
//已存在社保缴费库数据 非删除状态
List
<
TPaymentInfo
>
paymentInfos
=
baseMapper
.
selectListForPaymentImport
(
monthList
,
Common
.
listObjectToStrList
(
list
,
ExcelAttributeConstants
.
EMPIDCARD
));
//养老
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoPensionMap
=
new
ConcurrentHashMap
<>();
//大病救助金
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoBigMap
=
new
ConcurrentHashMap
<>();
//失业
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoUnEmpMap
=
new
ConcurrentHashMap
<>();
//工伤
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoInjuryMap
=
new
ConcurrentHashMap
<>();
//医保
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoMedicalMap
=
new
ConcurrentHashMap
<>();
if
(
Common
.
isNotNull
(
paymentInfos
))
{
for
(
TPaymentInfo
info
:
paymentInfos
)
{
if
(
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
info
.
getUnitPensionMoney
()),
BigDecimalUtils
.
isNullToZero
(
info
.
getPersonalPensionMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
paymentInfoPensionMap
.
put
(
info
.
getSocialPayAddr
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getEmpIdcard
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialPayMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialCreateMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
PaymentConstants
.
PENSION_RISK
,
info
);
}
if
(
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
info
.
getUnitUnemploymentMoney
()),
BigDecimalUtils
.
isNullToZero
(
info
.
getPersonalUnemploymentMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
paymentInfoUnEmpMap
.
put
(
info
.
getSocialPayAddr
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getEmpIdcard
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialPayMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialCreateMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
PaymentConstants
.
UNEMPLOYEEMENT_RISK
,
info
);
}
if
(
BigDecimalUtils
.
isNullToZero
(
info
.
getUnitInjuryMoney
()).
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
paymentInfoInjuryMap
.
put
(
info
.
getSocialPayAddr
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getEmpIdcard
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialPayMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialCreateMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
PaymentConstants
.
INJURY_RISK
,
info
);
}
if
(
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
info
.
getUnitMedicalMoney
()),
BigDecimalUtils
.
isNullToZero
(
info
.
getPersonalMedicalMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
paymentInfoMedicalMap
.
put
(
info
.
getSocialPayAddr
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getEmpIdcard
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialPayMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialCreateMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
PaymentConstants
.
MEDICAL
,
info
);
if
(
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
info
.
getUnitPensionMoney
()),
BigDecimalUtils
.
isNullToZero
(
info
.
getPersonalPensionMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
paymentInfoPensionMap
.
put
(
info
.
getSocialPayAddr
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getEmpIdcard
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialPayMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialCreateMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
PaymentConstants
.
PENSION_RISK
,
info
);
}
if
(
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
info
.
getUnitUnemploymentMoney
()),
BigDecimalUtils
.
isNullToZero
(
info
.
getPersonalUnemploymentMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
paymentInfoUnEmpMap
.
put
(
info
.
getSocialPayAddr
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getEmpIdcard
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialPayMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialCreateMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
PaymentConstants
.
UNEMPLOYEEMENT_RISK
,
info
);
}
if
(
BigDecimalUtils
.
isNullToZero
(
info
.
getUnitInjuryMoney
()).
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
paymentInfoInjuryMap
.
put
(
info
.
getSocialPayAddr
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getEmpIdcard
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialPayMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialCreateMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
PaymentConstants
.
INJURY_RISK
,
info
);
}
if
(
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
info
.
getUnitMedicalMoney
()),
BigDecimalUtils
.
isNullToZero
(
info
.
getPersonalMedicalMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
!=
0
)
{
paymentInfoMedicalMap
.
put
(
info
.
getSocialPayAddr
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getEmpIdcard
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialPayMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
info
.
getSocialCreateMonth
()
+
CommonConstants
.
DOWN_LINE_STRING
+
PaymentConstants
.
MEDICAL
,
info
);
}
}
}
}
}
// -----------------------------生成paymentInfoMap本段结束--------------------------------
// -----------------------------生成paymentInfoMap本段结束--------------------------------
/**
* 修改批量导入社保为线程池的方式。逻辑分析,根据前端传入的list,将list分成每份partSize个。
* 有以下3种情况。1.list数量不足partSize,直接进行处理;2.list数量正好可以根据partSize等分,循环处理;3.不能等分有剩余的情况
*/
/**
* 修改批量导入社保为线程池的方式。逻辑分析,根据前端传入的list,将list分成每份partSize个。
* 有以下3种情况。1.list数量不足partSize,直接进行处理;2.list数量正好可以根据partSize等分,循环处理;3.不能等分有剩余的情况
*/
// -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List
<
TPaymentHeFeiVo
>
tempList
=
new
ArrayList
<>();
AtomicInteger
atomicLine
=
new
AtomicInteger
(
CommonConstants
.
ZERO_INT
);
List
<
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>>
completableFutureList
=
new
ArrayList
<>();
try
{
// 1.list.size()不足partSize,直接执行
if
(
list
.
size
()
<
partSize
)
{
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>
listCompletableFuture
=
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialListThree
(
user
,
atomicLine
,
random
,
list
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
CommonConstants
.
ONE_INT
,
type
),
yfSocialImportThreadPoolExecutor
)
.
whenComplete
((
result
,
e
)
->
{
if
(
CollectionUtils
.
isNotEmpty
(
result
))
{
this
.
tPaymentInfoImportLogService
.
saveBatch
(
result
);
}
//todo
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList
.
add
(
listCompletableFuture
);
}
// -----------------------------线程池处理list,批量保存社保信息开始--------------------------------
List
<
TPaymentHeFeiVo
>
tempList
=
new
ArrayList
<>();
AtomicInteger
atomicLine
=
new
AtomicInteger
(
CommonConstants
.
ZERO_INT
);
try
{
// 1.list.size()不足partSize,直接执行
if
(
list
.
size
()
<
partSize
)
{
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialListThree
(
user
,
atomicLine
,
random
,
list
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
CommonConstants
.
ONE_INT
,
type
,
errorMessageList
),
yfSocialImportThreadPoolExecutor
);
}
// 2.list.size()大于partSize,循环分批执行
int
lastIdx
=
0
;
if
(
partSize
<=
list
.
size
())
{
// 处理第一个0位元素
final
List
<
TPaymentHeFeiVo
>
finalList
=
list
.
subList
(
0
,
1
);
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>
oneCompletableFuture
=
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialListThree
(
user
,
atomicLine
,
random
,
finalList
,
areaMap
,
areaMap2
,
// 2.list.size()大于partSize,循环分批执行
int
lastIdx
=
0
;
if
(
partSize
<=
list
.
size
())
{
// 处理第一个0位元素
final
List
<
TPaymentHeFeiVo
>
finalList
=
list
.
subList
(
0
,
1
);
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialListThree
(
user
,
atomicLine
,
random
,
finalList
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
CommonConstants
.
ONE_INT
,
type
),
yfSocialImportThreadPoolExecutor
)
.
whenComplete
((
result
,
e
)
->
{
if
(
CollectionUtils
.
isNotEmpty
(
result
))
{
this
.
tPaymentInfoImportLogService
.
saveBatch
(
result
);
}
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
lastIdx
=
1
;
completableFutureList
.
add
(
oneCompletableFuture
);
for
(
int
i
=
1
;
i
<
list
.
size
();
i
++)
{
// partSize数量的list为一个执行单元
tempList
.
add
(
list
.
get
(
i
));
if
(
i
%
partSize
==
0
)
{
lastIdx
=
i
;
final
int
idx
=
i
-
partSize
+
2
;
List
<
TPaymentHeFeiVo
>
finalTempList1
=
tempList
;
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>
listCompletableFuture
=
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialListThree
(
user
,
atomicLine
,
random
,
finalTempList1
,
areaMap
,
paymentInfoInjuryMap
,
CommonConstants
.
ONE_INT
,
type
,
errorMessageList
)
,
yfSocialImportThreadPoolExecutor
);
lastIdx
=
1
;
for
(
int
i
=
1
;
i
<
list
.
size
();
i
++)
{
// partSize数量的list为一个执行单元
tempList
.
add
(
list
.
get
(
i
));
if
(
i
%
partSize
==
0
)
{
lastIdx
=
i
;
final
int
idx
=
i
-
partSize
+
2
;
List
<
TPaymentHeFeiVo
>
finalTempList1
=
tempList
;
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialListThree
(
user
,
atomicLine
,
random
,
finalTempList1
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
idx
,
type
),
yfSocialImportThreadPoolExecutor
)
.
whenComplete
((
result
,
e
)
->
{
if
(
CollectionUtils
.
isNotEmpty
(
result
))
{
this
.
tPaymentInfoImportLogService
.
saveBatch
(
result
);
}
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList
.
add
(
listCompletableFuture
);
tempList
=
new
ArrayList
<>();
}
}
}
// 3.第2种方式执行完后,有余数的情况下,执行3
if
(
lastIdx
!=
0
)
{
tempList
=
new
ArrayList
<>();
if
(
lastIdx
==
1
)
{
for
(
int
i
=
lastIdx
;
i
<
list
.
size
();
i
++)
{
tempList
.
add
(
list
.
get
(
i
));
}
}
else
{
for
(
int
i
=
lastIdx
+
1
;
i
<
list
.
size
();
i
++)
{
tempList
.
add
(
list
.
get
(
i
));
paymentInfoInjuryMap
,
idx
,
type
,
errorMessageList
)
,
yfSocialImportThreadPoolExecutor
);
tempList
=
new
ArrayList
<>();
}
}
}
lastIdx
+=
1
;
}
List
<
TPaymentHeFeiVo
>
finalTempList
=
tempList
;
int
finalLastIdx
=
lastIdx
+
1
;
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>
listCompletableFuture
=
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialListThree
(
user
,
atomicLine
,
random
,
finalTempList
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
finalLastIdx
,
type
),
yfSocialImportThreadPoolExecutor
)
.
whenComplete
((
result
,
e
)
->
{
if
(
CollectionUtils
.
isNotEmpty
(
result
))
{
this
.
tPaymentInfoImportLogService
.
saveBatch
(
result
);
// 3.第2种方式执行完后,有余数的情况下,执行3
if
(
lastIdx
!=
0
)
{
tempList
=
new
ArrayList
<>();
if
(
lastIdx
==
1
)
{
for
(
int
i
=
lastIdx
;
i
<
list
.
size
();
i
++)
{
tempList
.
add
(
list
.
get
(
i
));
}
// ServiceUtil.initErrorMessage(atomicLine.get(), remotePushService, pushParam);
});
completableFutureList
.
add
(
listCompletableFuture
);
}
}
else
{
for
(
int
i
=
lastIdx
+
1
;
i
<
list
.
size
();
i
++)
{
tempList
.
add
(
list
.
get
(
i
));
}
lastIdx
+=
1
;
}
// 阻塞当前线程,等待所有的线程执行完毕
boolean
computeFlag
;
do
{
computeFlag
=
false
;
for
(
CompletableFuture
<
List
<
TPaymentInfoImportLog
>>
listCompletableFuture
:
completableFutureList
)
{
if
(!
listCompletableFuture
.
isDone
())
{
computeFlag
=
true
;
List
<
TPaymentHeFeiVo
>
finalTempList
=
tempList
;
int
finalLastIdx
=
lastIdx
+
1
;
CompletableFuture
.
supplyAsync
(()
->
executeImportSocialListThree
(
user
,
atomicLine
,
random
,
finalTempList
,
areaMap
,
areaMap2
,
paymentInfoPensionMap
,
paymentInfoMedicalMap
,
paymentInfoUnEmpMap
,
paymentInfoInjuryMap
,
finalLastIdx
,
type
,
errorMessageList
)
,
yfSocialImportThreadPoolExecutor
)
;
}
}
}
while
(
computeFlag
);
String
importSuccessKey
=
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CommonConstants
.
PAYMENT_SOCIAL_WAIT_EXPORT
;
redisUtil
.
set
(
importSuccessKey
,
random
,
1800L
);
}
catch
(
Exception
e
)
{
log
.
error
(
"社保缴费库数据批量导入异常:"
+
e
);
redisUtil
.
remove
(
key
);
errorMessageList
.
add
(
new
ErrorMessage
(-
1
,
"数据批量导入异常:"
+
e
));
}
finally
{
paymentInfoPensionMap
.
clear
();
paymentInfoBigMap
.
clear
();
paymentInfoMedicalMap
.
clear
();
paymentInfoUnEmpMap
.
clear
();
paymentInfoInjuryMap
.
clear
();
}
}
String
importSuccessKey
=
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CommonConstants
.
PAYMENT_SOCIAL_WAIT_EXPORT
;
redisUtil
.
set
(
importSuccessKey
,
random
,
1800L
);
private
void
initListToMapThree
(
List
<
TPaymentHeFeiVo
>
list
,
Map
<
String
,
TPaymentHeFeiVo
>
listMap
)
{
if
(
Common
.
isNotNull
(
list
))
{
for
(
TPaymentHeFeiVo
vo
:
list
)
{
listMap
.
put
(
String
.
valueOf
(
list
.
indexOf
(
vo
)
+
2
),
vo
);
}
catch
(
Exception
e
)
{
log
.
error
(
"社保缴费库数据批量导入异常:"
+
e
);
redisUtil
.
remove
(
key
);
}
finally
{
paymentInfoPensionMap
.
clear
();
paymentInfoBigMap
.
clear
();
paymentInfoMedicalMap
.
clear
();
paymentInfoUnEmpMap
.
clear
();
paymentInfoInjuryMap
.
clear
();
}
}
}
}
/*
* 保存初步校验
* */
private
void
getErrorMessageHashMapThree
(
YifuUser
user
,
String
random
,
List
<
ErrorMessage
>
errorInfo
,
String
key
,
Map
<
String
,
TPaymentHeFeiVo
>
listMap
)
{
List
<
TPaymentInfoImportLog
>
logList
=
new
ArrayList
<>();
TPaymentHeFeiVo
vo
=
null
;
for
(
ErrorMessage
error
:
errorInfo
)
{
vo
=
listMap
.
get
(
error
.
getLineNum
().
toString
());
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
null
==
vo
?
""
:
vo
.
getEmpName
(),
null
==
vo
?
""
:
vo
.
getEmpIdcard
(),
error
.
getMessage
(),
vo
.
getRowIndex
(),
random
));
}
if
(
Common
.
isNotNull
(
logList
))
{
this
.
tPaymentInfoImportLogService
.
saveBatch
(
logList
);
}
redisUtil
.
set
(
user
.
getId
()
+
CommonConstants
.
DOWN_LINE_STRING
+
CommonConstants
.
PAYMENT_SOCIAL_WAIT_EXPORT
,
random
,
1800L
);
redisUtil
.
remove
(
key
);
}
private
List
<
TPaymentInfoImportLog
>
executeImportSocialListThree
(
YifuUser
user
,
AtomicInteger
atomicLine
,
String
random
,
List
<
TPaymentHeFeiVo
>
list
,
HashMap
<
String
,
String
>
areaMap
,
HashMap
<
String
,
String
>
areaMap2
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoPensionMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoMedicalMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoUnEmpMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoInjuryMap
,
int
idx
,
String
type
)
{
private
List
<
ErrorMessage
>
executeImportSocialListThree
(
YifuUser
user
,
AtomicInteger
atomicLine
,
String
random
,
List
<
TPaymentHeFeiVo
>
list
,
HashMap
<
String
,
String
>
areaMap
,
HashMap
<
String
,
String
>
areaMap2
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoPensionMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoMedicalMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoUnEmpMap
,
ConcurrentHashMap
<
String
,
TPaymentInfo
>
paymentInfoInjuryMap
,
int
idx
,
String
type
,
List
<
ErrorMessage
>
errorMessageList
)
{
int
i
=
idx
;
List
<
TPaymentInfoImportLog
>
logList
=
new
ArrayList
<>();
if
(
Common
.
isNotNull
(
list
))
{
TPaymentInfo
payExists
=
null
;
TSocialInfo
socialInfo
=
null
;
...
...
@@ -1989,7 +1803,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
infoVo
.
setEmpIdcard
(
infoVo
.
getEmpIdcard
().
replace
(
"x"
,
"X"
));
}
//导入校验
if
(
socialThreeCheckBase
(
random
,
i
,
log
List
,
infoVo
,
type
))
{
if
(
socialThreeCheckBase
(
random
,
i
,
errorMessage
List
,
infoVo
,
type
))
{
continue
;
}
//无对应员工的社保数据
...
...
@@ -2005,13 +1819,10 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
//对身份证与人员姓名的对应关系进行校验
if
(
socialInfo
!=
null
&&
!
socialInfo
.
getEmpName
().
equals
(
infoVo
.
getEmpName
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"姓名与身份证信息不一致,请核实后再次尝试!"
,
i
,
random
));
continue
;
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"姓名与身份证信息不一致,请核实后再次尝试!"
));
}
if
(
socialInfo
!=
null
&&
socialInfo
.
getSocialStartDate
()
==
null
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
infoVo
.
getEmpIdcard
()
+
"的社保起缴日期为空!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
infoVo
.
getEmpIdcard
()
+
"的社保起缴日期为空!"
));
continue
;
}
if
(
null
==
socialInfo
||
(
null
!=
socialInfo
&&
!
ServiceUtil
.
checkMothForPaymentImport
(
...
...
@@ -2023,8 +1834,7 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
+
CommonConstants
.
DOWN_LINE_STRING
+
(
null
==
infoVo
.
getSocialTown
()
?
"null"
:
infoVo
.
getSocialTown
()));
//对身份证与人员姓名的对应关系进行校验
if
(
socialInfo
!=
null
&&
!
socialInfo
.
getEmpName
().
equals
(
infoVo
.
getEmpName
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"姓名与身份证信息不一致,请核实后再次尝试!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"姓名与身份证信息不一致,请核实后再次尝试!"
));
continue
;
}
if
(
null
!=
socialInfo
&&
!
ServiceUtil
.
checkMothForPaymentImport
(
socialInfo
.
getSocialStartDate
()
...
...
@@ -2044,23 +1854,20 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
}
}
if
(
null
==
socialInfo
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"无对应员工"
+
infoVo
.
getEmpIdcard
()
+
"的社保数据(请查验社保办理状态|缴纳地|起缴月份|停缴月份)"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"无对应员工"
+
infoVo
.
getEmpIdcard
()
+
"的社保数据(请查验社保办理状态|缴纳地|起缴月份|停缴月份)"
));
continue
;
}
//如果导入项目数大于办理成功项目数给提示,少于给进,有问题自行删除后导入
checkRes
=
checkRepeatInfoThree
(
socialInfo
,
infoVo
,
type
);
if
(
null
!=
checkRes
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
checkRes
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
checkRes
));
continue
;
}
//查看缴纳月是否为空
if
(!
Common
.
isNotNull
(
infoVo
.
getSocialPayMonth
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"必填项校验失败:社保缴纳月份不可为空!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"必填项校验失败:社保缴纳月份不可为空!"
));
continue
;
}
...
...
@@ -2081,9 +1888,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getUnitSet
())),
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
payExists
.
getUnitPensionMoney
()),
BigDecimalUtils
.
isNullToZero
(
payExists
.
getPersonalPensionMoney
()))).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的养老缴费数据,请勿重复导入!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的养老缴费数据,请勿重复导入!"
));
continue
;
}
else
{
payExists
=
null
;
...
...
@@ -2107,9 +1913,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getUnitSet
())),
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
payExists
.
getUnitUnemploymentMoney
()),
BigDecimalUtils
.
isNullToZero
(
payExists
.
getPersonalUnemploymentMoney
()))).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的失业缴费数据,请勿重复导入!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的失业缴费数据,请勿重复导入!"
));
continue
;
}
else
{
payExists
=
null
;
...
...
@@ -2134,9 +1939,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getPersonalMedicalMoney
())),
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
payExists
.
getUnitMedicalMoney
()),
BigDecimalUtils
.
isNullToZero
(
payExists
.
getPersonalMedicalMoney
()))).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的医保缴费数据,请勿重复导入!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的医保缴费数据,请勿重复导入!"
));
continue
;
}
else
{
payExists
=
null
;
...
...
@@ -2160,9 +1964,8 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getUnitMedicalMoney
()),
BigDecimalUtils
.
isNullToZero
(
infoVo
.
getPersonalMedicalMoney
())),
BigDecimalUtils
.
isNullToZero
(
payExists
.
getUnitInjuryMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
>
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的单位工伤缴费数据,请勿重复导入!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"已存在对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"的单位工伤缴费数据,请勿重复导入!"
));
continue
;
}
else
{
payExists
=
null
;
...
...
@@ -2278,58 +2081,44 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
if
(
null
!=
payExists
&&
Common
.
isNotNull
(
payExists
.
getId
()))
{
res
=
baseMapper
.
updateById
(
payExists
);
if
(
res
<
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
infoVo
.
getEmpIdcard
()
+
"_缴费库更新失败!"
,
i
,
random
));
continue
;
}
else
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
SUCCESS_MSG_PREFIX
+
infoVo
.
getEmpIdcard
()
+
"_缴费库更新成功!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
infoVo
.
getEmpIdcard
()
+
"_缴费库更新失败!"
));
continue
;
}
}
else
{
res
=
insertAndSTimestamp
(
payExists
);
if
(
res
<
0
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
infoVo
.
getEmpIdcard
()
+
"_缴费库保存失败!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
infoVo
.
getEmpIdcard
()
+
"_缴费库保存失败!"
));
continue
;
}
}
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
SUCCESS_MSG_PREFIX
+
"保存成功!"
,
i
,
random
));
}
itemMap
.
clear
();
cusMap
.
clear
();
}
else
{
return
null
;
}
return
log
List
;
return
errorMessage
List
;
}
/**
* 导入校验
**/
private
boolean
socialThreeCheckBase
(
String
random
,
int
i
,
List
<
TPaymentInfoImportLog
>
log
List
,
TPaymentHeFeiVo
private
boolean
socialThreeCheckBase
(
String
random
,
int
i
,
List
<
ErrorMessage
>
errorMessage
List
,
TPaymentHeFeiVo
infoVo
,
String
type
)
{
if
(!
Common
.
isNotNull
(
infoVo
.
getSocialPayMonth
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"社保缴纳月份不可为空!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"社保缴纳月份不可为空!"
));
return
true
;
}
if
(!
Common
.
isNotNull
(
infoVo
.
getSocialCreateMonth
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"社保生成月份不可为空!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"社保生成月份不可为空!"
));
return
true
;
}
if
(!
Common
.
isNotNull
(
infoVo
.
getSocialPayAddr
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"社保缴纳地不可为空!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"社保缴纳地不可为空!"
));
return
true
;
}
if
(
CommonConstants
.
ZERO_STRING
.
equals
(
type
)
&&
!
PaymentConstants
.
PENSION_RISK
.
equals
(
infoVo
.
getRiskType
())
&&
!
PaymentConstants
.
UNEMPLOYEEMENT_RISK
.
equals
(
infoVo
.
getRiskType
())
&&
!
PaymentConstants
.
INJURY_RISK
.
equals
(
infoVo
.
getRiskType
()))
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"无相关险种!"
,
i
,
random
));
errorMessageList
.
add
(
new
ErrorMessage
(
infoVo
.
getRowIndex
(),
"无相关险种!"
));
return
true
;
}
return
false
;
...
...
@@ -2365,64 +2154,6 @@ public class TPaymentInfoServiceImpl extends ServiceImpl<TPaymentInfoMapper, TPa
return
s
;
}
/**
* 检验每个险种是否可以导入
*
* @param random String
* @param i int
* @param logList List<TPaymentInfoImportLog>
* @param payExists TPaymentInfoVo
* @param infoVo TPaymentHeFeiVo
* @param type String
* @return
* @Author huyc
* @Date 2022-07-27
**/
private
boolean
checkImportInfo
(
String
random
,
int
i
,
List
<
TPaymentInfoImportLog
>
logList
,
TPaymentInfoVo
payExists
,
TPaymentHeFeiVo
infoVo
,
String
type
)
{
boolean
flag
;
if
(
CommonConstants
.
ZERO_STRING
.
equals
(
type
))
{
// 对应养老险种已经存在金额 不合并
flag
=
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
payExists
.
getUnitPensionMoney
())
,
BigDecimalUtils
.
isNullToZero
(
payExists
.
getPersonalPensionMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
==
0
;
if
(
PaymentConstants
.
PENSION_RISK
.
equals
(
infoVo
.
getRiskType
())
&&
!
flag
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"养老数据已存在,请勿重复导入!"
,
i
,
random
));
return
true
;
}
// 对应失业险种已经存在金额 不合并
flag
=
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
payExists
.
getUnitUnemploymentMoney
())
,
BigDecimalUtils
.
isNullToZero
(
payExists
.
getPersonalUnemploymentMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
==
0
;
if
(
PaymentConstants
.
UNEMPLOYEEMENT_RISK
.
equals
(
infoVo
.
getRiskType
())
&&
!
flag
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"失业数据已存在,请勿重复导入!"
,
i
,
random
));
return
true
;
}
// 对应工伤险种已经存在金额 不合并
flag
=
BigDecimalUtils
.
isNullToZero
(
payExists
.
getUnitInjuryMoney
()).
compareTo
(
BigDecimal
.
ZERO
)
==
0
;
if
(
PaymentConstants
.
INJURY_RISK
.
equals
(
infoVo
.
getRiskType
())
&&
!
flag
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"工伤数据已存在,请勿重复导入!"
,
i
,
random
));
return
true
;
}
}
if
(
CommonConstants
.
ONE_STRING
.
equals
(
type
))
{
flag
=
BigDecimalUtils
.
safeAdd
(
BigDecimalUtils
.
isNullToZero
(
payExists
.
getUnitMedicalMoney
())
,
BigDecimalUtils
.
isNullToZero
(
payExists
.
getPersonalMedicalMoney
())).
compareTo
(
BigDecimal
.
ZERO
)
==
0
;
if
(!
flag
)
{
logList
.
add
(
new
TPaymentInfoImportLog
(
null
,
infoVo
.
getEmpName
(),
infoVo
.
getEmpIdcard
()
,
CommonConstants
.
ERROR_MSG_PRFIX
+
"对应员工身份证"
+
infoVo
.
getEmpIdcard
()
+
"医疗数据已存在,请勿重复导入!"
,
i
,
random
));
return
true
;
}
}
return
false
;
}
/**
* 验证部分办理失败的导入是否有超出部分的数据导入
*
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysDeptServiceImpl.java
View file @
3aaf5093
...
...
@@ -26,13 +26,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import
com.unboundid.ldap.sdk.SearchResultEntry
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDept
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysDeptRelation
;
import
com.yifu.cloud.plus.v1.yifu.admin.api.entity.SysUser
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysDeptMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.mapper.SysUserMapper
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptRelationService
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysDeptService
;
import
com.yifu.cloud.plus.v1.yifu.admin.service.SysUserService
;
import
com.yifu.cloud.plus.v1.yifu.common.core.constant.CommonConstants
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.Common
;
import
com.yifu.cloud.plus.v1.yifu.common.core.util.R
;
import
com.yifu.cloud.plus.v1.yifu.common.ldap.util.LdapUtil
;
import
com.yifu.cloud.plus.v1.yifu.common.security.util.SecurityUtils
;
...
...
@@ -44,7 +42,6 @@ import org.springframework.transaction.annotation.Transactional;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* <p>
...
...
@@ -214,6 +211,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
SysDept
insertSysDept
=
new
SysDept
();
insertSysDept
.
setName
(
deptName
);
insertSysDept
.
setParentId
(
0L
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
}
insertSysDept
.
setDeptDn
(
dn
);
this
.
save
(
insertSysDept
);
}
else
{
...
...
@@ -231,6 +231,9 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
insertSysDept
.
setName
(
deptName
);
insertSysDept
.
setParentId
(
sysDept
.
getDeptId
());
insertSysDept
.
setDeptDn
(
dn
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
}
this
.
save
(
insertSysDept
);
}
}
else
{
...
...
yifu-upms/yifu-upms-biz/src/main/java/com/yifu.cloud.plus.v1/yifu/admin/service/impl/SysUserServiceImpl.java
View file @
3aaf5093
...
...
@@ -424,7 +424,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
if
(
null
!=
list
)
{
List
<
SysUser
>
listUser
=
this
.
list
(
Wrappers
.<
SysUser
>
query
().
lambda
().
eq
(
SysUser:
:
getDelFlag
,
CommonConstants
.
STATUS_NORMAL
));
List
<
String
>
list1
=
listUser
.
stream
().
map
(
SysUser:
:
getUsername
).
collect
(
Collectors
.
toList
());
Map
<
String
,
String
>
map
=
listUser
.
stream
().
collect
(
HashMap:
:
new
,
(
m
,
v
)
->
m
.
put
(
v
.
getUsername
(),
v
.
getUserId
()),
HashMap:
:
putAll
);
List
<
PersonVo
>
updateList
=
new
ArrayList
<>();
List
<
PersonVo
>
insertList
=
new
ArrayList
<>();
for
(
PersonVo
personVo
:
list
)
{
...
...
@@ -469,6 +468,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
insertSysDept
.
setName
(
deptName
);
insertSysDept
.
setParentId
(
0L
);
insertSysDept
.
setDeptDn
(
dn
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
}
sysDeptMapper
.
insert
(
insertSysDept
);
}
else
{
sysDept
.
setName
(
deptName
);
...
...
@@ -484,6 +486,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
insertSysDept
.
setName
(
deptName
);
insertSysDept
.
setParentId
(
sysDept
.
getDeptId
());
insertSysDept
.
setDeptDn
(
dn
);
if
(
Common
.
isNotNull
(
entry
.
getAttributeValue
(
"x-ouid"
)))
{
insertSysDept
.
setDeptId
(
Long
.
valueOf
(
entry
.
getAttributeValue
(
"x-ouid"
)));
}
sysDeptMapper
.
insert
(
insertSysDept
);
}
}
else
{
...
...
yifu-upms/yifu-upms-biz/src/main/resources/mapper/SysUserMapper.xml
View file @
3aaf5093
...
...
@@ -210,7 +210,7 @@
<insert
id=
"batchInsertUser"
parameterType=
"java.util.List"
>
insert into sys_user
(user_id,username,phone,email,password,nickname,create_time)
(user_id,username,phone,email,password,nickname,
deptId,
create_time)
VALUES
<foreach
collection=
"list"
item=
"item"
index=
"index"
separator=
","
>
(
...
...
@@ -220,6 +220,7 @@
#{item.email,jdbcType=VARCHAR},
#{item.password,jdbcType=VARCHAR},
#{item.personName,jdbcType=VARCHAR},
#{item.deptId,jdbcType=VARCHAR},
now()
)
</foreach>
...
...
@@ -256,6 +257,13 @@
</if>
</foreach>
</trim>
<trim
prefix=
"deptId =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.deptId!=null"
>
when username=#{i.uid} then #{i.deptId}
</if>
</foreach>
</trim>
<trim
prefix=
"update_time =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
when username=#{i.uid} then now()
...
...
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