Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
entrance_api
Project
Project
Details
Activity
Releases
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
王琮
entrance_api
Commits
74c24277
Commit
74c24277
authored
Dec 14, 2022
by
王琮
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改员工导入
parent
ff43a267
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
78 additions
and
245 deletions
+78
-245
SysUserController.java
...org/rcisoft/sys/sysuser/controller/SysUserController.java
+2
-2
UserErrorDTO.java
src/main/java/org/rcisoft/sys/sysuser/dto/UserErrorDTO.java
+10
-0
SysUserService.java
.../java/org/rcisoft/sys/sysuser/service/SysUserService.java
+1
-1
SysUserServiceImpl.java
.../rcisoft/sys/sysuser/service/impl/SysUserServiceImpl.java
+46
-71
CheckUtil.java
src/main/java/org/rcisoft/sys/sysuser/util/CheckUtil.java
+19
-14
VisitPersonService.java
...ava/org/rcisoft/sys/visit/service/VisitPersonService.java
+0
-1
VisitPersonServiceImpl.java
...cisoft/sys/visit/service/impl/VisitPersonServiceImpl.java
+0
-156
No files found.
src/main/java/org/rcisoft/sys/sysuser/controller/SysUserController.java
View file @
74c24277
...
...
@@ -219,11 +219,11 @@ public class SysUserController extends CyPaginationController<SysUser> {
@ApiOperation
(
value
=
"导入用户信息"
,
notes
=
"导入用户信息"
)
@PostMapping
(
"/importExcel"
)
@CyEptSm4EnableAnno
public
CyResult
importSysUser
(
MultipartFile
file
)
{
public
CyResult
importSysUser
(
MultipartFile
file
,
HttpServletResponse
response
)
{
return
CyResultGenUtil
.
builder
(
new
CyPersistModel
(
1
),
CyMessCons
.
MESSAGE_ALERT_SUCCESS
,
CyMessCons
.
MESSAGE_ALERT_ERROR
,
sysUserServiceImpl
.
importUserExcel
(
file
));
sysUserServiceImpl
.
importUserExcel
(
file
,
response
));
}
/**
...
...
src/main/java/org/rcisoft/sys/sysuser/dto/UserErrorDTO.java
0 → 100644
View file @
74c24277
package
org
.
rcisoft
.
sys
.
sysuser
.
dto
;
import
cn.afterturn.easypoi.excel.annotation.Excel
;
import
lombok.Data
;
@Data
public
class
UserErrorDTO
extends
ExportUserDTO
{
@Excel
(
name
=
"错误提示"
,
orderNum
=
"2"
,
width
=
40
)
private
String
error
;
}
src/main/java/org/rcisoft/sys/sysuser/service/SysUserService.java
View file @
74c24277
...
...
@@ -92,7 +92,7 @@ public interface SysUserService {
int
exportEmptyTemplate
(
HttpServletResponse
response
);
ImportUserDTO
importUserExcel
(
MultipartFile
file
);
ImportUserDTO
importUserExcel
(
MultipartFile
file
,
HttpServletResponse
response
);
/**
...
...
src/main/java/org/rcisoft/sys/sysuser/service/impl/SysUserServiceImpl.java
View file @
74c24277
This diff is collapsed.
Click to expand it.
src/main/java/org/rcisoft/sys/sysuser/util/CheckUtil.java
View file @
74c24277
...
...
@@ -6,6 +6,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.rcisoft.core.constant.CySysCons
;
import
org.rcisoft.core.exception.CyServiceException
;
import
org.rcisoft.sys.sysuser.dto.ExportUserDTO
;
import
org.rcisoft.sys.sysuser.dto.UserErrorDTO
;
import
org.rcisoft.sys.sysuser.entity.SysUser
;
import
org.rcisoft.sys.visit.dto.ExportVisitInfoDto
;
import
org.rcisoft.sys.visit.dto.ExportVisitUserDTO
;
...
...
@@ -35,27 +36,31 @@ public class CheckUtil {
* 对导入的用户信息进行非空校验
*
* @param sysUser 用户信息
* @param row 行数
* @return
*/
public
static
ErrorDTO
userNotNull
(
ExportUserDTO
sysUser
,
int
row
)
{
ErrorDTO
errorDTO
=
new
ErrorDTO
();
Map
<
Integer
,
List
<
String
>>
notTrues
=
new
HashMap
<>();
public
static
UserErrorDTO
userNotNull
(
ExportUserDTO
sysUser
)
{
UserErrorDTO
errorDTO
=
new
UserErrorDTO
();
List
<
String
>
notTrue
=
new
ArrayList
<>();
errorDTO
.
setSuccess
(
0
);
if
(
StringUtils
.
isEmpty
(
sysUser
.
getName
()))
{
if
(
StringUtils
.
isEmpty
(
sysUser
.
getName
()))
notTrue
.
add
(
"姓名不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
sysUser
.
getPhone
()))
{
if
(
StringUtils
.
isEmpty
(
sysUser
.
getPhone
()))
notTrue
.
add
(
"手机号不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
sysUser
.
getSex
()))
{
if
(!
sysUser
.
getPhone
().
matches
(
"^1[3-9]\\d{9}$"
))
notTrue
.
add
(
"手机号格式不正确"
);
if
(
StringUtils
.
isEmpty
(
sysUser
.
getSex
()))
notTrue
.
add
(
"性别不能为空"
);
}
if
(
StringUtils
.
isEmpty
(
sysUser
.
getAddress
()))
notTrue
.
add
(
"所属园区不能为空"
);
if
(
StringUtils
.
isEmpty
(
sysUser
.
getDeptId
()))
notTrue
.
add
(
"所属部门不能为空"
);
if
(
StringUtils
.
isEmpty
(
sysUser
.
getPosition
()))
notTrue
.
add
(
"职位不能为空"
);
if
(
StringUtils
.
isEmpty
(
sysUser
.
getNltBz
()))
notTrue
.
add
(
"班次不能为空"
);
if
(
notTrue
.
size
()
>
0
)
{
errorDTO
.
setSuccess
(
1
);
notTrues
.
put
(
row
,
notTrue
);
errorDTO
.
setMap
(
notTrues
)
;
BeanUtil
.
copyProperties
(
sysUser
,
errorDTO
);
errorDTO
.
setError
(
notTrue
.
stream
().
collect
(
Collectors
.
joining
(
","
))
);
return
errorDTO
;
}
return
errorDTO
;
}
...
...
src/main/java/org/rcisoft/sys/visit/service/VisitPersonService.java
View file @
74c24277
...
...
@@ -90,7 +90,6 @@ public interface VisitPersonService {
int
exportEmptyTemplate
(
HttpServletResponse
response
);
ImportUserDTO
importUserExcel
(
MultipartFile
file
);
/**
...
...
src/main/java/org/rcisoft/sys/visit/service/impl/VisitPersonServiceImpl.java
View file @
74c24277
...
...
@@ -369,162 +369,6 @@ public class VisitPersonServiceImpl extends ServiceImpl<VisitPersonRepositorys,
importUserDTO
.
setFilename
(
fileName
);
}
@Override
@Transactional
public
ImportUserDTO
importUserExcel
(
MultipartFile
file
)
{
ImportUserDTO
importUserDTO
=
new
ImportUserDTO
();
Calendar
calendar
=
Calendar
.
getInstance
();
String
nowTime
=
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
calendar
.
getTime
());
String
fileName
=
"用户错误信息"
+
nowTime
+
".txt"
;
List
<
Map
<
Integer
,
List
<
String
>>>
maps
=
new
ArrayList
<>();
ExportUserDTO
exportUserDTO
=
new
ExportUserDTO
();
boolean
flag
=
false
;
try
{
flag
=
CyEpExcelUtil
.
isFileInUser
(
file
,
exportUserDTO
,
2
);
}
catch
(
Exception
e
)
{
throw
new
CyServiceException
(
CyResSvcExcEnum
.
ERROR_NETWORK
);
}
if
(!
flag
||
!
CyCompareToolUtils
.
compareFileName
(
file
,
"用户信息"
,
0
,
0
))
{
String
errorBefore
=
"上传模板错误请重新下载!"
;
errorText
(
errorBefore
,
importUserDTO
,
maps
,
fileName
);
try
{
errorTxt
.
exportTxtPaper
(
maps
,
fileName
);
}
catch
(
Exception
e
)
{
throw
new
CyServiceException
(
CyResSvcExcEnum
.
ERROR_NETWORK
);
}
return
importUserDTO
;
}
/** 从excel表中读到数据,有一部分为空值 */
List
<
ExportUserDTO
>
sysUserList
=
CyEpExcelUtil
.
importExcel
(
file
,
2
,
1
,
ExportUserDTO
.
class
);
/** 遍历 从Excel表中读到的数据 抛出不合适的数据 */
//判断整个Excel是不是为空 计算非空数据有多少条
int
information
=
CyCompareToolUtils
.
cmpareInformation
(
sysUserList
);
if
(
information
==
0
)
{
String
errorBefore
=
"Excel文件不可为空,请检查Excel文件是否填写!"
;
errorText
(
errorBefore
,
importUserDTO
,
maps
,
fileName
);
try
{
errorTxt
.
exportTxtPaper
(
maps
,
fileName
);
}
catch
(
Exception
e
)
{
throw
new
CyServiceException
(
CyResSvcExcEnum
.
ERROR_NETWORK
);
}
return
importUserDTO
;
}
else
if
(
information
>
500
)
{
String
errorMore
=
"单次导入数据不可超过500,请检查!"
;
errorText
(
errorMore
,
importUserDTO
,
maps
,
fileName
);
try
{
errorTxt
.
exportTxtPaper
(
maps
,
fileName
);
}
catch
(
Exception
e
)
{
throw
new
CyServiceException
(
CyResSvcExcEnum
.
ERROR_NETWORK
);
}
return
importUserDTO
;
}
else
{
//去除空数据
try
{
sysUserList
=
ThrowNull
(
sysUserList
);
}
catch
(
Exception
e
)
{
throw
new
CyServiceException
(
CyResSvcExcEnum
.
ERROR_NETWORK
);
}
//校验 将错误信息放入maps
int
index
=
3
;
//从第3行开始
SysUser
sysUserDTO
=
new
SysUser
();
sysUserDTO
.
setDeleted
();
List
<
SysUser
>
sysUsers
=
sysUserRepositorys
.
querySysUsers
(
sysUserDTO
);
for
(
ExportUserDTO
sysUser
:
sysUserList
)
{
//判断 是否为空
ErrorDTO
userNull
=
CheckUtil
.
userNotNull
(
sysUser
,
index
);
if
(
userNull
.
getSuccess
()
==
1
)
{
maps
.
add
(
userNull
.
getMap
());
}
//判断 信息是否重复
ErrorDTO
userRepeat
=
CheckUtil
.
userRepeat
(
sysUser
,
index
,
sysUsers
);
if
(
userRepeat
.
getSuccess
()
==
1
)
{
maps
.
add
(
userRepeat
.
getMap
());
}
index
++;
}
}
/** 将 信息插入sys_user */
if
(
sysUserList
.
size
()
>
0
)
{
//用户性别数据字典
List
<
DictData
>
userSex
=
dictionaryService
.
selectByTypes
(
CyDictCons
.
USER_SEX
);
for
(
ExportUserDTO
sysUser
:
sysUserList
)
{
sysUser
.
setIdentity
(
"0"
);
//数据库需要插入的用户信息
//登录名
if
(
sysUser
.
getUsername
()
==
null
)
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
//手机号
if
(
sysUser
.
getPhone
()
==
null
)
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
//人脸信息
if
(
sysUser
.
getFaceAddress
()
==
null
)
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
//所属园区
if
(
sysUser
.
getAddress
()
==
null
)
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
//性别
if
(
sysUser
.
getSex
()
!=
null
)
{
if
(
sysUser
.
getSex
().
equals
(
"男"
))
{
sysUser
.
setSex
(
"0"
);
}
else
if
(
sysUser
.
getSex
().
equals
(
"女"
))
{
sysUser
.
setSex
(
"1"
);
}
else
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
}
else
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
//所属部门
SysDept
sysDept
=
sysDeptRepositorys
.
querySysDeptByName
(
sysUser
.
getDeptId
());
if
(
sysDept
==
null
||
sysDept
.
equals
(
' '
))
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
else
{
sysUser
.
setDeptId
(
sysDept
.
getBusinessId
().
toString
());
}
//字典职位
SysDictData
sysDictData1
=
sysDictDataRepositorys
.
queryDataByDeptIdC
(
sysUser
.
getPosition
());
if
(
sysDictData1
==
null
||
sysDictData1
.
equals
(
' '
))
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
else
{
sysUser
.
setPosition
(
sysDictData1
.
getBusinessId
().
toString
());
}
//字典班次
SysDictData
sysDictData2
=
sysDictDataRepositorys
.
queryDataByDeptIdC
(
sysUser
.
getNltBz
());
if
(
sysDictData2
==
null
||
sysDictData2
.
equals
(
' '
))
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
else
{
sysUser
.
setNltBz
(
sysDictData2
.
getBusinessId
().
toString
());
}
//工作状态
if
(
sysUser
.
getFlag
()
!=
null
)
{
if
(
sysUser
.
getFlag
().
equals
(
"停用"
))
{
sysUser
.
setFlag
(
"0"
);
}
else
if
(
sysUser
.
getFlag
().
equals
(
"正常"
)
||
sysUser
.
getFlag
().
equals
(
"在职"
))
{
sysUser
.
setFlag
(
"1"
);
}
else
if
(
sysUser
.
getFlag
().
equals
(
"离职"
))
{
sysUser
.
setFlag
(
"2"
);
}
else
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
}
else
{
throw
new
CyServiceException
(
500
,
"数据错误"
);
}
//用户类型
sysUser
.
setUserType
(
"0"
);
//身份
sysUser
.
setIdentity
(
"1"
);
sysUserRepositorys
.
addSysUser
(
sysUser
);
}
}
return
importUserDTO
;
}
/**
* @param persionId
* @param userId
...
...
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