Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
education
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
李丛阳
education
Commits
a209b953
Commit
a209b953
authored
Apr 27, 2018
by
刘子正
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
教师excel导入 新增导入教学单位编号
parent
6d240af5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
13 deletions
+31
-13
BTeacherServiceImpl.java
...t/business/bteacher/service/impl/BTeacherServiceImpl.java
+24
-11
SysUserMapper.java
src/main/java/org/rcisoft/sys/user/dao/SysUserMapper.java
+7
-2
No files found.
src/main/java/org/rcisoft/business/bteacher/service/impl/BTeacherServiceImpl.java
View file @
a209b953
...
...
@@ -82,8 +82,8 @@ public class BTeacherServiceImpl implements BTeacherService {
ArrayList
<
UserRole
>
userRoles
=
new
ArrayList
<
UserRole
>();
String
[]
headers
=
{
"教师工号"
,
"教师姓名"
,
"性别"
,
"邮箱"
};
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
fals
e
);
//获取excel数据
String
[]
headers
=
{
"教师工号"
,
"教师姓名"
,
"性别"
,
"邮箱"
,
"教学单位编号"
};
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
tru
e
);
//获取excel数据
if
(
values
.
size
()
==
0
){
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
);
}
...
...
@@ -92,6 +92,7 @@ public class BTeacherServiceImpl implements BTeacherService {
List
<
String
>
valuesRepeat
=
new
ArrayList
<>();
List
<
String
>
valuesShort
=
new
ArrayList
<>();
List
<
String
>
valuesEmailExist
=
new
ArrayList
<>();
List
<
String
>
valuesAgencyExist
=
new
ArrayList
<>();
for
(
String
[]
value
:
values
)
{
...
...
@@ -126,6 +127,14 @@ public class BTeacherServiceImpl implements BTeacherService {
continue
;
}
//判断4:教师的所属教学单位是否存在,存在才能添加;
SysUser
user3
=
new
SysUser
();
user3
.
setAgencyCode
(
value
[
4
]);
if
(
sysUserMapper
.
checkTeacherAgency
(
user3
).
size
()
==
0
){
valuesAgencyExist
.
add
(
value
[
4
]);
continue
;
}
//合法:通过了三次判断,证明可建立该用户
valuesOK
.
add
(
value
);
...
...
@@ -137,8 +146,9 @@ public class BTeacherServiceImpl implements BTeacherService {
value
[
2
]
=
""
;
//1. 添加user
SysUser
user
=
new
SysUser
(
value
[
0
],
passwordEncoder
.
encode
(
global
.
getDEFAULT_PASSWORD
()),
value
[
1
],
value
[
2
]);
//
学
号,密码,姓名,性别;
SysUser
user
=
new
SysUser
(
value
[
0
],
passwordEncoder
.
encode
(
global
.
getDEFAULT_PASSWORD
()),
value
[
1
],
value
[
2
]);
//
教师工
号,密码,姓名,性别;
user
.
setEmail
(
value
[
3
]);
user
.
setAgencyCode
(
value
[
4
]);
//教学单位编号
UserUtil
.
setCurrentPersistOperation
(
user
);
//2 创建gitlab账户
/*GitUser gitUser = new GitUser();
...
...
@@ -188,6 +198,9 @@ public class BTeacherServiceImpl implements BTeacherService {
if
(
valuesEmailExist
.
size
()>
0
){
result
+=
"以下教师邮箱已注册或格式不正确:"
+
JSON
.
toJSONString
(
valuesEmailExist
)+
"。"
;
}
if
(
valuesAgencyExist
.
size
()>
0
){
result
+=
"以下教师的所属教学单位不存在:"
+
JSON
.
toJSONString
(
valuesAgencyExist
)+
"。"
;
}
if
(
valuesOK
.
size
()<
1
){
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DB_INSERT_ERROR
.
getCode
(),
result
);
...
...
@@ -227,13 +240,13 @@ public class BTeacherServiceImpl implements BTeacherService {
BeanUtils
.
copyProperties
((
DataEntity
)
model
,
(
DataEntity
)
user
);
if
(
model
.
getBusinessId
()
==
null
)
{
if
(
sysUserMapper
.
selectOne
(
new
SysUser
(
model
.
getCode
(),
"0"
,
"1"
))
!=
null
)
throw
new
ServiceException
(
ResultServiceEnums
.
TEACHER_EXISTS
);
{
throw
new
ServiceException
(
ResultServiceEnums
.
TEACHER_EXISTS
);}
SysUser
user1
=
new
SysUser
();
user1
.
setEmail
(
model
.
getEmail
());
user1
.
setDelFlag
(
"0"
);
user1
.
setFlag
(
"1"
);
if
(
sysUserMapper
.
selectOne
(
user1
)!=
null
)
throw
new
ServiceException
(
ResultServiceEnums
.
EMAIL_EXISTS
);
{
throw
new
ServiceException
(
ResultServiceEnums
.
EMAIL_EXISTS
);}
//1添加用户
user
.
setHeadPic
(
global
.
getDEFAULT_TEACHER_LOCATION
());
UserUtil
.
setCurrentPersistOperation
(
user
);
...
...
@@ -249,13 +262,13 @@ public class BTeacherServiceImpl implements BTeacherService {
line
=
bTeacherRepository
.
insertSelective
(
model
);
if
(
line1
!=
line
)
throw
new
ServiceException
(
ResultServiceEnums
.
INSERT_ERROR
);
{
throw
new
ServiceException
(
ResultServiceEnums
.
INSERT_ERROR
);}
}
else
{
UserUtil
.
setCurrentMergeOperation
(
model
);
line
=
bTeacherRepository
.
updateByPrimaryKeySelective
(
model
);
String
uid
=
sysUserMapper
.
selectUserIdByStuOrTeaId
(
model
.
getBusinessId
(),
"b_teacher"
);
if
(
uid
==
null
)
throw
new
ServiceException
(
ResultServiceEnums
.
STUDENT_NOT_EXISTS
);
{
throw
new
ServiceException
(
ResultServiceEnums
.
STUDENT_NOT_EXISTS
);}
userService
.
updateUser
(
user
,
uid
,
line
);
}
return
new
PersistModel
(
line
);
...
...
@@ -264,13 +277,13 @@ public class BTeacherServiceImpl implements BTeacherService {
private
Map
<
String
,
Object
>
queryParamHandler
(
BTeacher
model
)
{
Map
param
=
new
HashMap
<
String
,
Object
>();
if
(
model
.
getName
()
!=
null
)
param
.
put
(
"name"
,
"%"
+
model
.
getName
()
+
"%"
);
{
param
.
put
(
"name"
,
"%"
+
model
.
getName
()
+
"%"
);}
else
param
.
put
(
"name"
,
"%%"
);
{
param
.
put
(
"name"
,
"%%"
);}
if
(
model
.
getCode
()
!=
null
)
param
.
put
(
"code"
,
"%"
+
model
.
getCode
()
+
"%"
);
{
param
.
put
(
"code"
,
"%"
+
model
.
getCode
()
+
"%"
);}
else
param
.
put
(
"code"
,
"%%"
);
{
param
.
put
(
"code"
,
"%%"
);}
param
.
put
(
"teacherCode"
,
model
.
getTeacherCode
());
return
param
;
}
...
...
src/main/java/org/rcisoft/sys/user/dao/SysUserMapper.java
View file @
a209b953
...
...
@@ -2,6 +2,7 @@ package org.rcisoft.sys.user.dao;
import
org.apache.ibatis.annotations.*
;
import
org.rcisoft.business.bagency.entity.BAgency
;
import
org.rcisoft.core.base.BaseMapper
;
import
org.rcisoft.sys.user.entity.SysUser
;
import
org.rcisoft.sys.user.entity.UserRole
;
...
...
@@ -25,9 +26,9 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
List
<
SysUser
>
queryUserByName
(
String
username
);
@Insert
(
"<script>INSERT INTO s_user"
+
"(create_date,update_date,create_by,update_by,remarks,del_flag,flag,business_id,login_name,password,name,sex,git_lab_id,git_lab_username,git_lab_impression_token,head_pic,email)VALUES"
+
"(create_date,update_date,create_by,update_by,remarks,del_flag,flag,business_id,login_name,password,name,sex,git_lab_id,git_lab_username,git_lab_impression_token,head_pic,email
,agency_code
)VALUES"
+
"<foreach collection=\"list\" item=\"item\" separator=\",\">"
+
"( #{item.createDate},#{item.updateDate},#{item.createBy},#{item.updateBy},#{item.remarks},#{item.delFlag},#{item.flag},#{item.businessId},#{item.loginName},#{item.password},#{item.name},#{item.sex},#{item.gitLabId},#{item.gitLabUsername},#{item.gitLabImpressionToken},#{item.headPic},#{item.email})"
+
"( #{item.createDate},#{item.updateDate},#{item.createBy},#{item.updateBy},#{item.remarks},#{item.delFlag},#{item.flag},#{item.businessId},#{item.loginName},#{item.password},#{item.name},#{item.sex},#{item.gitLabId},#{item.gitLabUsername},#{item.gitLabImpressionToken},#{item.headPic},#{item.email}
,#{item.agencyCode}
)"
+
"</foreach></script>"
)
int
insertList
(
List
<
SysUser
>
users
);
...
...
@@ -82,4 +83,8 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
@Select
(
"<script>select agency_code from s_user where business_id = #{businessId}</script>"
)
String
queryAgencyCodeByBusinessId
(
String
businessId
);
@Select
(
"select * from b_agency where code = #{agencyCode} and del_flag = 0 and flag = 1"
)
List
<
BAgency
>
checkTeacherAgency
(
SysUser
sysUser
);
}
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