Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yujianwangzivayy
MaxKey
提交
d2af3d8f
MaxKey
项目概览
yujianwangzivayy
/
MaxKey
与 Fork 源项目一致
Fork自
MaxKey单点登录官方(MaxKeyTop) / MaxKey
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MaxKey
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
d2af3d8f
编写于
11月 08, 2020
作者:
Y
yapeng.li
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
添加新特性
1. 添加MaxKey用户通过excel导入功能-后端接口开发 100%
上级
235982d8
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
318 addition
and
279 deletion
+318
-279
maxkey-core/src/main/java/org/maxkey/domain/ImportResultBaseVO.java
...e/src/main/java/org/maxkey/domain/ImportResultBaseVO.java
+0
-64
maxkey-core/src/main/java/org/maxkey/domain/ImportResultVO.java
...-core/src/main/java/org/maxkey/domain/ImportResultVO.java
+0
-105
maxkey-core/src/main/java/org/maxkey/domain/UserInfo.java
maxkey-core/src/main/java/org/maxkey/domain/UserInfo.java
+37
-37
maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoListener.java
...java/org/maxkey/persistence/service/UserInfoListener.java
+0
-61
maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoService.java
.../java/org/maxkey/persistence/service/UserInfoService.java
+276
-8
maxkey-web-manage/src/main/java/org/maxkey/web/contorller/UserInfoController.java
...in/java/org/maxkey/web/contorller/UserInfoController.java
+5
-4
未找到文件。
maxkey-core/src/main/java/org/maxkey/domain/ImportResultBaseVO.java
已删除
100644 → 0
浏览文件 @
235982d8
package
org.maxkey.domain
;
import
org.apache.commons.lang.StringUtils
;
/**
* @author yapeng.li
* @date 2019.3.6
*/
public
class
ImportResultBaseVO
{
/**
* 资源名
*/
private
String
name
;
/**
* 状态
*/
private
String
status
;
/**
* 描述
*/
private
String
desc
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
Integer
status
)
{
if
(
status
==
0
){
this
.
status
=
"SUCCESS"
;
}
else
if
(
status
==
1
){
this
.
status
=
"FAILURE"
;
}
else
{
this
.
status
=
"IGNORE"
;
}
}
public
String
getDesc
()
{
if
(
StringUtils
.
isEmpty
(
desc
)){
return
""
;
}
return
desc
;
}
public
void
setDesc
(
String
desc
)
{
this
.
desc
=
desc
;
}
@Override
public
String
toString
()
{
return
"ImportResultBaseVO{"
+
"name='"
+
name
+
'\''
+
", status='"
+
status
+
'\''
+
", desc='"
+
desc
+
'\''
+
'}'
;
}
}
maxkey-core/src/main/java/org/maxkey/domain/ImportResultVO.java
已删除
100644 → 0
浏览文件 @
235982d8
package
org.maxkey.domain
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author yapeng.li
* @since 2020/9/21 21:12
*/
public
class
ImportResultVO
{
/**
* 成功结果
*/
List
<
ImportResultBaseVO
>
success
;
/**
* 失败结果
*/
List
<
ImportResultBaseVO
>
error
;
/**
* 忽略结果
*/
List
<
ImportResultBaseVO
>
ignore
;
/**
* 成功次数
*/
Integer
successCount
;
/**
* 失败次数
*/
Integer
errorCount
;
/**
* 忽略次数
*/
Integer
ignoreCount
;
public
List
<
ImportResultBaseVO
>
getSuccess
()
{
if
(
success
==
null
){
success
=
new
ArrayList
<>();
}
return
success
;
}
public
void
setSuccess
(
List
<
ImportResultBaseVO
>
success
)
{
this
.
success
=
success
;
}
public
List
<
ImportResultBaseVO
>
getError
()
{
if
(
error
==
null
){
error
=
new
ArrayList
<>();
}
return
error
;
}
public
void
setError
(
List
<
ImportResultBaseVO
>
error
)
{
this
.
error
=
error
;
}
public
List
<
ImportResultBaseVO
>
getIgnore
()
{
if
(
ignore
==
null
){
ignore
=
new
ArrayList
<>();
}
return
ignore
;
}
public
void
setIgnore
(
List
<
ImportResultBaseVO
>
ignore
)
{
this
.
ignore
=
ignore
;
}
public
Integer
getSuccessCount
()
{
return
successCount
;
}
public
void
setSuccessCount
(
Integer
successCount
)
{
this
.
successCount
=
successCount
;
}
public
Integer
getErrorCount
()
{
return
errorCount
;
}
public
void
setErrorCount
(
Integer
errorCount
)
{
this
.
errorCount
=
errorCount
;
}
public
Integer
getIgnoreCount
()
{
return
ignoreCount
;
}
public
void
setIgnoreCount
(
Integer
ignoreCount
)
{
this
.
ignoreCount
=
ignoreCount
;
}
@Override
public
String
toString
()
{
return
"ImportResultVO{"
+
"success="
+
success
+
", error="
+
error
+
", ignore="
+
ignore
+
", successCount="
+
successCount
+
", errorCount="
+
errorCount
+
", ignoreCount="
+
ignoreCount
+
'}'
;
}
}
maxkey-core/src/main/java/org/maxkey/domain/UserInfo.java
浏览文件 @
d2af3d8f
/*
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* See the License for the specific language governing permissions and
* limitations under the License.
* limitations under the License.
*/
*/
package
org.maxkey.domain
;
package
org.maxkey.domain
;
...
@@ -32,7 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
...
@@ -32,7 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
/**
/**
* .
* .
* @author Crystal.Sea
* @author Crystal.Sea
*
*
*/
*/
@Table
(
name
=
"MXK_USERINFO"
)
@Table
(
name
=
"MXK_USERINFO"
)
public
class
UserInfo
extends
JpaBaseDomain
{
public
class
UserInfo
extends
JpaBaseDomain
{
...
@@ -327,7 +327,7 @@ public class UserInfo extends JpaBaseDomain {
...
@@ -327,7 +327,7 @@ public class UserInfo extends JpaBaseDomain {
}
}
/**
/**
*
*
*/
*/
public
UserInfo
()
{
public
UserInfo
()
{
super
();
super
();
...
@@ -467,7 +467,7 @@ public class UserInfo extends JpaBaseDomain {
...
@@ -467,7 +467,7 @@ public class UserInfo extends JpaBaseDomain {
this
.
nickName
=
nickName
;
this
.
nickName
=
nickName
;
}
}
public
String
getNameZhSpell
()
{
public
String
getNameZhSpell
()
{
return
nameZhSpell
;
return
nameZhSpell
;
...
@@ -1147,64 +1147,64 @@ public class UserInfo extends JpaBaseDomain {
...
@@ -1147,64 +1147,64 @@ public class UserInfo extends JpaBaseDomain {
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
"UserInfo [username="
+
username
return
"UserInfo [username="
+
username
+
", password="
+
password
+
", decipherable="
+
decipherable
+
", password="
+
password
+
", decipherable="
+
decipherable
+
", sharedSecret="
+
sharedSecret
+
", sharedSecret="
+
sharedSecret
+
", sharedCounter="
+
sharedCounter
+
", userType="
+
userType
+
", sharedCounter="
+
sharedCounter
+
", userType="
+
userType
+
", windowsAccount="
+
windowsAccount
+
", windowsAccount="
+
windowsAccount
+
", displayName="
+
displayName
+
", nickName="
+
nickName
+
", displayName="
+
displayName
+
", nickName="
+
nickName
+
", nameZHSpell="
+
nameZhSpell
+
", nameZHSpell="
+
nameZhSpell
+
", nameZHShortSpell="
+
nameZhShortSpell
+
", nameZHShortSpell="
+
nameZhShortSpell
+
", givenName="
+
givenName
+
", givenName="
+
givenName
+
", middleName="
+
middleName
+
", familyName="
+
familyName
+
", middleName="
+
middleName
+
", familyName="
+
familyName
+
", honorificPrefix="
+
honorificPrefix
+
", honorificPrefix="
+
honorificPrefix
+
", honorificSuffix="
+
honorificSuffix
+
", honorificSuffix="
+
honorificSuffix
+
", formattedName="
+
formattedName
+
", married="
+
married
+
", formattedName="
+
formattedName
+
", married="
+
married
+
", gender="
+
gender
+
", birthDate="
+
birthDate
+
", gender="
+
gender
+
", birthDate="
+
birthDate
+
", pictureFile="
+
pictureFile
+
", idType="
+
", pictureFile="
+
pictureFile
+
", idType="
+
idType
+
", idCardNo="
+
idCardNo
+
", webSite="
+
webSite
+
idType
+
", idCardNo="
+
idCardNo
+
", webSite="
+
webSite
+
", startWorkDate="
+
startWorkDate
+
", startWorkDate="
+
startWorkDate
+
", authnType="
+
authnType
+
", email="
+
email
+
", authnType="
+
authnType
+
", email="
+
email
+
", emailVerified="
+
emailVerified
+
", mobile="
+
", emailVerified="
+
emailVerified
+
", mobile="
+
mobile
+
", mobileVerified="
+
mobileVerified
+
mobile
+
", mobileVerified="
+
mobileVerified
+
", passwordQuestion="
+
passwordQuestion
+
", passwordQuestion="
+
passwordQuestion
+
", passwordAnswer="
+
passwordAnswer
+
", appLoginAuthnType="
+
appLoginAuthnType
+
", passwordAnswer="
+
passwordAnswer
+
", appLoginAuthnType="
+
appLoginAuthnType
+
", appLoginPassword="
+
appLoginPassword
+
", appLoginPassword="
+
appLoginPassword
+
", protectedApps="
+
protectedApps
+
", protectedAppsMap="
+
", protectedApps="
+
protectedApps
+
", protectedAppsMap="
+
protectedAppsMap
+
", passwordLastSetTime="
+
passwordLastSetTime
+
protectedAppsMap
+
", passwordLastSetTime="
+
passwordLastSetTime
+
", badPasswordCount="
+
", badPasswordCount="
+
badPasswordCount
+
", unLockTime="
+
unLockTime
+
badPasswordCount
+
", unLockTime="
+
unLockTime
+
", isLocked="
+
isLocked
+
", lastLoginTime="
+
", isLocked="
+
isLocked
+
", lastLoginTime="
+
lastLoginTime
+
", lastLoginIp="
+
lastLoginIp
+
lastLoginTime
+
", lastLoginIp="
+
lastLoginIp
+
", lastLogoffTime="
+
lastLogoffTime
+
", lastLogoffTime="
+
lastLogoffTime
+
", passwordSetType="
+
passwordSetType
+
", passwordSetType="
+
passwordSetType
+
", loginCount="
+
loginCount
+
", locale="
+
locale
+
", loginCount="
+
loginCount
+
", locale="
+
locale
+
", timeZone="
+
timeZone
+
", preferredLanguage="
+
preferredLanguage
+
", timeZone="
+
timeZone
+
", preferredLanguage="
+
preferredLanguage
+
", workCountry="
+
workCountry
+
", workCountry="
+
workCountry
+
", workRegion="
+
workRegion
+
", workLocality="
+
workLocality
+
", workRegion="
+
workRegion
+
", workLocality="
+
workLocality
+
", workStreetAddress="
+
", workStreetAddress="
+
workStreetAddress
+
", workAddressFormatted="
+
workAddressFormatted
+
workStreetAddress
+
", workAddressFormatted="
+
workAddressFormatted
+
", workEmail="
+
workEmail
+
", workEmail="
+
workEmail
+
", workPhoneNumber="
+
workPhoneNumber
+
", workPostalCode="
+
workPostalCode
+
", workPhoneNumber="
+
workPhoneNumber
+
", workPostalCode="
+
workPostalCode
+
", workFax="
+
workFax
+
", workFax="
+
workFax
+
", homeCountry="
+
homeCountry
+
", homeRegion="
+
homeRegion
+
", homeCountry="
+
homeCountry
+
", homeRegion="
+
homeRegion
+
", homeLocality="
+
homeLocality
+
", homeLocality="
+
homeLocality
+
", homeStreetAddress="
+
homeStreetAddress
+
", homeStreetAddress="
+
homeStreetAddress
+
", homeAddressFormatted="
+
homeAddressFormatted
+
", homeAddressFormatted="
+
homeAddressFormatted
+
", homeEmail="
+
homeEmail
+
", homeEmail="
+
homeEmail
+
", homePhoneNumber="
+
homePhoneNumber
+
", homePostalCode="
+
", homePhoneNumber="
+
homePhoneNumber
+
", homePostalCode="
+
homePostalCode
+
", homeFax="
+
homeFax
+
homePostalCode
+
", homeFax="
+
homeFax
+
", employeeNumber="
+
employeeNumber
+
", costCenter="
+
", employeeNumber="
+
employeeNumber
+
", costCenter="
+
costCenter
+
", organization="
+
organization
+
costCenter
+
", organization="
+
organization
+
", division="
+
division
+
", departmentId="
+
", division="
+
division
+
", departmentId="
+
departmentId
+
", department="
+
department
+
departmentId
+
", department="
+
department
+
", jobTitle="
+
jobTitle
+
", jobLevel="
+
jobLevel
+
", jobTitle="
+
jobTitle
+
", jobLevel="
+
jobLevel
+
", managerId="
+
managerId
+
", manager="
+
manager
+
", managerId="
+
managerId
+
", manager="
+
manager
+
", assistantId="
+
assistantId
+
", assistant="
+
", assistantId="
+
assistantId
+
", assistant="
+
assistant
+
", entryDate="
+
entryDate
+
assistant
+
", entryDate="
+
entryDate
+
", quitDate="
+
quitDate
+
", extraAttribute="
+
extraAttribute
+
", quitDate="
+
quitDate
+
", extraAttribute="
+
extraAttribute
+
", extraAttributeName="
+
extraAttributeName
+
", extraAttributeValue="
+
", extraAttributeName="
+
extraAttributeName
+
", extraAttributeValue="
+
extraAttributeValue
+
", extraAttributeMap="
+
extraAttributeMap
+
extraAttributeValue
+
", extraAttributeMap="
+
extraAttributeMap
+
", online="
+
online
+
", ldapDn="
+
", online="
+
online
+
", ldapDn="
+
ldapDn
+
"]"
;
+
ldapDn
+
"]"
;
}
}
...
...
maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoListener.java
已删除
100644 → 0
浏览文件 @
235982d8
package
org.maxkey.persistence.service
;
import
com.alibaba.excel.context.AnalysisContext
;
import
com.alibaba.excel.event.AnalysisEventListener
;
import
com.alibaba.fastjson.JSON
;
import
org.maxkey.domain.UserInfo
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author yapeng.li
*/
public
class
UserInfoListener
extends
AnalysisEventListener
<
UserInfo
>
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
UserInfoListener
.
class
);
/**
* 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收
*/
private
static
final
int
BATCH_COUNT
=
20
;
List
<
UserInfo
>
list
=
new
ArrayList
<
UserInfo
>();
private
UserInfoService
userInfoService
;
public
UserInfoListener
(
UserInfoService
userInfoService
)
{
this
.
userInfoService
=
userInfoService
;
}
@Override
public
void
invoke
(
UserInfo
data
,
AnalysisContext
context
)
{
LOGGER
.
info
(
"解析到一条数据:{}"
,
JSON
.
toJSONString
(
data
));
list
.
add
(
data
);
// 达到BATCH_COUNT了,需要去存储一次数据库,防止数据几万条数据在内存,容易OOM
if
(
list
.
size
()
>=
BATCH_COUNT
)
{
saveData
();
// 存储完成清理 list
list
.
clear
();
}
}
@Override
public
void
doAfterAllAnalysed
(
AnalysisContext
context
)
{
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
saveData
();
LOGGER
.
info
(
"所有数据解析完成!"
);
}
/**
* 加上存储数据库
*/
private
void
saveData
()
{
LOGGER
.
info
(
"{}条数据,开始存储数据库!"
,
list
.
size
());
userInfoService
.
batchInsert
(
list
);
LOGGER
.
info
(
"存储数据库成功!"
);
}
}
maxkey-persistence/src/main/java/org/maxkey/persistence/service/UserInfoService.java
浏览文件 @
d2af3d8f
...
@@ -18,12 +18,18 @@
...
@@ -18,12 +18,18 @@
package
org.maxkey.persistence.service
;
package
org.maxkey.persistence.service
;
import
com.google.common.collect.Lists
;
import
org.apache.mybatis.jpa.persistence.JpaBaseService
;
import
org.apache.mybatis.jpa.persistence.JpaBaseService
;
import
org.apache.poi.hssf.usermodel.HSSFWorkbook
;
import
org.apache.poi.ss.usermodel.Cell
;
import
org.apache.poi.ss.usermodel.Row
;
import
org.apache.poi.ss.usermodel.Sheet
;
import
org.apache.poi.ss.usermodel.Workbook
;
import
org.apache.poi.xssf.usermodel.XSSFWorkbook
;
import
org.maxkey.constants.ConstantsStatus
;
import
org.maxkey.constants.ConstantsStatus
;
import
org.maxkey.crypto.ReciprocalUtils
;
import
org.maxkey.crypto.ReciprocalUtils
;
import
org.maxkey.crypto.password.PasswordReciprocal
;
import
org.maxkey.crypto.password.PasswordReciprocal
;
import
org.maxkey.domain.ChangePassword
;
import
org.maxkey.domain.ChangePassword
;
import
org.maxkey.domain.ImportResultVO
;
import
org.maxkey.domain.UserInfo
;
import
org.maxkey.domain.UserInfo
;
import
org.maxkey.identity.kafka.KafkaIdentityAction
;
import
org.maxkey.identity.kafka.KafkaIdentityAction
;
import
org.maxkey.identity.kafka.KafkaIdentityTopic
;
import
org.maxkey.identity.kafka.KafkaIdentityTopic
;
...
@@ -39,9 +45,13 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -39,9 +45,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.jdbc.core.JdbcTemplate
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.security.crypto.password.PasswordEncoder
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.util.List
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.util.*
;
import
java.util.stream.Collectors
;
/**
/**
...
@@ -120,16 +130,274 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
...
@@ -120,16 +130,274 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
return
false
;
return
false
;
}
}
public
ImportResultVO
importing
(
MultipartFile
file
,
Integer
type
)
{
public
boolean
importing
(
MultipartFile
file
)
throws
IOException
{
if
(
file
==
null
){
return
false
;
}
// 解析excel文件中数据
List
<
UserInfo
>
userInfos
=
readExcel
(
file
);
return
batchInsert
(
userInfos
);
}
// 校验当前文件格式是不是excel文件
// 解析excel文件中数据
private
static
List
<
UserInfo
>
readExcel
(
MultipartFile
file
)
throws
IOException
{
InputStream
is
=
file
.
getInputStream
();
Workbook
wb
;
String
xls
=
".xls"
;
String
xlsx
=
".xlsx"
;
int
columnSize
=
46
;
List
<
UserInfo
>
userInfos
=
Lists
.
newArrayList
();
// 判断当前类型 0忽略 1覆盖 2终止
try
{
// 返回导入结果
if
(
file
.
getOriginalFilename
().
toLowerCase
().
endsWith
(
xls
))
{
wb
=
new
HSSFWorkbook
(
is
);
}
else
if
(
file
.
getOriginalFilename
().
toLowerCase
().
endsWith
(
xlsx
))
{
wb
=
new
XSSFWorkbook
(
is
);
}
else
{
throw
new
RuntimeException
(
"maxKey用户导入没有Excel类型"
);
}
int
sheetSize
=
wb
.
getNumberOfSheets
();
//遍历sheet页
for
(
int
i
=
0
;
i
<
sheetSize
;
i
++)
{
Sheet
sheet
=
wb
.
getSheetAt
(
i
);
int
rowSize
=
sheet
.
getLastRowNum
()
+
1
;
//遍历行
for
(
int
j
=
1
;
j
<
rowSize
;
j
++)
{
Row
row
=
sheet
.
getRow
(
j
);
//略过空行和第一行
if
(
row
==
null
||
j
==
0
)
{
continue
;
}
else
{
//其他行是数据行
UserInfo
userInfo
=
new
UserInfo
();
userInfo
.
setCreatedDate
(
DateUtils
.
formatDateTime
(
new
Date
()));
int
rangeType
=
-
1
;
for
(
int
k
=
0
;
k
<
columnSize
;
k
++)
{
if
(
k
==
0
)
{
// 登录账号
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setUsername
(
getValue
(
cell
));
}
else
if
(
k
==
1
)
{
// 密码
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setPassword
(
getValue
(
cell
));
}
else
if
(
k
==
2
)
{
// 员工编码
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setEmployeeNumber
(
getValue
(
cell
));
}
else
if
(
k
==
3
)
{
// 用户类型
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setUserType
(
getValue
(
cell
));
}
else
if
(
k
==
4
)
{
// 用户名
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setDisplayName
(
getValue
(
cell
));
}
else
if
(
k
==
5
)
{
// 姓
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setFamilyName
(
getValue
(
cell
));
}
else
if
(
k
==
6
)
{
// 名
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setGivenName
(
getValue
(
cell
));
}
else
if
(
k
==
7
)
{
// 中间名
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setMiddleName
(
getValue
(
cell
));
}
else
if
(
k
==
8
)
{
// 昵称
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setNickName
(
getValue
(
cell
));
}
else
if
(
k
==
9
)
{
// 性别
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setGender
(
Integer
.
valueOf
(
getValue
(
cell
)));
}
else
if
(
k
==
10
)
{
// AD域账号
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setWindowsAccount
(
getValue
(
cell
));
}
else
if
(
k
==
11
)
{
// 出生日期
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setBirthDate
(
getValue
(
cell
));
}
else
if
(
k
==
12
)
{
// 语言偏好
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setPreferredLanguage
(
getValue
(
cell
));
}
else
if
(
k
==
13
)
{
// 时区
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setTimeZone
(
getValue
(
cell
));
}
else
if
(
k
==
14
)
{
// 所属机构
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setOrganization
(
getValue
(
cell
));
}
else
if
(
k
==
15
)
{
// 分支机构
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setDivision
(
getValue
(
cell
));
}
else
if
(
k
==
16
)
{
// 部门名称
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setDepartment
(
getValue
(
cell
));
}
else
if
(
k
==
17
)
{
// 成本中心
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setCostCenter
(
getValue
(
cell
));
}
else
if
(
k
==
18
)
{
// 职位
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setJobTitle
(
getValue
(
cell
));
}
else
if
(
k
==
19
)
{
// 级别
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setJobLevel
(
getValue
(
cell
));
}
else
if
(
k
==
20
)
{
// 上级经理
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setManager
(
getValue
(
cell
));
}
else
if
(
k
==
21
)
{
// 助理
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setAssistant
(
getValue
(
cell
));
}
else
if
(
k
==
22
)
{
// 入职时间
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setEntryDate
(
getValue
(
cell
));
}
else
if
(
k
==
23
)
{
// 离职时间
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setQuitDate
(
getValue
(
cell
));
}
else
if
(
k
==
24
)
{
// 工作-国家
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setWorkCountry
(
getValue
(
cell
));
}
else
if
(
k
==
25
)
{
// 工作-省
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setWorkRegion
(
getValue
(
cell
));
}
else
if
(
k
==
26
)
{
// 工作-城市
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setTimeZone
(
getValue
(
cell
));
}
else
if
(
k
==
27
)
{
// 工作-地址
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setWorkLocality
(
getValue
(
cell
));
}
else
if
(
k
==
28
)
{
// 邮编
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setWorkPostalCode
(
getValue
(
cell
));
}
else
if
(
k
==
29
)
{
// 传真
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setWorkFax
(
getValue
(
cell
));
}
else
if
(
k
==
30
)
{
// 工作电话
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setWorkPhoneNumber
(
getValue
(
cell
));
}
else
if
(
k
==
31
)
{
// 工作邮件
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setWorkEmail
(
getValue
(
cell
));
}
else
if
(
k
==
32
)
{
// 证件类型 todo 现在数据库中存储的是tinyint
// Cell cell = row.getCell(k);
// userInfo.setIdType(getValue(cell));
}
else
if
(
k
==
33
)
{
// 证件号码
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setIdCardNo
(
getValue
(
cell
));
}
else
if
(
k
==
34
)
{
// 婚姻状态 todo 现在数据字段类型是 tinyint
// Cell cell = row.getCell(k);
// userInfo.setMarried(getValue(cell));
}
else
if
(
k
==
35
)
{
// 开始工作时间
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setStartWorkDate
(
getValue
(
cell
));
}
else
if
(
k
==
36
)
{
// 国家
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setHomeCountry
(
getValue
(
cell
));
}
else
if
(
k
==
37
)
{
// 省
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setHomeRegion
(
getValue
(
cell
));
}
else
if
(
k
==
38
)
{
// 城市
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setHomeLocality
(
getValue
(
cell
));
}
else
if
(
k
==
39
)
{
// 家庭地址
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setHomeStreetAddress
(
getValue
(
cell
));
}
else
if
(
k
==
40
)
{
// 家庭邮编
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setHomePostalCode
(
getValue
(
cell
));
}
else
if
(
k
==
41
)
{
// 家庭传真
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setHomeFax
(
getValue
(
cell
));
}
else
if
(
k
==
42
)
{
// 家庭电话
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setHomePhoneNumber
(
getValue
(
cell
));
}
else
if
(
k
==
43
)
{
// 家庭邮箱
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setHomeEmail
(
getValue
(
cell
));
}
else
if
(
k
==
44
)
{
// 个人主页
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setWebSite
(
getValue
(
cell
));
}
else
if
(
k
==
45
)
{
// 即时通讯
Cell
cell
=
row
.
getCell
(
k
);
userInfo
.
setDefineIm
(
getValue
(
cell
));
}
}
userInfos
.
add
(
userInfo
);
}
}
}
// 数据去重
if
(
CollectionUtils
.
isEmpty
(
userInfos
)){
userInfos
=
userInfos
.
stream
().
collect
(
Collectors
.
collectingAndThen
(
Collectors
.
toCollection
(()
->
new
TreeSet
<>(
Comparator
.
comparing
(
o
->
o
.
getUsername
()))),
ArrayList:
:
new
));
}
return
userInfos
;
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
is
!=
null
)
{
is
.
close
();
}
}
return
userInfos
;
}
return
new
ImportResultVO
();
/**
* 根据数据格式返回数据
*
* @param cell
* @return
*/
public
static
String
getValue
(
Cell
cell
)
{
if
(
cell
==
null
)
{
return
""
;
}
else
if
(
cell
.
getCellType
()
==
Cell
.
CELL_TYPE_BOOLEAN
)
{
return
String
.
valueOf
(
cell
.
getBooleanCellValue
());
}
else
if
(
cell
.
getCellType
()
==
Cell
.
CELL_TYPE_NUMERIC
)
{
cell
.
setCellType
(
Cell
.
CELL_TYPE_STRING
);
return
String
.
valueOf
(
cell
.
getStringCellValue
().
trim
());
}
else
{
return
String
.
valueOf
(
cell
.
getStringCellValue
().
trim
());
}
}
}
public
boolean
delete
(
UserInfo
userInfo
)
{
public
boolean
delete
(
UserInfo
userInfo
)
{
...
...
maxkey-web-manage/src/main/java/org/maxkey/web/contorller/UserInfoController.java
浏览文件 @
d2af3d8f
...
@@ -26,12 +26,10 @@ import java.util.Map;
...
@@ -26,12 +26,10 @@ import java.util.Map;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
com.alibaba.excel.EasyExcel
;
import
org.apache.mybatis.jpa.persistence.JpaPageResults
;
import
org.apache.mybatis.jpa.persistence.JpaPageResults
;
import
org.maxkey.constants.ConstantsOperateMessage
;
import
org.maxkey.constants.ConstantsOperateMessage
;
import
org.maxkey.crypto.ReciprocalUtils
;
import
org.maxkey.crypto.ReciprocalUtils
;
import
org.maxkey.domain.UserInfo
;
import
org.maxkey.domain.UserInfo
;
import
org.maxkey.persistence.service.UserInfoListener
;
import
org.maxkey.persistence.service.UserInfoService
;
import
org.maxkey.persistence.service.UserInfoService
;
import
org.maxkey.util.JsonUtils
;
import
org.maxkey.util.JsonUtils
;
import
org.maxkey.util.StringUtils
;
import
org.maxkey.util.StringUtils
;
...
@@ -144,8 +142,11 @@ public class UserInfoController {
...
@@ -144,8 +142,11 @@ public class UserInfoController {
*/
*/
@RequestMapping
(
value
=
"/importing"
)
@RequestMapping
(
value
=
"/importing"
)
public
Object
importing
(
MultipartFile
file
)
throws
IOException
{
public
Object
importing
(
MultipartFile
file
)
throws
IOException
{
EasyExcel
.
read
(
file
.
getInputStream
(),
UserInfo
.
class
,
new
UserInfoListener
(
userInfoService
)).
sheet
().
doRead
();
if
(
userInfoService
.
importing
(
file
))
{
return
"success"
;
return
new
Message
(
WebContext
.
getI18nValue
(
ConstantsOperateMessage
.
INSERT_SUCCESS
),
null
,
MessageType
.
success
,
OperateType
.
add
,
MessageScope
.
DB
);
}
else
{
return
new
Message
(
WebContext
.
getI18nValue
(
ConstantsOperateMessage
.
INSERT_ERROR
),
MessageType
.
error
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录