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
250f93a6
Commit
250f93a6
authored
May 28, 2018
by
李博今
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加导入内部去重
parent
125e6b82
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
85 additions
and
23 deletions
+85
-23
BClassServiceImpl.java
...isoft/business/bclass/service/impl/BClassServiceImpl.java
+21
-6
BLessonServiceImpl.java
...oft/business/blesson/service/impl/BLessonServiceImpl.java
+9
-3
BRClassStudentServiceImpl.java
...rclassstudent/service/impl/BRClassStudentServiceImpl.java
+9
-2
BRSlStudentServiceImpl.java
...ness/brslstudent/service/impl/BRSlStudentServiceImpl.java
+9
-4
BSlServiceImpl.java
...org/rcisoft/business/bsl/service/impl/BSlServiceImpl.java
+10
-1
BStudentServiceImpl.java
...t/business/bstudent/service/impl/BStudentServiceImpl.java
+8
-2
BTeacherServiceImpl.java
...t/business/bteacher/service/impl/BTeacherServiceImpl.java
+8
-3
ExcelUtil.java
src/main/java/org/rcisoft/core/util/ExcelUtil.java
+9
-0
application-dev.yml
src/main/resources/application-dev.yml
+2
-2
business-class.xls
src/main/resources/excel-template/business-class.xls
+0
-0
class.xls
src/main/resources/excel-template/class.xls
+0
-0
sl.xls
src/main/resources/excel-template/sl.xls
+0
-0
student-class.xls
src/main/resources/excel-template/student-class.xls
+0
-0
student-sl.xls
src/main/resources/excel-template/student-sl.xls
+0
-0
No files found.
src/main/java/org/rcisoft/business/bclass/service/impl/BClassServiceImpl.java
View file @
250f93a6
...
@@ -145,7 +145,7 @@ public class BClassServiceImpl implements BClassService {
...
@@ -145,7 +145,7 @@ public class BClassServiceImpl implements BClassService {
public
PersistModel
administrativeImportExcel
(
HSSFWorkbook
hwb
,
String
token
)
throws
IOException
{
public
PersistModel
administrativeImportExcel
(
HSSFWorkbook
hwb
,
String
token
)
throws
IOException
{
ArrayList
<
BClass
>
bClasses
=
new
ArrayList
<
BClass
>();
ArrayList
<
BClass
>
bClasses
=
new
ArrayList
<
BClass
>();
ArrayList
<
String
>
repeatCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
repeatCode
=
new
ArrayList
<
String
>();
String
innerRepeatResult
=
""
;
String
[]
headers
=
{
"班级编号"
,
"学号"
,
"所属年级"
};
String
[]
headers
=
{
"班级编号"
,
"学号"
,
"所属年级"
};
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
,
1
);
//获取excel数据
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
,
1
);
//获取excel数据
//判断年级是否存在
//判断年级是否存在
...
@@ -155,7 +155,8 @@ public class BClassServiceImpl implements BClassService {
...
@@ -155,7 +155,8 @@ public class BClassServiceImpl implements BClassService {
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
);
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
);
}
}
for
(
String
[]
value:
values
){
//将数据封装到entity
//外循环
outLoop
:
for
(
String
[]
value:
values
){
//将数据封装到entity
BClass
bClass
=
null
;
BClass
bClass
=
null
;
BClass
b
=
new
BClass
(
value
[
0
]);
BClass
b
=
new
BClass
(
value
[
0
]);
if
(
value
[
0
]==
null
||
value
[
0
].
equals
(
""
)||
value
[
1
]==
null
||
value
[
1
].
equals
(
""
)){
if
(
value
[
0
]==
null
||
value
[
0
].
equals
(
""
)||
value
[
1
]==
null
||
value
[
1
].
equals
(
""
)){
...
@@ -172,6 +173,13 @@ public class BClassServiceImpl implements BClassService {
...
@@ -172,6 +173,13 @@ public class BClassServiceImpl implements BClassService {
valuesGrade
.
add
(
value
[
2
]);
valuesGrade
.
add
(
value
[
2
]);
continue
;
continue
;
}
}
//表中去重
for
(
BClass
bClass1
:
bClasses
){
if
(
b1
.
getCode
().
equals
(
bClass1
.
getCode
())){
innerRepeatResult
+=
"编号 "
+
b1
.
getCode
()
+
" 在Excel中重复出现,除第一条以外的数据插入失败 "
;
continue
outLoop
;
}
}
bClass
=
new
BClass
(
value
[
0
],
value
[
1
]);
bClass
=
new
BClass
(
value
[
0
],
value
[
1
]);
bClass
.
setGradeCode
(
value
[
2
]);
bClass
.
setGradeCode
(
value
[
2
]);
...
@@ -197,7 +205,7 @@ public class BClassServiceImpl implements BClassService {
...
@@ -197,7 +205,7 @@ public class BClassServiceImpl implements BClassService {
result
+=
"以下班级的所属年级信息不存在:"
+
JSON
.
toJSONString
(
valuesGrade
)+
"。"
;
result
+=
"以下班级的所属年级信息不存在:"
+
JSON
.
toJSONString
(
valuesGrade
)+
"。"
;
}
}
return
new
PersistModel
(
line
,
result
);
return
new
PersistModel
(
line
,
result
+
innerRepeatResult
);
}
}
@Override
@Override
...
@@ -205,7 +213,7 @@ public class BClassServiceImpl implements BClassService {
...
@@ -205,7 +213,7 @@ public class BClassServiceImpl implements BClassService {
ArrayList
<
BClass
>
bClasses
=
new
ArrayList
<
BClass
>();
ArrayList
<
BClass
>
bClasses
=
new
ArrayList
<
BClass
>();
ArrayList
<
String
>
repeatCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
repeatCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
AgencyCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
AgencyCode
=
new
ArrayList
<
String
>();
String
innerRepeatResult
=
""
;
String
[]
headers
=
{
"班级编号"
,
"班级名称"
,
"所属年级"
,
"教学单位"
};
String
[]
headers
=
{
"班级编号"
,
"班级名称"
,
"所属年级"
,
"教学单位"
};
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
,
1
);
//获取excel数据
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
,
1
);
//获取excel数据
//判断年级是否存在
//判断年级是否存在
...
@@ -215,7 +223,7 @@ public class BClassServiceImpl implements BClassService {
...
@@ -215,7 +223,7 @@ public class BClassServiceImpl implements BClassService {
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
);
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
);
}
}
for
(
String
[]
value:
values
){
//将数据封装到entity
outLoop
:
for
(
String
[]
value:
values
){
//将数据封装到entity
BClass
bClass
=
null
;
BClass
bClass
=
null
;
BClass
b
=
new
BClass
(
value
[
0
]);
BClass
b
=
new
BClass
(
value
[
0
]);
if
(
value
[
0
]==
null
||
value
[
0
].
equals
(
""
)||
value
[
1
]==
null
||
value
[
1
].
equals
(
""
)){
if
(
value
[
0
]==
null
||
value
[
0
].
equals
(
""
)||
value
[
1
]==
null
||
value
[
1
].
equals
(
""
)){
...
@@ -246,6 +254,13 @@ public class BClassServiceImpl implements BClassService {
...
@@ -246,6 +254,13 @@ public class BClassServiceImpl implements BClassService {
bClass
.
setType
(
"1"
);
bClass
.
setType
(
"1"
);
bClass
.
setCommonBusinessId
();
bClass
.
setCommonBusinessId
();
UserUtil
.
setCurrentPersistOperation
(
bClass
);
UserUtil
.
setCurrentPersistOperation
(
bClass
);
//表中去重
for
(
BClass
bClass1
:
bClasses
){
if
(
b1
.
getBusinessId
().
equals
(
bClass1
.
getBusinessId
())){
innerRepeatResult
+=
"班级编号 "
+
b1
.
getBusinessId
()
+
" 在Excel中重复出现,除第一条以外的数据插入失败 "
;
continue
outLoop
;
}
}
if
(!
bClasses
.
contains
(
bClass
)){
if
(!
bClasses
.
contains
(
bClass
)){
bClasses
.
add
(
bClass
);
bClasses
.
add
(
bClass
);
...
@@ -269,7 +284,7 @@ public class BClassServiceImpl implements BClassService {
...
@@ -269,7 +284,7 @@ public class BClassServiceImpl implements BClassService {
result
+=
"以下教学单位不存在:"
+
JSON
.
toJSONString
(
AgencyCode
)+
"。"
;
result
+=
"以下教学单位不存在:"
+
JSON
.
toJSONString
(
AgencyCode
)+
"。"
;
}
}
return
new
PersistModel
(
line
,
result
);
return
new
PersistModel
(
line
,
result
+
innerRepeatResult
);
}
}
@Override
@Override
...
...
src/main/java/org/rcisoft/business/blesson/service/impl/BLessonServiceImpl.java
View file @
250f93a6
...
@@ -115,7 +115,8 @@ public class BLessonServiceImpl implements BLessonService {
...
@@ -115,7 +115,8 @@ public class BLessonServiceImpl implements BLessonService {
ArrayList
<
String
>
direction
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
direction
=
new
ArrayList
<
String
>();
List
<
String
>
isChinese
=
new
ArrayList
<>();
List
<
String
>
isChinese
=
new
ArrayList
<>();
List
<
String
>
isNegative
=
new
ArrayList
<>();
List
<
String
>
isNegative
=
new
ArrayList
<>();
List
<
String
>
currentlyCode
=
new
ArrayList
<>();
String
innerRepeatResult
=
""
;
String
[]
headers
=
{
"课程编号"
,
"课程名称"
,
"课程方向编号"
,
"学时"
,
"学分"
};
String
[]
headers
=
{
"课程编号"
,
"课程名称"
,
"课程方向编号"
,
"学时"
,
"学分"
};
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
,
1
);
//获取excel数据
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
,
1
);
//获取excel数据
...
@@ -159,8 +160,13 @@ public class BLessonServiceImpl implements BLessonService {
...
@@ -159,8 +160,13 @@ public class BLessonServiceImpl implements BLessonService {
bLesson
=
new
BLesson
(
value
[
0
],
value
[
1
],
value
[
3
],
value
[
4
]);
bLesson
=
new
BLesson
(
value
[
0
],
value
[
1
],
value
[
3
],
value
[
4
]);
bLesson
.
setDefaultUrl
(
global
.
getDEFAULT_COURSE_LOCATION
());
bLesson
.
setDefaultUrl
(
global
.
getDEFAULT_COURSE_LOCATION
());
UserUtil
.
setCurrentPersistOperation
(
bLesson
);
UserUtil
.
setCurrentPersistOperation
(
bLesson
);
//表中去重
if
(
currentlyCode
.
contains
(
bLesson
.
getCode
())){
innerRepeatResult
+=
"编号 "
+
value
[
1
]
+
" 在Excel中重复出现,除第一条以外的数据插入失败 \n"
;
continue
;
}
if
(!
lessons
.
contains
(
bLesson
)){
if
(!
lessons
.
contains
(
bLesson
)){
currentlyCode
.
add
(
bLesson
.
getCode
());
lessons
.
add
(
bLesson
);
lessons
.
add
(
bLesson
);
BLessonDirection
bDirection
=
new
BLessonDirection
();
BLessonDirection
bDirection
=
new
BLessonDirection
();
...
@@ -203,7 +209,7 @@ public class BLessonServiceImpl implements BLessonService {
...
@@ -203,7 +209,7 @@ public class BLessonServiceImpl implements BLessonService {
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
.
getCode
(),
result
);
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
.
getCode
(),
result
);
}
}
return
new
PersistModel
(
1
,
result
);
return
new
PersistModel
(
1
,
result
+
innerRepeatResult
);
}
}
...
...
src/main/java/org/rcisoft/business/brclassstudent/service/impl/BRClassStudentServiceImpl.java
View file @
250f93a6
...
@@ -86,7 +86,8 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
...
@@ -86,7 +86,8 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
ArrayList
<
String
>
classCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
classCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
repeatCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
repeatCode
=
new
ArrayList
<
String
>();
List
<
String
>
valuesGrade
=
new
ArrayList
<>();
List
<
String
>
valuesGrade
=
new
ArrayList
<>();
List
<
String
>
currenty
=
new
ArrayList
<>();
String
innerRepeatResult
=
""
;
String
[]
headers
=
{
"班级编号"
,
"学号"
};
String
[]
headers
=
{
"班级编号"
,
"学号"
};
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
,
1
);
//获取excel数据
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
,
1
);
//获取excel数据
...
@@ -128,10 +129,16 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
...
@@ -128,10 +129,16 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
//1.4 构造学生班级信息
//1.4 构造学生班级信息
brClassStudent
=
new
BRClassStudent
(
value
[
0
],
value
[
1
]);
brClassStudent
=
new
BRClassStudent
(
value
[
0
],
value
[
1
]);
if
(
currenty
.
contains
(
brClassStudent
.
toString
())){
innerRepeatResult
+=
"班级编号,学号分别为 "
+
value
[
0
]
+
" "
+
value
[
1
]
+
" 的数据,在Excel中重复出现,除第一条以外的数据插入失败 \n"
;
continue
;
}
currenty
.
add
(
brClassStudent
.
toString
());
brClassStudent
.
setCommonBusinessId
();
brClassStudent
.
setCommonBusinessId
();
//UserUtils.setCurrentPersistOperation(brClassStudent);
//UserUtils.setCurrentPersistOperation(brClassStudent);
if
(!
brClassStudents
.
contains
(
brClassStudent
)){
if
(!
brClassStudents
.
contains
(
brClassStudent
)){
brClassStudents
.
add
(
brClassStudent
);
brClassStudents
.
add
(
brClassStudent
);
}
}
}
}
...
@@ -175,7 +182,7 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
...
@@ -175,7 +182,7 @@ public class BRClassStudentServiceImpl implements BRClassStudentService {
int
l1
=
MapUtils
.
getInteger
(
map
,
"result"
,-
2
);
int
l1
=
MapUtils
.
getInteger
(
map
,
"result"
,-
2
);
if
(
l1
<=
0
)
if
(
l1
<=
0
)
throw
new
ServiceException
(
ResultServiceEnums
.
UPDATE_STUDENT_NUM_ERROR
);
throw
new
ServiceException
(
ResultServiceEnums
.
UPDATE_STUDENT_NUM_ERROR
);
return
new
PersistModel
(
1
,
result
.
toString
());
return
new
PersistModel
(
1
,
result
.
toString
()
+
innerRepeatResult
);
}
}
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
...
...
src/main/java/org/rcisoft/business/brslstudent/service/impl/BRSlStudentServiceImpl.java
View file @
250f93a6
...
@@ -87,7 +87,8 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
...
@@ -87,7 +87,8 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
ArrayList
<
String
>
studentCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
studentCode
=
new
ArrayList
<
String
>();
/*ArrayList<String> gitlabP = new ArrayList<String>();
/*ArrayList<String> gitlabP = new ArrayList<String>();
ArrayList<String> gitlabUser = new ArrayList<String>();*/
ArrayList<String> gitlabUser = new ArrayList<String>();*/
String
innerRepeatResult
=
""
;
List
<
String
>
currently
=
new
ArrayList
<>();
String
[]
headers
=
{
"课序号"
,
"学号"
};
String
[]
headers
=
{
"课序号"
,
"学号"
};
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
,
1
);
//获取excel数据
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
,
1
);
//获取excel数据
...
@@ -144,9 +145,14 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
...
@@ -144,9 +145,14 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
//3.封装学生选课信息
//3.封装学生选课信息
brSlStudent
=
new
BRSlStudent
(
value
[
1
],
value
[
0
]);
brSlStudent
=
new
BRSlStudent
(
value
[
1
],
value
[
0
]);
if
(
currently
.
contains
(
brSlStudent
.
toString
())){
innerRepeatResult
+=
"课序号,学号分别为 "
+
value
[
0
]
+
" "
+
value
[
1
]
+
" 的数据,在Excel中重复出现,除第一条以外的数据插入失败 \n"
;
continue
;
}
currently
.
add
(
brSlStudent
.
toString
());
brSlStudent
.
setBusinessId
(
IdGen
.
uuid
());
brSlStudent
.
setBusinessId
(
IdGen
.
uuid
());
if
(!
brSlStudents
.
contains
(
brSlStudent
)){
if
(!
brSlStudents
.
contains
(
brSlStudent
)){
brSlStudents
.
add
(
brSlStudent
);
brSlStudents
.
add
(
brSlStudent
);
}
}
}
}
...
@@ -180,12 +186,11 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
...
@@ -180,12 +186,11 @@ public class BRSlStudentServiceImpl implements BRSlStudentService {
}*/
}*/
result
+=
nullResult
;
result
+=
nullResult
;
if
(
brSlStudents
.
size
()<
1
){
if
(
brSlStudents
.
size
()<
1
){
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DB_INSERT_ERROR
.
getCode
(),
result
);
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DB_INSERT_ERROR
.
getCode
(),
result
);
}
}
return
new
PersistModel
(
1
,
result
+
nullResult
.
toString
());
return
new
PersistModel
(
1
,
result
+
nullResult
.
toString
()
+
innerRepeatResult
);
}
}
static
String
sub
(
String
str
)
{
static
String
sub
(
String
str
)
{
...
...
src/main/java/org/rcisoft/business/bsl/service/impl/BSlServiceImpl.java
View file @
250f93a6
...
@@ -156,6 +156,8 @@ public class BSlServiceImpl implements BSlService {
...
@@ -156,6 +156,8 @@ public class BSlServiceImpl implements BSlService {
ArrayList
<
String
>
lessonCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
lessonCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
teacherCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
teacherCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
termCode
=
new
ArrayList
<
String
>();
ArrayList
<
String
>
termCode
=
new
ArrayList
<
String
>();
List
<
String
>
currentlyCode
=
new
ArrayList
<>();
String
innerRepeatResult
=
""
;
//ArrayList<String> direction = new ArrayList<String>();
//ArrayList<String> direction = new ArrayList<String>();
//List<BSl> repeatSl = new ArrayList<>();
//List<BSl> repeatSl = new ArrayList<>();
Map
map
=
new
HashMap
();
Map
map
=
new
HashMap
();
...
@@ -218,11 +220,18 @@ public class BSlServiceImpl implements BSlService {
...
@@ -218,11 +220,18 @@ public class BSlServiceImpl implements BSlService {
bSl
.
setSlCoverUrl
(
bLesson
.
getDefaultUrl
());
bSl
.
setSlCoverUrl
(
bLesson
.
getDefaultUrl
());
bSl
.
setCredits
(
bLesson
.
getCredits
());
bSl
.
setCredits
(
bLesson
.
getCredits
());
bSl
.
setClassHour
(
bLesson
.
getClassHour
());
bSl
.
setClassHour
(
bLesson
.
getClassHour
());
if
(
currentlyCode
.
contains
(
bSl
.
getCode
())){
innerRepeatResult
+=
"编号 "
+
bSl
.
getCode
()
+
" 在Excel中重复出现,除第一条以外的数据插入失败 \n"
;
continue
;
}
currentlyCode
.
add
(
bSl
.
getCode
());
UserUtil
.
setCurrentPersistOperation
(
bSl
);
UserUtil
.
setCurrentPersistOperation
(
bSl
);
BLessonDirection
bDirection
=
new
BLessonDirection
();
BLessonDirection
bDirection
=
new
BLessonDirection
();
if
(!
bSls
.
contains
(
bSl
))
{
if
(!
bSls
.
contains
(
bSl
))
{
bSls
.
add
(
bSl
);
bSls
.
add
(
bSl
);
bDirection
.
setDirectionId
(
bLesson
.
getDirectionId
());
bDirection
.
setDirectionId
(
bLesson
.
getDirectionId
());
bDirection
.
setBusinessId
(
IdGen
.
uuid
());
bDirection
.
setBusinessId
(
IdGen
.
uuid
());
...
@@ -269,7 +278,7 @@ public class BSlServiceImpl implements BSlService {
...
@@ -269,7 +278,7 @@ public class BSlServiceImpl implements BSlService {
if
(
bSls
.
size
()<
1
){
if
(
bSls
.
size
()<
1
){
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DB_INSERT_ERROR
.
getCode
(),
result
);
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DB_INSERT_ERROR
.
getCode
(),
result
);
}
}
return
new
PersistModel
(
1
,
result
);
return
new
PersistModel
(
1
,
result
+
innerRepeatResult
);
}
}
@Override
@Override
...
...
src/main/java/org/rcisoft/business/bstudent/service/impl/BStudentServiceImpl.java
View file @
250f93a6
...
@@ -124,7 +124,8 @@ public class BStudentServiceImpl implements BStudentService {
...
@@ -124,7 +124,8 @@ public class BStudentServiceImpl implements BStudentService {
@Override
@Override
public
PersistModel
importExcel
(
HSSFWorkbook
hwb
,
String
token
)
throws
IOException
{
public
PersistModel
importExcel
(
HSSFWorkbook
hwb
,
String
token
)
throws
IOException
{
ArrayList
<
BStudent
>
students
=
new
ArrayList
<
BStudent
>();
ArrayList
<
BStudent
>
students
=
new
ArrayList
<
BStudent
>();
List
<
String
>
currentlyCode
=
new
ArrayList
<>();
String
innerRepeatResult
=
""
;
ArrayList
<
SysUser
>
users
=
new
ArrayList
<
SysUser
>();
ArrayList
<
SysUser
>
users
=
new
ArrayList
<
SysUser
>();
ArrayList
<
UserRole
>
userRoles
=
new
ArrayList
<
UserRole
>();
ArrayList
<
UserRole
>
userRoles
=
new
ArrayList
<
UserRole
>();
List
<
String
>
valuesIncomplete
=
new
ArrayList
<>();
List
<
String
>
valuesIncomplete
=
new
ArrayList
<>();
...
@@ -235,7 +236,12 @@ public class BStudentServiceImpl implements BStudentService {
...
@@ -235,7 +236,12 @@ public class BStudentServiceImpl implements BStudentService {
bStudent
.
setGradeCode
(
value
[
3
]);
bStudent
.
setGradeCode
(
value
[
3
]);
bStudent
.
setRemarks
(
value
[
4
]);
bStudent
.
setRemarks
(
value
[
4
]);
UserUtil
.
setCurrentPersistOperation
(
bStudent
);
UserUtil
.
setCurrentPersistOperation
(
bStudent
);
if
(
currentlyCode
.
contains
(
bStudent
.
getCode
())){
innerRepeatResult
+=
"编号 "
+
value
[
0
]
+
" 在Excel中重复出现,除第一条以外的数据插入失败 \n"
;
continue
;
}
if
(!
students
.
contains
(
bStudent
))
{
if
(!
students
.
contains
(
bStudent
))
{
currentlyCode
.
add
(
bStudent
.
getCode
());
students
.
add
(
bStudent
);
students
.
add
(
bStudent
);
users
.
add
(
user
);
users
.
add
(
user
);
userRoles
.
add
(
userRole
);
userRoles
.
add
(
userRole
);
...
@@ -281,7 +287,7 @@ public class BStudentServiceImpl implements BStudentService {
...
@@ -281,7 +287,7 @@ public class BStudentServiceImpl implements BStudentService {
if
(
valuesOK
.
size
()<
1
){
if
(
valuesOK
.
size
()<
1
){
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DB_INSERT_ERROR
.
getCode
(),
result
);
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DB_INSERT_ERROR
.
getCode
(),
result
);
}
}
return
new
PersistModel
(
1
,
result
);
return
new
PersistModel
(
1
,
result
+
innerRepeatResult
);
...
...
src/main/java/org/rcisoft/business/bteacher/service/impl/BTeacherServiceImpl.java
View file @
250f93a6
...
@@ -85,8 +85,8 @@ public class BTeacherServiceImpl implements BTeacherService {
...
@@ -85,8 +85,8 @@ public class BTeacherServiceImpl implements BTeacherService {
public
PersistModel
importExcel
(
HSSFWorkbook
hwb
,
String
token
)
throws
IOException
,
InterruptedException
{
public
PersistModel
importExcel
(
HSSFWorkbook
hwb
,
String
token
)
throws
IOException
,
InterruptedException
{
ArrayList
<
BTeacher
>
teachers
=
new
ArrayList
<
BTeacher
>();
ArrayList
<
BTeacher
>
teachers
=
new
ArrayList
<
BTeacher
>();
ArrayList
<
SysUser
>
users
=
new
ArrayList
<
SysUser
>();
ArrayList
<
SysUser
>
users
=
new
ArrayList
<
SysUser
>();
String
innerRepeatResult
=
""
;
List
<
String
>
currentlyCode
=
new
ArrayList
<>();
ArrayList
<
UserRole
>
userRoles
=
new
ArrayList
<
UserRole
>();
ArrayList
<
UserRole
>
userRoles
=
new
ArrayList
<
UserRole
>();
String
[]
headers
=
{
"教师工号"
,
"教师姓名"
,
"性别"
,
"教学单位编号"
,
"备注"
};
String
[]
headers
=
{
"教师工号"
,
"教师姓名"
,
"性别"
,
"教学单位编号"
,
"备注"
};
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
true
,
1
);
//获取excel数据
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
true
,
1
);
//获取excel数据
...
@@ -192,7 +192,12 @@ public class BTeacherServiceImpl implements BTeacherService {
...
@@ -192,7 +192,12 @@ public class BTeacherServiceImpl implements BTeacherService {
BTeacher
bTeacher
=
new
BTeacher
(
value
[
0
],
value
[
3
]);
BTeacher
bTeacher
=
new
BTeacher
(
value
[
0
],
value
[
3
]);
bTeacher
.
setRemarks
(
value
[
4
]);
bTeacher
.
setRemarks
(
value
[
4
]);
UserUtil
.
setCurrentPersistOperation
(
bTeacher
);
UserUtil
.
setCurrentPersistOperation
(
bTeacher
);
if
(
currentlyCode
.
contains
(
bTeacher
.
getCode
())){
innerRepeatResult
+=
"编号 "
+
bTeacher
.
getCode
()
+
" 在Excel中重复出现,除第一条以外的数据插入失败 "
;
continue
;
}
if
(!
teachers
.
contains
(
bTeacher
))
{
if
(!
teachers
.
contains
(
bTeacher
))
{
currentlyCode
.
add
(
bTeacher
.
getCode
());
teachers
.
add
(
bTeacher
);
teachers
.
add
(
bTeacher
);
users
.
add
(
user
);
users
.
add
(
user
);
userRoles
.
add
(
userRole
);
userRoles
.
add
(
userRole
);
...
@@ -234,7 +239,7 @@ public class BTeacherServiceImpl implements BTeacherService {
...
@@ -234,7 +239,7 @@ public class BTeacherServiceImpl implements BTeacherService {
}
}
return
new
PersistModel
(
1
,
result
);
return
new
PersistModel
(
1
,
result
+
innerRepeatResult
);
}
}
...
...
src/main/java/org/rcisoft/core/util/ExcelUtil.java
View file @
250f93a6
...
@@ -106,6 +106,15 @@ public class ExcelUtil {
...
@@ -106,6 +106,15 @@ public class ExcelUtil {
return
values
;
return
values
;
}
}
// public static boolean isRepeat(List<String[]> totalValue,String[] value){
// for(int i = 0 ; i < totalValue.size() ; i++){
// for(int j = 0 ; j < value.length ; j++){
// if(((String)value[j]).equals((String)totalValue.get(i)[j])){
// return true;
// }
// }
// }
// }
/**
/**
* 重复数据检查
* 重复数据检查
...
...
src/main/resources/application-dev.yml
View file @
250f93a6
...
@@ -11,8 +11,8 @@ server:
...
@@ -11,8 +11,8 @@ server:
# org.springframework.web: DEBUG
# org.springframework.web: DEBUG
druid
:
druid
:
#url: jdbc:mysql://192.168.1.125:13318/new_
edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
url
:
jdbc:mysql://127.0.0.1:3306/
edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
url
:
jdbc:mysql://120.52.179.75:13318/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
#
url: jdbc:mysql://120.52.179.75:13318/edu_db?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false
username
:
root
username
:
root
password
:
123456
password
:
123456
initial-size
:
1
initial-size
:
1
...
...
src/main/resources/excel-template/business-class.xls
View file @
250f93a6
No preview for this file type
src/main/resources/excel-template/class.xls
View file @
250f93a6
No preview for this file type
src/main/resources/excel-template/sl.xls
View file @
250f93a6
No preview for this file type
src/main/resources/excel-template/student-class.xls
View file @
250f93a6
No preview for this file type
src/main/resources/excel-template/student-sl.xls
View file @
250f93a6
No preview for this file type
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