Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
yangxiujun
/
paidan_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 20f38411
authored
Jul 11, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加了分页、按工号手机号姓名模糊匹配的功能
1 parent
fe78a284
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
3 deletions
project-order/src/main/java/com/dituhui/pea/order/common/EngineerUtil.java
project-order/src/main/java/com/dituhui/pea/order/dao/EngineerInfoDao.java
project-order/src/main/java/com/dituhui/pea/order/dto/EngineerCalendarDTO.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerCalendarServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/common/EngineerUtil.java
View file @
20f3841
...
...
@@ -7,8 +7,17 @@ import com.dituhui.pea.order.entity.EngineerInfoEntity;
import
com.dituhui.pea.order.entity.OrgGroupEntity
;
import
com.dituhui.pea.order.entity.OrgTeamEngineerEntity
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Component
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
...
...
@@ -24,7 +33,7 @@ public class EngineerUtil {
@Autowired
private
OrgGroupDao
orgGroupDao
;
public
List
<
EngineerInfoEntity
>
getEngineesByLevel
(
String
levelType
,
String
levelValue
){
public
List
<
EngineerInfoEntity
>
getEngineesByLevel
(
String
levelType
,
String
levelValue
)
{
List
<
EngineerInfoEntity
>
engineers
=
null
;
List
<
String
>
groupIds
=
null
;
switch
(
levelType
)
{
...
...
@@ -50,4 +59,28 @@ public class EngineerUtil {
}
return
engineers
;
}
public
Page
<
EngineerInfoEntity
>
findEngineersByKeyAndPage
(
List
<
String
>
engineerCodes
,
String
key
,
Integer
page
,
Integer
size
)
{
Pageable
pageable
=
PageRequest
.
of
(
page
-
1
,
size
);
return
engineerInfoDao
.
findAllAndEngineerCodeIn
(
engineerCodes
,
buildSpecification
(
key
),
pageable
);
}
private
Specification
<
EngineerInfoEntity
>
buildSpecification
(
String
keyword
)
{
return
new
Specification
<
EngineerInfoEntity
>()
{
@Override
public
Predicate
toPredicate
(
Root
<
EngineerInfoEntity
>
root
,
CriteriaQuery
<?>
query
,
CriteriaBuilder
criteriaBuilder
)
{
List
<
Predicate
>
predicates
=
new
ArrayList
<>();
// 构建查询条件
Predicate
engineerCodePredicate
=
criteriaBuilder
.
like
(
root
.
get
(
"engineerCode"
),
"%"
+
keyword
+
"%"
);
Predicate
mobilePredicate
=
criteriaBuilder
.
like
(
root
.
get
(
"phone"
),
"%"
+
keyword
+
"%"
);
Predicate
msgContentPredicate
=
criteriaBuilder
.
like
(
root
.
get
(
"name"
),
"%"
+
keyword
+
"%"
);
predicates
.
add
(
criteriaBuilder
.
or
(
engineerCodePredicate
,
mobilePredicate
,
msgContentPredicate
));
return
criteriaBuilder
.
and
(
predicates
.
toArray
(
new
Predicate
[
0
]));
}
};
}
}
project-order/src/main/java/com/dituhui/pea/order/dao/EngineerInfoDao.java
View file @
20f3841
...
...
@@ -2,6 +2,9 @@ package com.dituhui.pea.order.dao;
import
com.dituhui.pea.order.entity.EngineerInfoEntity
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.stereotype.Repository
;
...
...
@@ -16,4 +19,6 @@ public interface EngineerInfoDao extends JpaRepository<EngineerInfoEntity, Integ
List
<
EngineerInfoEntity
>
findByGroupIdIn
(
List
<
String
>
groupIds
);
List
<
EngineerInfoEntity
>
findByEngineerCodeIn
(
List
<
String
>
engineerCodes
);
Page
<
EngineerInfoEntity
>
findAllAndEngineerCodeIn
(
List
<
String
>
engineerCodes
,
Specification
<
EngineerInfoEntity
>
engineerInfoEntitySpecification
,
Pageable
pageable
);
}
project-order/src/main/java/com/dituhui/pea/order/dto/EngineerCalendarDTO.java
View file @
20f3841
...
...
@@ -2,6 +2,8 @@ package com.dituhui.pea.order.dto;
import
java.util.List
;
import
static
com
.
dituhui
.
pea
.
order
.
config
.
OrderConfig
.
DEFAULT_PAGE_SIZE
;
public
class
EngineerCalendarDTO
{
@lombok
.
Data
...
...
@@ -13,11 +15,17 @@ public class EngineerCalendarDTO {
private
String
key
;
private
String
levelType
;
private
String
levelValue
;
private
Integer
size
=
DEFAULT_PAGE_SIZE
;
private
Integer
page
=
1
;
}
@lombok
.
Data
public
static
class
Result
{
private
long
pageCurrent
;
private
long
pages
;
private
long
pageSize
;
private
long
total
;
private
List
<
Engineer
>
engineers
;
}
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerCalendarServiceImpl.java
View file @
20f3841
...
...
@@ -14,6 +14,7 @@ import com.dituhui.pea.order.entity.OrgTeamEntity;
import
com.dituhui.pea.order.service.EngineerCalendarService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.stereotype.Service
;
import
java.time.Duration
;
...
...
@@ -48,10 +49,14 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
public
Result
<?>
getEngineersCalendar
(
EngineerCalendarDTO
.
Request
req
)
{
// 技术员日历,查询 capacity_engineer_calendar表,如果当日有各种事项,进行显示;否则显示正常上班;
List
<
EngineerCalendarDTO
.
Engineer
>
engineers
=
new
ArrayList
<>();
List
<
EngineerInfoEntity
>
entities
=
engineerUtil
.
getEngineesByLevel
(
req
.
getLevelType
(),
req
.
getLevelValue
());
List
<
String
>
allCodes
=
engineerUtil
.
getEngineesByLevel
(
req
.
getLevelType
(),
req
.
getLevelValue
()).
stream
()
.
map
(
EngineerInfoEntity:
:
getEngineerCode
).
collect
(
Collectors
.
toList
());
Page
<
EngineerInfoEntity
>
page
=
engineerUtil
.
findEngineersByKeyAndPage
(
allCodes
,
req
.
getKey
(),
req
.
getPage
(),
req
.
getSize
());
String
edate
=
LocalDate
.
parse
(
req
.
getDate
()).
plusDays
(
14
).
toString
();
for
(
EngineerInfoEntity
e
:
entities
)
{
for
(
EngineerInfoEntity
e
:
page
.
getContent
()
)
{
EngineerCalendarDTO
.
Engineer
engineer
=
new
EngineerCalendarDTO
.
Engineer
();
engineer
.
setEngineerCode
(
e
.
getEngineerCode
());
engineer
.
setName
(
e
.
getName
());
...
...
@@ -59,6 +64,10 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
engineers
.
add
(
engineer
);
}
EngineerCalendarDTO
.
Result
rs
=
new
EngineerCalendarDTO
.
Result
();
rs
.
setTotal
(
page
.
getTotalElements
());
rs
.
setPages
(
page
.
getTotalPages
());
rs
.
setPageSize
(
page
.
getSize
());
rs
.
setPageCurrent
(
page
.
getNumber
());
rs
.
setEngineers
(
engineers
);
return
Result
.
success
(
rs
);
}
...
...
@@ -143,4 +152,5 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
calendar
.
setContent
(
Collections
.
singletonList
(
content
));
return
calendar
;
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment