Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
on-site-service
Project
Project
Details
Activity
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
external
on-site-service
Commits
2fc1b4b1
Commit
2fc1b4b1
authored
Jul 18, 2022
by
shangtx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 查询估价员接口
parent
30321953
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
77 deletions
+56
-77
ServiceValuatorController.java
...e/admin/controller/service/ServiceValuatorController.java
+0
-21
ServiceValuatorVO.java
...ervice/admin/controller/service/vo/ServiceValuatorVO.java
+1
-1
ServiceValuatorService.java
...service/admin/service/service/ServiceValuatorService.java
+25
-52
ServiceValuatorServiceTest.java
...ice/admin/service/service/ServiceValuatorServiceTest.java
+21
-0
UserMapper.xml
dao/src/main/resources/mapper/user/UserMapper.xml
+4
-1
ServiceValuatorVO.java
...rvice/miniapp/controller/worker/vo/ServiceValuatorVO.java
+1
-1
ServiceValuatorService.java
...ervice/miniapp/service/worker/ServiceValuatorService.java
+4
-1
No files found.
admin/src/main/java/com/onsiteservice/admin/controller/service/ServiceValuatorController.java
View file @
2fc1b4b1
...
@@ -17,11 +17,9 @@ import org.springframework.web.bind.annotation.*;
...
@@ -17,11 +17,9 @@ import org.springframework.web.bind.annotation.*;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.Positive
;
import
java.util.List
;
import
java.util.List
;
import
static
com
.
onsiteservice
.
core
.
result
.
ResultGenerator
.
fail
;
import
static
com
.
onsiteservice
.
core
.
result
.
ResultGenerator
.
success
;
import
static
com
.
onsiteservice
.
core
.
result
.
ResultGenerator
.
success
;
/**
/**
...
@@ -48,23 +46,4 @@ public class ServiceValuatorController {
...
@@ -48,23 +46,4 @@ public class ServiceValuatorController {
}
}
@ApiOperation
(
value
=
"分页查询列表"
)
@PostMapping
(
"page"
)
public
Result
<
PageInfoVO
<
ServiceValuatorVO
>>
getPage
(
@RequestBody
@NonNull
@Validated
PageServiceValuatorDTO
dto
)
{
return
serviceValuatorService
.
getPage
(
dto
);
}
@ApiOperation
(
value
=
"根据id查询"
)
@GetMapping
(
"get/{id}"
)
public
Result
<
ServiceValuatorVO
>
getDetails
(
@ApiParam
(
name
=
"id"
,
value
=
"估价员id"
)
@PathVariable
@Positive
Long
id
)
{
return
success
(
serviceValuatorService
.
selectById
(
id
));
}
@ApiOperation
(
value
=
"新增"
)
@PostMapping
(
"save"
)
public
Result
save
(
@RequestBody
@NonNull
@Validated
SaveServiceValuatorDTO
dto
,
@CurrentUserId
Long
userId
)
{
return
serviceValuatorService
.
save
(
dto
,
userId
)
==
1
?
success
()
:
fail
(
"新增失败"
);
}
}
}
admin/src/main/java/com/onsiteservice/admin/controller/service/vo/ServiceValuatorVO.java
View file @
2fc1b4b1
...
@@ -38,6 +38,6 @@ public class ServiceValuatorVO {
...
@@ -38,6 +38,6 @@ public class ServiceValuatorVO {
private
Date
modifyTime
;
private
Date
modifyTime
;
@ApiModelProperty
(
value
=
"估价员已被指派的时间"
)
@ApiModelProperty
(
value
=
"估价员已被指派的时间"
)
private
List
<
Date
>
assignTime
;
private
List
<
String
>
assignTime
;
}
}
\ No newline at end of file
admin/src/main/java/com/onsiteservice/admin/service/service/ServiceValuatorService.java
View file @
2fc1b4b1
...
@@ -7,6 +7,7 @@ import com.onsiteservice.admin.controller.service.dto.SaveServiceValuatorDTO;
...
@@ -7,6 +7,7 @@ import com.onsiteservice.admin.controller.service.dto.SaveServiceValuatorDTO;
import
com.onsiteservice.admin.controller.service.dto.UpdateServiceValuatorDTO
;
import
com.onsiteservice.admin.controller.service.dto.UpdateServiceValuatorDTO
;
import
com.onsiteservice.admin.controller.service.vo.ServiceValuatorVO
;
import
com.onsiteservice.admin.controller.service.vo.ServiceValuatorVO
;
import
com.onsiteservice.admin.mapper.service.ServiceValuatorBizMapper
;
import
com.onsiteservice.admin.mapper.service.ServiceValuatorBizMapper
;
import
com.onsiteservice.constant.constant.BizConstants
;
import
com.onsiteservice.constant.enums.BizCodeEnum
;
import
com.onsiteservice.constant.enums.BizCodeEnum
;
import
com.onsiteservice.constant.enums.ServiceUserTypeEnum
;
import
com.onsiteservice.constant.enums.ServiceUserTypeEnum
;
import
com.onsiteservice.core.exception.ServiceException
;
import
com.onsiteservice.core.exception.ServiceException
;
...
@@ -21,7 +22,9 @@ import com.onsiteservice.entity.service.ServiceValuatorAssign;
...
@@ -21,7 +22,9 @@ import com.onsiteservice.entity.service.ServiceValuatorAssign;
import
com.onsiteservice.entity.service.ServiceWorker
;
import
com.onsiteservice.entity.service.ServiceWorker
;
import
com.onsiteservice.entity.user.User
;
import
com.onsiteservice.entity.user.User
;
import
com.onsiteservice.util.AttrCopyUtils
;
import
com.onsiteservice.util.AttrCopyUtils
;
import
com.onsiteservice.util.DateUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -51,77 +54,47 @@ public class ServiceValuatorService extends AbstractMapper<ServiceValuator> {
...
@@ -51,77 +54,47 @@ public class ServiceValuatorService extends AbstractMapper<ServiceValuator> {
private
UserMapper
userMapper
;
private
UserMapper
userMapper
;
@Resource
@Resource
private
ServiceValuatorAssignMapper
serviceValuatorAssignMapper
;
private
ServiceValuatorAssignMapper
serviceValuatorAssignMapper
;
;
;
/**
* 分页查询列表
*/
public
Result
<
PageInfoVO
<
ServiceValuatorVO
>>
getPage
(
PageServiceValuatorDTO
dto
)
{
PageHelper
.
startPage
(
dto
.
getPage
(),
dto
.
getSize
());
List
<
ServiceValuator
>
serviceValuatorList
=
serviceValuatorBizMapper
.
selectServiceValuatorPage
(
dto
);
List
<
ServiceValuatorVO
>
serviceValuatorVOList
=
serviceValuatorList
.
parallelStream
().
map
(
e
->
AttrCopyUtils
.
copy
(
e
,
new
ServiceValuatorVO
())).
collect
(
Collectors
.
toList
());
return
ResultGenerator
.
success
(
new
PageInfoVO
<>(
serviceValuatorVOList
));
}
public
ServiceValuatorVO
selectById
(
Long
id
)
{
log
.
info
(
"valuator selectById id: {}"
,
id
);
ServiceValuator
serviceValuator
=
this
.
selectByPrimaryKey
(
id
);
if
(
Objects
.
isNull
(
serviceValuator
))
{
throw
new
ServiceException
(
BizCodeEnum
.
SERVICE_VALUATOR_NOT_EXIST
);
}
return
AttrCopyUtils
.
copy
(
serviceValuator
,
new
ServiceValuatorVO
());
}
public
int
save
(
SaveServiceValuatorDTO
dto
,
Long
userId
)
{
log
.
info
(
"valuator save dto: {}, userId: {}"
,
dto
,
userId
);
// checkAuth(userId);
Condition
c
=
new
Condition
(
ServiceWorker
.
class
);
c
.
createCriteria
().
andEqualTo
(
"phone"
,
dto
.
getPhone
());
List
<
ServiceValuator
>
serviceValuatorList
=
this
.
selectByCondition
(
c
);
if
(!
CollectionUtils
.
isEmpty
(
serviceValuatorList
))
{
throw
new
ServiceException
(
BizCodeEnum
.
SERVICE_VALUATOR_HAS_EXIST
);
}
return
this
.
insertSelective
(
AttrCopyUtils
.
copy
(
dto
,
new
ServiceValuator
()));
}
public
List
<
ServiceValuatorVO
>
selectByName
(
String
name
)
{
public
List
<
ServiceValuatorVO
>
selectByName
(
String
name
)
{
log
.
info
(
"valuator selectByName name: {}"
,
name
);
log
.
info
(
"valuator selectByName name: {}"
,
name
);
List
<
User
>
userList
;
List
<
ServiceValuator
>
serviceValuatorList
=
serviceValuatorBizMapper
.
selectByNameLike
(
name
);
if
(
StringUtils
.
isNotEmpty
(
name
))
{
return
handle
(
serviceValuatorList
);
userList
=
userMapper
.
selectByNameLike
(
name
);
}
else
{
Condition
c
=
new
Condition
(
User
.
class
);
c
.
createCriteria
().
andEqualTo
(
BizConstants
.
UserConstants
.
ROLE_TYPE
);
userList
=
userMapper
.
selectByCondition
(
c
);
}
return
handle
(
userList
);
}
}
private
List
<
ServiceValuatorVO
>
handle
(
List
<
ServiceValuator
>
serviceValuatorList
)
{
private
List
<
ServiceValuatorVO
>
handle
(
List
<
User
>
userList
)
{
if
(
CollectionUtils
.
isEmpty
(
serviceValuato
rList
))
{
if
(
CollectionUtils
.
isEmpty
(
use
rList
))
{
return
Lists
.
newArrayList
();
return
Lists
.
newArrayList
();
}
}
// 估价员id列表
// 估价员id列表
List
<
Long
>
valuatorIds
=
serviceValuatorList
.
parallelStream
().
map
(
ServiceValuato
r:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Long
>
valuatorIds
=
userList
.
parallelStream
().
map
(
Use
r:
:
getId
).
collect
(
Collectors
.
toList
());
// 已被指派的时间
// 已被指派的时间
List
<
ServiceValuatorAssign
>
serviceValuatorAssignList
=
serviceValuatorAssignMapper
.
selectByDeletedAndIdListAndAssignTime
(
valuatorIds
);
List
<
ServiceValuatorAssign
>
serviceValuatorAssignList
=
serviceValuatorAssignMapper
.
selectByDeletedAndIdListAndAssignTime
(
valuatorIds
);
Map
<
Long
,
List
<
ServiceValuatorAssign
>>
serviceValuatorAssignMap
=
Map
<
Long
,
List
<
ServiceValuatorAssign
>>
serviceValuatorAssignMap
=
serviceValuatorAssignList
.
parallelStream
()
serviceValuatorAssignList
.
parallelStream
()
.
collect
(
Collectors
.
groupingBy
(
ServiceValuatorAssign:
:
getValuatorId
));
.
collect
(
Collectors
.
groupingBy
(
ServiceValuatorAssign:
:
getValuatorId
));
return
serviceValuatorList
.
parallelStream
().
map
(
e1
->
{
return
userList
.
parallelStream
().
map
(
e1
->
{
ServiceValuatorVO
serviceValuatorVO
=
AttrCopyUtils
.
copy
(
e1
,
new
ServiceValuatorVO
());
ServiceValuatorVO
serviceValuatorVO
=
new
ServiceValuatorVO
();
serviceValuatorVO
.
setId
(
e1
.
getId
());
serviceValuatorVO
.
setName
(
e1
.
getUserName
());
serviceValuatorVO
.
setPhone
(
e1
.
getPhone
());
// 估价员已经被指派的时间
// 估价员已经被指派的时间
List
<
ServiceValuatorAssign
>
assigns
=
serviceValuatorAssignMap
.
getOrDefault
(
e1
.
getId
(),
Lists
.
newArrayList
());
List
<
ServiceValuatorAssign
>
assigns
=
serviceValuatorAssignMap
.
getOrDefault
(
e1
.
getId
(),
Lists
.
newArrayList
());
List
<
Date
>
assignTimes
=
assigns
.
parallelStream
().
map
(
ServiceValuatorAssign:
:
getAssignTime
).
collect
(
Collectors
.
toList
());
String
dateFormat
=
"yyyy-MM-dd HH:mm"
;
List
<
String
>
assignTimes
=
assigns
.
parallelStream
()
.
map
(
assign
->
DateUtils
.
formatDate
(
assign
.
getAssignTime
(),
dateFormat
)).
collect
(
Collectors
.
toList
());
serviceValuatorVO
.
setAssignTime
(
assignTimes
);
serviceValuatorVO
.
setAssignTime
(
assignTimes
);
...
...
admin/src/test/java/com/onsiteservice/admin/service/service/ServiceValuatorServiceTest.java
0 → 100644
View file @
2fc1b4b1
package
com
.
onsiteservice
.
admin
.
service
.
service
;
import
com.alibaba.fastjson.JSONObject
;
import
org.junit.jupiter.api.Test
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
javax.annotation.Resource
;
import
static
org
.
junit
.
jupiter
.
api
.
Assertions
.*;
@SpringBootTest
class
ServiceValuatorServiceTest
{
@Resource
private
ServiceValuatorService
serviceValuatorService
;
@Test
void
selectByName
()
{
System
.
out
.
println
(
JSONObject
.
toJSONString
(
serviceValuatorService
.
selectByName
(
null
)));
System
.
out
.
println
(
JSONObject
.
toJSONString
(
serviceValuatorService
.
selectByName
(
"宁"
)));
}
}
\ No newline at end of file
dao/src/main/resources/mapper/user/UserMapper.xml
View file @
2fc1b4b1
...
@@ -3,7 +3,10 @@
...
@@ -3,7 +3,10 @@
<mapper
namespace=
"com.onsiteservice.dao.mapper.user.UserMapper"
>
<mapper
namespace=
"com.onsiteservice.dao.mapper.user.UserMapper"
>
<select
id=
"selectByNameLike"
resultType=
"com.onsiteservice.entity.user.User"
>
<select
id=
"selectByNameLike"
resultType=
"com.onsiteservice.entity.user.User"
>
select * from user where user_name like '%${name}%' order by create_time asc
select * from user
where user_name like '%${name}%'
and role_type = ${@com.onsiteservice.constant.enums.ServiceUserTypeEnum@VALUATOR.getId()}
order by create_time asc
</select>
</select>
</mapper>
</mapper>
\ No newline at end of file
mini-app/src/main/java/com/onsiteservice/miniapp/controller/worker/vo/ServiceValuatorVO.java
View file @
2fc1b4b1
...
@@ -28,6 +28,6 @@ public class ServiceValuatorVO {
...
@@ -28,6 +28,6 @@ public class ServiceValuatorVO {
private
String
phone
;
private
String
phone
;
@ApiModelProperty
(
value
=
"估价员已被指派的时间"
)
@ApiModelProperty
(
value
=
"估价员已被指派的时间"
)
private
List
<
Date
>
assignTime
;
private
List
<
String
>
assignTime
;
}
}
mini-app/src/main/java/com/onsiteservice/miniapp/service/worker/ServiceValuatorService.java
View file @
2fc1b4b1
...
@@ -9,6 +9,7 @@ import com.onsiteservice.entity.service.ServiceValuator;
...
@@ -9,6 +9,7 @@ import com.onsiteservice.entity.service.ServiceValuator;
import
com.onsiteservice.entity.service.ServiceValuatorAssign
;
import
com.onsiteservice.entity.service.ServiceValuatorAssign
;
import
com.onsiteservice.entity.user.User
;
import
com.onsiteservice.entity.user.User
;
import
com.onsiteservice.miniapp.controller.worker.vo.ServiceValuatorVO
;
import
com.onsiteservice.miniapp.controller.worker.vo.ServiceValuatorVO
;
import
com.onsiteservice.util.DateUtils
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -76,7 +77,9 @@ public class ServiceValuatorService extends AbstractMapper<ServiceValuator> {
...
@@ -76,7 +77,9 @@ public class ServiceValuatorService extends AbstractMapper<ServiceValuator> {
// 估价员已经被指派的时间
// 估价员已经被指派的时间
List
<
ServiceValuatorAssign
>
assigns
=
serviceValuatorAssignMap
.
getOrDefault
(
e1
.
getId
(),
Lists
.
newArrayList
());
List
<
ServiceValuatorAssign
>
assigns
=
serviceValuatorAssignMap
.
getOrDefault
(
e1
.
getId
(),
Lists
.
newArrayList
());
List
<
Date
>
assignTimes
=
assigns
.
parallelStream
().
map
(
ServiceValuatorAssign:
:
getAssignTime
).
collect
(
Collectors
.
toList
());
String
dateFormat
=
"yyyy-MM-dd HH:mm"
;
List
<
String
>
assignTimes
=
assigns
.
parallelStream
()
.
map
(
assign
->
DateUtils
.
formatDate
(
assign
.
getAssignTime
(),
dateFormat
)).
collect
(
Collectors
.
toList
());
serviceValuatorVO
.
setAssignTime
(
assignTimes
);
serviceValuatorVO
.
setAssignTime
(
assignTimes
);
...
...
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