Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
E
engine-class-work
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
liuchengjiu
engine-class-work
Commits
3a4bf0e2
Commit
3a4bf0e2
authored
Jul 18, 2023
by
Ryan Loong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化学生查询逻辑
parent
8b602ffa
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
29 deletions
+81
-29
StudentVo.java
...va/cn/exploring/engine/server/db/domain/vo/StudentVo.java
+9
-0
StudentInfoService.java
...xploring/engine/server/db/service/StudentInfoService.java
+35
-23
StudentPointService.java
...ploring/engine/server/db/service/StudentPointService.java
+4
-0
SqlUtil.java
...main/java/cn/exploring/engine/server/db/util/SqlUtil.java
+17
-0
StrUtil.java
...main/java/cn/exploring/engine/server/db/util/StrUtil.java
+16
-0
PointController.java
...va/cn/exploring/engine/server/wx/web/PointController.java
+0
-6
No files found.
server-db/src/main/java/cn/exploring/engine/server/db/domain/vo/StudentVo.java
View file @
3a4bf0e2
...
...
@@ -7,6 +7,7 @@ import cn.exploring.engine.server.db.domain.StudentInfo;
*/
public
class
StudentVo
extends
StudentInfo
{
public
String
ClassName
;
private
Integer
callTimes
;
public
String
getClassName
()
{
return
ClassName
;
...
...
@@ -15,4 +16,12 @@ public class StudentVo extends StudentInfo {
public
void
setClassName
(
String
className
)
{
ClassName
=
className
;
}
public
Integer
getCallTimes
()
{
return
callTimes
;
}
public
void
setCallTimes
(
Integer
callTimes
)
{
this
.
callTimes
=
callTimes
;
}
}
server-db/src/main/java/cn/exploring/engine/server/db/service/StudentInfoService.java
View file @
3a4bf0e2
...
...
@@ -8,9 +8,11 @@ import cn.exploring.engine.server.db.domain.StudentInfoExample;
import
cn.exploring.engine.server.db.domain.vo.StudentInfoExcelImportResultVo
;
import
cn.exploring.engine.server.db.domain.vo.StudentInfoExcelImportVo
;
import
cn.exploring.engine.server.db.domain.vo.StudentVo
;
import
cn.exploring.engine.server.db.util.SqlUtil
;
import
cn.exploring.engine.server.db.util.excel.ExcelReaderListener
;
import
cn.exploring.engine.server.db.util.excel.StudentInfoExcelReaderListener
;
import
com.alibaba.excel.EasyExcel
;
import
com.github.pagehelper.Page
;
import
com.github.pagehelper.PageHelper
;
import
com.github.pagehelper.PageInfo
;
import
com.google.common.collect.ImmutableMap
;
...
...
@@ -157,10 +159,10 @@ public class StudentInfoService {
StudentInfoExample
.
Criteria
criteria
=
example
.
createCriteria
();
criteria
.
andDeletedEqualTo
(
false
);
if
(!
StringUtils
.
isEmpty
(
studentName
))
{
criteria
.
andNameLike
(
"%"
+
studentName
+
"%"
);
criteria
.
andNameLike
(
SqlUtil
.
likeStr
(
studentName
)
);
}
if
(!
StringUtils
.
isEmpty
(
studentId
))
{
criteria
.
andStudentUniqueIdLike
(
"%"
+
studentId
+
"%"
);
criteria
.
andStudentUniqueIdLike
(
SqlUtil
.
likeStr
(
studentId
)
);
}
if
(
idList
!=
null
&&
idList
.
size
()
>
0
)
{
criteria
.
andIdIn
(
idList
);
...
...
@@ -169,34 +171,44 @@ public class StudentInfoService {
criteria
.
andClassIdEqualTo
(
classId
);
}
PageHelper
.
startPage
(
page
,
limit
);
example
.
setOrderByClause
(
sort
+
" "
+
order
);
Map
<
Integer
,
Integer
>
callTimeMap
=
studentPointService
.
countByClassGroupByStudent
(
classId
);
if
(
Objects
.
nonNull
(
minCall
)
||
Objects
.
nonNull
(
maxCall
))
{
List
<
Integer
>
excluded
=
callTimeMap
.
entrySet
().
stream
()
.
filter
(
entry
->
(
Objects
.
nonNull
(
minCall
)
&&
entry
.
getValue
()
<
minCall
)
||
(
Objects
.
nonNull
(
maxCall
)
&&
entry
.
getValue
()
>
maxCall
))
.
map
(
Map
.
Entry
::
getKey
).
collect
(
Collectors
.
toList
());
if
(!
CollectionUtils
.
isEmpty
(
excluded
))
{
criteria
.
andIdNotIn
(
excluded
);
}
}
List
<
StudentInfo
>
studentInfoList
=
studentInfoMapper
.
selectByExample
(
example
);
try
(
Page
<?>
ignored
=
PageHelper
.
startPage
(
page
,
limit
,
sort
+
" "
+
order
))
{
List
<
StudentInfo
>
studentInfoList
=
studentInfoMapper
.
selectByExample
(
example
);
if
(
CollectionUtils
.
isEmpty
(
studentInfoList
))
{
return
ImmutableMap
.
of
(
"total"
,
0
,
"items"
,
Collections
.
emptyList
());
}
if
(
CollectionUtils
.
isEmpty
(
studentInfoList
))
{
return
ImmutableMap
.
of
(
"total"
,
0
,
"items"
,
Collections
.
emptyList
());
}
Map
<
Integer
,
String
>
classMap
=
classService
.
getClassNameMap
();
Map
<
Integer
,
String
>
classMap
=
classService
.
getClassNameMap
();
List
<
StudentVo
>
dataList
=
studentInfoList
.
stream
().
map
(
x
->
{
StudentVo
voData
=
new
StudentVo
();
BeanUtils
.
copyProperties
(
x
,
voData
);
voData
.
setClassName
(
classMap
.
get
(
x
.
getClassId
()));
List
<
StudentVo
>
dataList
=
studentInfoList
.
stream
().
map
(
x
->
{
StudentVo
voData
=
new
StudentVo
();
BeanUtils
.
copyProperties
(
x
,
voData
);
voData
.
setClassName
(
classMap
.
get
(
x
.
getClassId
()));
voData
.
setCallTimes
(
callTimeMap
.
getOrDefault
(
x
.
getId
(),
0
));
if
(
StringUtils
.
isEmpty
(
x
.
getHead
())
||
x
.
getHead
().
trim
().
equalsIgnoreCase
(
STRING_DEFAULT_HEAD
))
{
voData
.
setHead
(
URL_DEFAULT_HEAD
);
}
return
voData
;
}).
collect
(
Collectors
.
toList
());
Long
total
=
PageInfo
.
of
(
studentInfoList
).
getTotal
();
return
ImmutableMap
.
of
(
"total"
,
total
,
"items"
,
dataList
);
}
if
(
StringUtils
.
isEmpty
(
x
.
getHead
())
||
x
.
getHead
().
trim
().
equalsIgnoreCase
(
STRING_DEFAULT_HEAD
))
{
voData
.
setHead
(
URL_DEFAULT_HEAD
);
}
return
voData
;
}).
collect
(
Collectors
.
toList
());
Long
total
=
PageInfo
.
of
(
studentInfoList
).
getTotal
();
return
new
HashMap
(){{
put
(
"total"
,
total
);
put
(
"items"
,
dataList
);
}};
}
// /**
...
...
server-db/src/main/java/cn/exploring/engine/server/db/service/StudentPointService.java
View file @
3a4bf0e2
...
...
@@ -101,6 +101,10 @@ public class StudentPointService {
.
stream
().
collect
(
Collectors
.
groupingBy
(
StudentPointInfo:
:
getStudentId
,
Collectors
.
toList
()));
}
public
Map
<
Integer
,
Integer
>
countByClassGroupByStudent
(
Integer
classId
)
{
return
selectByClassGroupByStudent
(
classId
).
entrySet
().
stream
().
collect
(
Collectors
.
toMap
(
Map
.
Entry
::
getKey
,
entry
->
entry
.
getValue
().
size
()));
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
removeAll
()
{
studentPointInfoMapper
.
updateByExampleSelective
(
new
StudentPointInfo
(){{
...
...
server-db/src/main/java/cn/exploring/engine/server/db/util/SqlUtil.java
0 → 100644
View file @
3a4bf0e2
package
cn
.
exploring
.
engine
.
server
.
db
.
util
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.Optional
;
public
class
SqlUtil
{
public
static
String
likeStr
(
String
str
)
{
return
Optional
.
ofNullable
(
str
)
.
filter
(
StringUtils:
:
isNotBlank
)
.
map
(
String:
:
trim
)
.
map
(
s
->
StrUtil
.
format
(
"%{}%"
,
s
.
replaceAll
(
"\\s+"
,
"%"
)))
.
orElse
(
"%"
);
}
}
server-db/src/main/java/cn/exploring/engine/server/db/util/StrUtil.java
0 → 100644
View file @
3a4bf0e2
package
cn
.
exploring
.
engine
.
server
.
db
.
util
;
import
org.apache.logging.log4j.message.ParameterizedMessage
;
import
java.util.Objects
;
public
class
StrUtil
{
public
static
String
format
(
String
messagePattern
,
Object
...
arguments
)
{
if
(
Objects
.
nonNull
(
arguments
)
&&
arguments
.
length
==
1
&&
Objects
.
nonNull
(
arguments
[
0
])
&&
arguments
[
0
].
getClass
().
isArray
())
{
arguments
=
(
Object
[])
arguments
[
0
];
}
return
ParameterizedMessage
.
format
(
messagePattern
,
arguments
);
}
}
server-wx-api/src/main/java/cn/exploring/engine/server/wx/web/PointController.java
View file @
3a4bf0e2
...
...
@@ -69,12 +69,6 @@ public class PointController {
}
// @PostMapping("getStuList")
// public Object getStuList(@RequestParam Integer classId, @RequestParam Integer maxCall) {
// return ResponseUtil.ok(studentInfoService.listForCall(classId, maxCall));
// }
@GetMapping
(
"export"
)
public
Object
export
(
Integer
classId
)
{
List
<
StudentPointInfo
>
list
=
pointService
.
listByClassId
(
classId
);
...
...
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