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
4496d0de
Commit
4496d0de
authored
May 02, 2018
by
刘子正
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
班级导入分为企业版和行政班
parent
38a6912c
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
193 additions
and
8 deletions
+193
-8
BClassController.java
.../rcisoft/business/bclass/controller/BClassController.java
+26
-1
BClassRepository.java
...ava/org/rcisoft/business/bclass/dao/BClassRepository.java
+12
-2
BClassService.java
...va/org/rcisoft/business/bclass/service/BClassService.java
+20
-2
BClassServiceImpl.java
...isoft/business/bclass/service/impl/BClassServiceImpl.java
+133
-2
BStudentRepository.java
...org/rcisoft/business/bstudent/dao/BStudentRepository.java
+2
-1
administrative-class.xls
src/main/resources/excel-template/administrative-class.xls
+0
-0
business-class.xls
src/main/resources/excel-template/business-class.xls
+0
-0
student-class.xls
src/main/resources/excel-template/student-class.xls
+0
-0
teacher.xls
src/main/resources/excel-template/teacher.xls
+0
-0
No files found.
src/main/java/org/rcisoft/business/bclass/controller/BClassController.java
View file @
4496d0de
...
...
@@ -72,7 +72,7 @@ public class BClassController extends PaginationController<BClass> {
MessageConstant
.
MESSAGE_ALERT_ERROR
,
id
);
}
/**
@ApiOperation(value="excel导入", notes="上传excel到服务器")
@ApiImplicitParam(name = "importFile", value = "excel文件", required = true, dataType = "MultipartFile")
@PreAuthorize("hasRole('ROLE_1001')")
...
...
@@ -84,6 +84,31 @@ public class BClassController extends PaginationController<BClass> {
MessageConstant.MESSAGE_ALERT_ERROR,
null);
}
*/
@ApiOperation
(
value
=
"行政班excel导入"
,
notes
=
"上传excel到服务器"
)
@ApiImplicitParam
(
name
=
"importFile"
,
value
=
"excel文件"
,
required
=
true
,
dataType
=
"MultipartFile"
)
@PreAuthorize
(
"hasRole('ROLE_1001')"
)
@PostMapping
(
value
=
"administrativeExcelImport"
)
public
Result
administrativeExcelImport
(
MultipartFile
importFile
,
String
token
)
throws
Exception
{
PersistModel
data
=
bClassService
.
administrativeImportExcel
(
MultipartFile2HSSFWorkbookConverter
.
convert
(
importFile
),
token
);
return
Result
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
null
);
}
@ApiOperation
(
value
=
"企业班excel导入"
,
notes
=
"上传excel到服务器"
)
@ApiImplicitParam
(
name
=
"importFile"
,
value
=
"excel文件"
,
required
=
true
,
dataType
=
"MultipartFile"
)
@PreAuthorize
(
"hasRole('ROLE_1001')"
)
@PostMapping
(
value
=
"businessExcelImport"
)
public
Result
businessExcelImport
(
MultipartFile
importFile
,
String
token
)
throws
Exception
{
PersistModel
data
=
bClassService
.
businessImportExcel
(
MultipartFile2HSSFWorkbookConverter
.
convert
(
importFile
),
token
);
return
Result
.
builder
(
data
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
,
MessageConstant
.
MESSAGE_ALERT_ERROR
,
null
);
}
@ApiOperation
(
value
=
"唯一查找"
,
notes
=
"根据ID查找一条记录"
)
@ApiImplicitParam
(
name
=
"businessId"
,
value
=
"businessId"
,
required
=
true
,
dataType
=
"varchar"
)
...
...
src/main/java/org/rcisoft/business/bclass/dao/BClassRepository.java
View file @
4496d0de
...
...
@@ -37,17 +37,27 @@ public interface BClassRepository extends BaseMapper<BClass> {
@Insert
(
"<script>INSERT INTO b_class"
+
"(create_date,update_date,del_flag,flag,business_id,code,class_name)VALUES"
+
"(create_date,update_date,del_flag,flag,business_id,code,class_name
,grade_code
)VALUES"
+
"<foreach collection=\"list\" item=\"item\" separator=\",\">"
+
"( #{item.createDate},#{item.updateDate},#{item.delFlag},#{item.flag},#{item.businessId},#{item.code},#{item.className})"
+
"( #{item.createDate},#{item.updateDate},#{item.delFlag},#{item.flag},#{item.businessId},#{item.code},#{item.className}
,#{item.gradeCode}
)"
+
"</foreach></script>"
)
int
insertList
(
List
<
BClass
>
bClasses
);
@Insert
(
"<script>INSERT INTO b_class"
+
"(create_date,update_date,del_flag,flag,business_id,code,class_name,grade_code,type,agency_code)VALUES"
+
"<foreach collection=\"list\" item=\"item\" separator=\",\">"
+
"( #{item.createDate},#{item.updateDate},#{item.delFlag},#{item.flag},#{item.businessId},#{item.code},#{item.className},#{item.gradeCode},#{item.type},#{item.agencyCode})"
+
"</foreach></script>"
)
int
insertBusinessClassList
(
List
<
BClass
>
bClasses
);
@Select
(
"select * from b_class where del_flag != 1 and flag = 1"
)
@ResultMap
(
value
=
"BaseResultMap"
)
List
<
BClass
>
queryBClassList
();
@Select
(
"select class_name from b_class where find_in_set(code,#{classesCode}) and del_flag != 1 and flag = 1"
)
List
<
String
>
queryClassNamesByIds
(
String
classesCode
);
@Select
(
"select * from b_grade where code = #{gradeCode} and del_flag = 0 and flag = 1"
)
List
<
BClass
>
checkGrade
(
BClass
bClass
);
}
src/main/java/org/rcisoft/business/bclass/service/BClassService.java
View file @
4496d0de
...
...
@@ -51,11 +51,29 @@ public interface BClassService{
PersistModel
removeBClass
(
String
id
);
/**
* 班级信息excel导入
* excel导入
* @param
* @return
*/
// PersistModel importExcel(HSSFWorkbook hwb, String token) throws IOException;
/**
* 行政班excel导入
* @param hwb
* @param token
* @return
* @throws IOException
*/
PersistModel
administrativeImportExcel
(
HSSFWorkbook
hwb
,
String
token
)
throws
IOException
;
/**
* 企业版excel导入
* @param hwb
* @param token
* @return
* @throws IOException
*/
PersistModel
i
mportExcel
(
HSSFWorkbook
hwb
,
String
token
)
throws
IOException
;
PersistModel
businessI
mportExcel
(
HSSFWorkbook
hwb
,
String
token
)
throws
IOException
;
List
<
SelectModel
>
queryBClassList
();
}
src/main/java/org/rcisoft/business/bclass/service/impl/BClassServiceImpl.java
View file @
4496d0de
...
...
@@ -6,6 +6,7 @@ import org.rcisoft.business.bclass.dao.BClassRepository;
import
org.rcisoft.business.bclass.entity.BClass
;
import
org.rcisoft.business.bclass.service.BClassService
;
import
org.rcisoft.business.brclassstudent.dao.BRClassStudentRepository
;
import
org.rcisoft.business.bstudent.entity.BStudent
;
import
org.rcisoft.core.aop.PageUtil
;
import
org.rcisoft.core.constant.MessageConstant
;
import
org.rcisoft.core.exception.ServiceException
;
...
...
@@ -78,6 +79,7 @@ public class BClassServiceImpl implements BClassService {
return
new
PersistModel
(
line
,
MessageConstant
.
MESSAGE_ALERT_SUCCESS
);
}
/**
@Transactional(propagation = Propagation.REQUIRED,readOnly = false)
@Override
public PersistModel importExcel(HSSFWorkbook hwb, String token) throws IOException {
...
...
@@ -122,6 +124,135 @@ public class BClassServiceImpl implements BClassService {
int line = bClassRepository.insertList(bClasses);
return new PersistModel(line,result);
}
*/
/**
* 行政班导入
* @param hwb
* @param token
* @return
* @throws IOException
*/
@Transactional
(
propagation
=
Propagation
.
REQUIRED
,
readOnly
=
false
)
@Override
public
PersistModel
administrativeImportExcel
(
HSSFWorkbook
hwb
,
String
token
)
throws
IOException
{
ArrayList
<
BClass
>
bClasses
=
new
ArrayList
<
BClass
>();
ArrayList
<
String
>
repeatCode
=
new
ArrayList
<
String
>();
String
[]
headers
=
{
"班级编号"
,
"班级名称"
,
"所属年级"
};
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
);
//获取excel数据
//判断年级是否存在
List
<
String
>
valuesGrade
=
new
ArrayList
<>();
if
(
values
.
size
()<=
0
){
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
);
}
for
(
String
[]
value:
values
){
//将数据封装到entity
BClass
bClass
=
null
;
BClass
b
=
new
BClass
(
value
[
0
]);
if
(
value
[
0
]==
null
||
value
[
0
].
equals
(
""
)||
value
[
1
]==
null
||
value
[
1
].
equals
(
""
)){
continue
;
}
if
((
bClass
=
bClassRepository
.
selectOne
(
b
))!=
null
)
{
repeatCode
.
add
(
value
[
0
]);
continue
;
}
//判断:学年是否存在,存在才能录入
BClass
b1
=
new
BClass
();
b1
.
setGradeCode
(
value
[
2
]);
if
(
bClassRepository
.
checkGrade
(
b1
).
size
()
==
0
){
valuesGrade
.
add
(
value
[
2
]);
continue
;
}
bClass
=
new
BClass
(
value
[
0
],
value
[
1
]);
bClass
.
setGradeCode
(
value
[
2
]);
bClass
.
setCommonBusinessId
();
UserUtil
.
setCurrentPersistOperation
(
bClass
);
if
(!
bClasses
.
contains
(
bClass
)){
bClasses
.
add
(
bClass
);
}
}
if
(
bClasses
.
size
()<
1
){
if
(
repeatCode
.
size
()<
1
)
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
);
else
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
.
getCode
(),
"Excel内所有数据之前都已经导入:"
+
JSON
.
toJSONString
(
repeatCode
));
}
String
result
=
ExcelUtil
.
checkRepeat
(
repeatCode
);
int
line
=
bClassRepository
.
insertList
(
bClasses
);
if
(
valuesGrade
.
size
()>
0
){
result
+=
"以下班级的所属年级信息不存在:"
+
JSON
.
toJSONString
(
valuesGrade
)+
"。"
;
}
return
new
PersistModel
(
line
,
result
);
}
@Override
public
PersistModel
businessImportExcel
(
HSSFWorkbook
hwb
,
String
token
)
{
ArrayList
<
BClass
>
bClasses
=
new
ArrayList
<
BClass
>();
ArrayList
<
String
>
repeatCode
=
new
ArrayList
<
String
>();
String
[]
headers
=
{
"班级编号"
,
"班级名称"
,
"所属年级"
,
"教学单位"
};
ArrayList
<
String
[]>
values
=
ExcelUtil
.
importExcel
(
hwb
,
headers
,
false
);
//获取excel数据
//判断年级是否存在
List
<
String
>
valuesGrade
=
new
ArrayList
<>();
if
(
values
.
size
()<=
0
){
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
);
}
for
(
String
[]
value:
values
){
//将数据封装到entity
BClass
bClass
=
null
;
BClass
b
=
new
BClass
(
value
[
0
]);
if
(
value
[
0
]==
null
||
value
[
0
].
equals
(
""
)||
value
[
1
]==
null
||
value
[
1
].
equals
(
""
)){
continue
;
}
if
((
bClass
=
bClassRepository
.
selectOne
(
b
))!=
null
)
{
repeatCode
.
add
(
value
[
0
]);
continue
;
}
//判断:学年是否存在,存在才能录入
BClass
b1
=
new
BClass
();
b1
.
setGradeCode
(
value
[
2
]);
if
(
bClassRepository
.
checkGrade
(
b1
).
size
()
==
0
){
valuesGrade
.
add
(
value
[
2
]);
continue
;
}
bClass
=
new
BClass
(
value
[
0
],
value
[
1
]);
bClass
.
setGradeCode
(
value
[
2
]);
bClass
.
setAgencyCode
(
value
[
3
]);
bClass
.
setType
(
"1"
);
bClass
.
setCommonBusinessId
();
UserUtil
.
setCurrentPersistOperation
(
bClass
);
if
(!
bClasses
.
contains
(
bClass
)){
bClasses
.
add
(
bClass
);
}
}
if
(
bClasses
.
size
()<
1
){
if
(
repeatCode
.
size
()<
1
)
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
);
else
throw
new
ServiceException
(
ResultServiceEnums
.
EXCEL_IMPORT_DATA_NOT_EXIST
.
getCode
(),
"Excel内所有数据之前都已经导入:"
+
JSON
.
toJSONString
(
repeatCode
));
}
String
result
=
ExcelUtil
.
checkRepeat
(
repeatCode
);
int
line
=
bClassRepository
.
insertBusinessClassList
(
bClasses
);
if
(
valuesGrade
.
size
()>
0
){
result
+=
"以下班级的所属年级信息不存在:"
+
JSON
.
toJSONString
(
valuesGrade
)+
"。"
;
}
return
new
PersistModel
(
line
,
result
);
}
@Override
public
List
<
SelectModel
>
queryBClassList
()
{
...
...
src/main/java/org/rcisoft/business/bstudent/dao/BStudentRepository.java
View file @
4496d0de
...
...
@@ -4,6 +4,7 @@ import org.apache.ibatis.annotations.Insert;
import
org.apache.ibatis.annotations.Param
;
import
org.apache.ibatis.annotations.ResultMap
;
import
org.apache.ibatis.annotations.Select
;
import
org.rcisoft.business.bclass.entity.BClass
;
import
org.rcisoft.business.bstudent.entity.BStudent
;
import
org.rcisoft.business.bstudent.entity.BStudentDto
;
import
org.rcisoft.core.base.BaseMapper
;
...
...
@@ -166,7 +167,7 @@ public interface BStudentRepository extends BaseMapper<BStudent> {
List
<
BStudent
>
queryStudentsByClassCode
(
String
classCode
);
@Select
(
"select * from b_grade where code = #{gradeCode} and del_flag = 0 and flag = 1"
)
List
<
B
Student
>
checkStudentGrade
(
BStudent
bStudent
);
List
<
B
Class
>
checkStudentGrade
(
BStudent
bStudent
);
}
src/main/resources/excel-template/administrative-class.xls
0 → 100644
View file @
4496d0de
File added
src/main/resources/excel-template/business-class.xls
0 → 100644
View file @
4496d0de
File added
src/main/resources/excel-template/student-class.xls
View file @
4496d0de
No preview for this file type
src/main/resources/excel-template/teacher.xls
View file @
4496d0de
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