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 ef4f0eca
authored
Jul 14, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
2 parents
2ff72eac
4723bf4a
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
174 additions
and
161 deletions
project-interface/src/main/java/com/dituhui/pea/common/Result.java
project-interface/src/main/java/com/dituhui/pea/order/IOrganization.java
project-interface/src/main/java/com/dituhui/pea/user/IUser.java
project-order/src/main/java/com/dituhui/pea/order/common/OrderAssignCheck.java
project-order/src/main/java/com/dituhui/pea/order/controller/PublicOrganizationController.java
project-order/src/main/java/com/dituhui/pea/order/dao/EngineerInfoMPDao.java
project-order/src/main/java/com/dituhui/pea/order/dao/EngineerSkillGroupMPDao.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderAssignImpl.java
project-user/src/main/java/com/dituhui/pea/user/controller/UserController.java
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
project-interface/src/main/java/com/dituhui/pea/common/Result.java
View file @
ef4f0ec
...
@@ -43,6 +43,10 @@ public class Result<T> {
...
@@ -43,6 +43,10 @@ public class Result<T> {
public
static
Result
<?>
failed
(
String
message
)
{
public
static
Result
<?>
failed
(
String
message
)
{
return
new
Result
<>(
ResultEnum
.
COMMON_FAILED
.
getCode
(),
message
,
null
);
return
new
Result
<>(
ResultEnum
.
COMMON_FAILED
.
getCode
(),
message
,
null
);
}
}
public
static
<
T
>
Result
<
T
>
failure
(
String
message
)
{
return
new
Result
<>(
ResultEnum
.
COMMON_FAILED
.
getCode
(),
message
,
null
);
}
public
static
Result
<?>
failed
(
IResult
errorResult
)
{
public
static
Result
<?>
failed
(
IResult
errorResult
)
{
return
new
Result
<>(
errorResult
.
getCode
(),
errorResult
.
getMessage
(),
null
);
return
new
Result
<>(
errorResult
.
getCode
(),
errorResult
.
getMessage
(),
null
);
...
...
project-interface/src/main/java/com/dituhui/pea/order/IOrganization.java
View file @
ef4f0ec
...
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
...
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.pojo.OrganizationDTO
;
/**
/**
* 组织结构相关接口
* 组织结构相关接口
...
@@ -24,7 +25,7 @@ public interface IOrganization {
...
@@ -24,7 +25,7 @@ public interface IOrganization {
* @return
* @return
*/
*/
@RequestMapping
(
value
=
"/pea-order/organization/list"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/pea-order/organization/list"
,
method
=
RequestMethod
.
GET
)
public
Result
<
?
>
getAllOrganizations
(
@RequestParam
(
"levelType"
)
String
levelType
,
public
Result
<
List
<
OrganizationDTO
>
>
getAllOrganizations
(
@RequestParam
(
"levelType"
)
String
levelType
,
@RequestParam
(
"organizationIds"
)
List
<
String
>
organizationIds
);
@RequestParam
(
"organizationIds"
)
List
<
String
>
organizationIds
);
}
}
project-interface/src/main/java/com/dituhui/pea/user/IUser.java
View file @
ef4f0ec
...
@@ -11,6 +11,7 @@ import com.dituhui.pea.common.Result;
...
@@ -11,6 +11,7 @@ import com.dituhui.pea.common.Result;
import
com.dituhui.pea.enums.ThirdPartyEnum
;
import
com.dituhui.pea.enums.ThirdPartyEnum
;
import
com.dituhui.pea.pojo.ThirdUserInfo
;
import
com.dituhui.pea.pojo.ThirdUserInfo
;
import
com.dituhui.pea.pojo.UserInfo
;
import
com.dituhui.pea.pojo.UserInfo
;
import
com.dituhui.pea.pojo.UserLoginDTO
;
import
com.dituhui.pea.pojo.UserLoginParam
;
import
com.dituhui.pea.pojo.UserLoginParam
;
import
com.dituhui.pea.pojo.WebResult
;
import
com.dituhui.pea.pojo.WebResult
;
...
@@ -22,10 +23,10 @@ import com.dituhui.pea.pojo.WebResult;
...
@@ -22,10 +23,10 @@ import com.dituhui.pea.pojo.WebResult;
public
interface
IUser
{
public
interface
IUser
{
@RequestMapping
(
value
=
"/pea-user/login"
,
method
=
RequestMethod
.
POST
)
@RequestMapping
(
value
=
"/pea-user/login"
,
method
=
RequestMethod
.
POST
)
public
Result
<
?
>
userLogin
(
@RequestBody
UserLoginParam
user
);
public
Result
<
UserLoginDTO
>
userLogin
(
@RequestBody
UserLoginParam
user
);
@RequestMapping
(
value
=
"/pea-user/userInfo"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/pea-user/userInfo"
,
method
=
RequestMethod
.
GET
)
public
Result
<
?
>
getUserInfo
(
@RequestHeader
(
name
=
"userId"
,
required
=
true
)
String
userId
);
public
Result
<
UserLoginDTO
>
getUserInfo
(
@RequestHeader
(
name
=
"userId"
,
required
=
true
)
String
userId
);
/**
/**
* 获取当前登陆用户信息
* 获取当前登陆用户信息
...
...
project-order/src/main/java/com/dituhui/pea/order/common/OrderAssignCheck.java
View file @
ef4f0ec
...
@@ -47,14 +47,16 @@ public class OrderAssignCheck {
...
@@ -47,14 +47,16 @@ public class OrderAssignCheck {
private
int
distanceAddition
;
private
int
distanceAddition
;
private
LocalDateTime
start
;
private
LocalDateTime
start
;
private
LocalDateTime
end
;
private
LocalDateTime
end
;
private
int
index
;
public
Result
(
boolean
canAssign
,
String
message
,
int
minuteAddition
,
int
distanceAddition
,
LocalDateTime
start
,
LocalDateTime
end
){
public
Result
(
boolean
canAssign
,
String
message
,
int
minuteAddition
,
int
distanceAddition
,
LocalDateTime
start
,
LocalDateTime
end
,
int
index
){
this
.
canAssign
=
canAssign
;
this
.
canAssign
=
canAssign
;
this
.
message
=
message
;
this
.
message
=
message
;
this
.
minuteAddition
=
minuteAddition
;
this
.
minuteAddition
=
minuteAddition
;
this
.
distanceAddition
=
distanceAddition
;
this
.
distanceAddition
=
distanceAddition
;
this
.
start
=
start
;
this
.
start
=
start
;
this
.
end
=
end
;
this
.
end
=
end
;
this
.
index
=
index
;
}
}
}
}
...
@@ -83,7 +85,7 @@ public class OrderAssignCheck {
...
@@ -83,7 +85,7 @@ public class OrderAssignCheck {
int
index
=
SegmentInsertion
.
insertSegment
(
takeTime
,
start
,
end
,
segments
);
int
index
=
SegmentInsertion
.
insertSegment
(
takeTime
,
start
,
end
,
segments
);
if
(
index
==
-
1
)
{
if
(
index
==
-
1
)
{
log
.
info
(
"没有可连续插入的空间"
);
log
.
info
(
"没有可连续插入的空间"
);
return
new
Result
(
false
,
"没有连续可插入空间(没计算时间)"
,
0
,
0
,
null
,
null
);
return
new
Result
(
false
,
"没有连续可插入空间(没计算时间)"
,
0
,
0
,
null
,
null
,
index
);
}
}
log
.
info
(
"插入位置为第{}单, 已分配单数(不包含本单):{}"
,
index
,
orderSegments
.
size
());
log
.
info
(
"插入位置为第{}单, 已分配单数(不包含本单):{}"
,
index
,
orderSegments
.
size
());
...
@@ -105,7 +107,7 @@ public class OrderAssignCheck {
...
@@ -105,7 +107,7 @@ public class OrderAssignCheck {
LocalDateTime
startDateTime
=
this
.
point2LocalDateTime
(
startInsert
,
order
.
getDt
());
LocalDateTime
startDateTime
=
this
.
point2LocalDateTime
(
startInsert
,
order
.
getDt
());
LocalDateTime
endDateTime
=
this
.
point2LocalDateTime
(
endInsert
,
order
.
getDt
());
LocalDateTime
endDateTime
=
this
.
point2LocalDateTime
(
endInsert
,
order
.
getDt
());
return
new
Result
(
true
,
"success"
,
0
,
0
,
startDateTime
,
endDateTime
);
return
new
Result
(
true
,
"success"
,
0
,
0
,
startDateTime
,
endDateTime
,
index
);
}
}
else
if
(
index
==
0
&&
!
orderSegments
.
isEmpty
())
{
else
if
(
index
==
0
&&
!
orderSegments
.
isEmpty
())
{
// 第一订单为出发地, 且有其他订单
// 第一订单为出发地, 且有其他订单
...
@@ -115,7 +117,7 @@ public class OrderAssignCheck {
...
@@ -115,7 +117,7 @@ public class OrderAssignCheck {
OrderSegment
post
=
orderSegments
.
get
(
0
);
OrderSegment
post
=
orderSegments
.
get
(
0
);
OrderSegment
pre
=
new
OrderSegment
(
480
,
480
,
preX
,
preY
);
OrderSegment
pre
=
new
OrderSegment
(
480
,
480
,
preX
,
preY
);
return
this
.
getResult
(
curX
,
curY
,
pre
,
post
,
takeTime
,
order
.
getDt
());
return
this
.
getResult
(
curX
,
curY
,
pre
,
post
,
takeTime
,
order
.
getDt
()
,
index
);
}
}
else
if
(
index
==
orderSegments
.
size
())
{
else
if
(
index
==
orderSegments
.
size
())
{
// 最后一个订单出发
// 最后一个订单出发
...
@@ -128,12 +130,12 @@ public class OrderAssignCheck {
...
@@ -128,12 +130,12 @@ public class OrderAssignCheck {
LocalDateTime
startDateTime
=
this
.
point2LocalDateTime
(
startInsert
,
order
.
getDt
());
LocalDateTime
startDateTime
=
this
.
point2LocalDateTime
(
startInsert
,
order
.
getDt
());
LocalDateTime
endDateTime
=
this
.
point2LocalDateTime
(
endInsert
,
order
.
getDt
());
LocalDateTime
endDateTime
=
this
.
point2LocalDateTime
(
endInsert
,
order
.
getDt
());
return
new
Result
(
true
,
"success"
,
0
,
0
,
startDateTime
,
endDateTime
);
return
new
Result
(
true
,
"success"
,
0
,
0
,
startDateTime
,
endDateTime
,
index
);
}
else
{
}
else
{
OrderSegment
pre
=
orderSegments
.
get
(
index
-
1
);
OrderSegment
pre
=
orderSegments
.
get
(
index
-
1
);
OrderSegment
post
=
orderSegments
.
get
(
index
);
OrderSegment
post
=
orderSegments
.
get
(
index
);
return
this
.
getResult
(
curX
,
curY
,
pre
,
post
,
takeTime
,
order
.
getDt
());
return
this
.
getResult
(
curX
,
curY
,
pre
,
post
,
takeTime
,
order
.
getDt
()
,
index
);
}
}
}
}
...
@@ -181,7 +183,7 @@ public class OrderAssignCheck {
...
@@ -181,7 +183,7 @@ public class OrderAssignCheck {
return
segments
;
return
segments
;
}
}
private
Result
getResult
(
double
curX
,
double
curY
,
OrderSegment
pre
,
OrderSegment
post
,
int
takeTime
,
LocalDate
dt
)
{
private
Result
getResult
(
double
curX
,
double
curY
,
OrderSegment
pre
,
OrderSegment
post
,
int
takeTime
,
LocalDate
dt
,
int
index
)
{
Pair
preCurPair
=
this
.
getDistanceAndDuration
(
pre
.
getX
(),
pre
.
getY
(),
curX
,
curY
);
Pair
preCurPair
=
this
.
getDistanceAndDuration
(
pre
.
getX
(),
pre
.
getY
(),
curX
,
curY
);
Pair
postCurPair
=
this
.
getDistanceAndDuration
(
post
.
getX
(),
post
.
getY
(),
curX
,
curY
);
Pair
postCurPair
=
this
.
getDistanceAndDuration
(
post
.
getX
(),
post
.
getY
(),
curX
,
curY
);
Pair
prePostPair
=
this
.
getDistanceAndDuration
(
post
.
getX
(),
post
.
getY
(),
pre
.
getX
(),
pre
.
getY
());
Pair
prePostPair
=
this
.
getDistanceAndDuration
(
post
.
getX
(),
post
.
getY
(),
pre
.
getX
(),
pre
.
getY
());
...
@@ -190,7 +192,7 @@ public class OrderAssignCheck {
...
@@ -190,7 +192,7 @@ public class OrderAssignCheck {
int
distance
=
post
.
getStart
()
-
postCurPair
.
getDuration
()
-
(
pre
.
getEnd
()
+
preCurPair
.
getDuration
());
int
distance
=
post
.
getStart
()
-
postCurPair
.
getDuration
()
-
(
pre
.
getEnd
()
+
preCurPair
.
getDuration
());
if
(
distance
<
takeTime
)
{
if
(
distance
<
takeTime
)
{
// 不支持插入
// 不支持插入
return
new
Result
(
false
,
"增加时间路程后,不支持插入"
,
0
,
0
,
null
,
null
);
return
new
Result
(
false
,
"增加时间路程后,不支持插入"
,
0
,
0
,
null
,
null
,
index
);
}
}
// 插入点(时间点)
// 插入点(时间点)
int
startInsert
=
pre
.
getEnd
()
+
preCurPair
.
getDuration
();
int
startInsert
=
pre
.
getEnd
()
+
preCurPair
.
getDuration
();
...
@@ -200,7 +202,7 @@ public class OrderAssignCheck {
...
@@ -200,7 +202,7 @@ public class OrderAssignCheck {
int
minuteAddition
=
preCurPair
.
getDuration
()
+
postCurPair
.
getDuration
()
-
prePostPair
.
getDuration
();
int
minuteAddition
=
preCurPair
.
getDuration
()
+
postCurPair
.
getDuration
()
-
prePostPair
.
getDuration
();
int
distanceAddition
=
preCurPair
.
getDistance
()
+
postCurPair
.
getDistance
()
-
prePostPair
.
getDistance
();
int
distanceAddition
=
preCurPair
.
getDistance
()
+
postCurPair
.
getDistance
()
-
prePostPair
.
getDistance
();
return
new
Result
(
true
,
"success"
,
minuteAddition
,
distanceAddition
,
startDateTime
,
endDateTime
);
return
new
Result
(
true
,
"success"
,
minuteAddition
,
distanceAddition
,
startDateTime
,
endDateTime
,
index
);
}
}
private
double
[]
getEngineerDepartureLocation
(
String
engineerCode
){
private
double
[]
getEngineerDepartureLocation
(
String
engineerCode
){
...
...
project-order/src/main/java/com/dituhui/pea/order/controller/PublicOrganizationController.java
View file @
ef4f0ec
...
@@ -24,20 +24,20 @@ public class PublicOrganizationController implements IOrganization {
...
@@ -24,20 +24,20 @@ public class PublicOrganizationController implements IOrganization {
private
OrganizationService
organizationService
;
private
OrganizationService
organizationService
;
@Override
@Override
public
Result
<
?
>
getAllOrganizations
(
String
levelType
,
List
<
String
>
organizationIds
)
{
public
Result
<
List
<
OrganizationDTO
>
>
getAllOrganizations
(
String
levelType
,
List
<
String
>
organizationIds
)
{
if
(
StringUtils
.
isEmpty
(
levelType
))
{
if
(
StringUtils
.
isEmpty
(
levelType
))
{
return
Result
.
fail
ed
(
"缺少参数levelType"
);
return
Result
.
fail
ure
(
"缺少参数levelType"
);
}
}
if
(
CollectionUtils
.
isEmpty
(
organizationIds
))
{
if
(
CollectionUtils
.
isEmpty
(
organizationIds
))
{
return
Result
.
fail
ed
(
"缺少参数organizationIds"
);
return
Result
.
fail
ure
(
"缺少参数organizationIds"
);
}
}
Result
<
?
>
res
=
null
;
Result
<
List
<
OrganizationDTO
>
>
res
=
null
;
try
{
try
{
List
<
OrganizationDTO
>
orgs
=
organizationService
.
getAllOrganizations
(
levelType
,
organizationIds
);
List
<
OrganizationDTO
>
orgs
=
organizationService
.
getAllOrganizations
(
levelType
,
organizationIds
);
res
=
Result
.
success
(
orgs
);
res
=
Result
.
success
(
orgs
);
}
catch
(
BusinessException
e
)
{
}
catch
(
BusinessException
e
)
{
return
Result
.
fail
ed
(
e
.
getMessage
());
return
Result
.
fail
ure
(
e
.
getMessage
());
}
}
return
res
;
return
res
;
}
}
...
...
project-order/src/main/java/com/dituhui/pea/order/dao/EngineerInfoMPDao.java
View file @
ef4f0ec
...
@@ -23,4 +23,8 @@ public interface EngineerInfoMPDao extends BaseMapper<EngineerInfo> {
...
@@ -23,4 +23,8 @@ public interface EngineerInfoMPDao extends BaseMapper<EngineerInfo> {
@Select
(
"select * from engineer_info where group_id = #{groupId}"
)
@Select
(
"select * from engineer_info where group_id = #{groupId}"
)
List
<
EngineerInfo
>
selectByGroupId
(
String
groupId
);
List
<
EngineerInfo
>
selectByGroupId
(
String
groupId
);
@Select
(
"<script> select * from engineer_info where group_id in "
+
"<foreach item='groupId' collection='groupIds' open='(' separator=',' close=')'>#{groupId}</foreach></script>"
)
List
<
EngineerInfo
>
selectByGroupIds
(
@Param
(
"groupIds"
)
List
<
String
>
groupIds
);
}
}
\ No newline at end of file
project-order/src/main/java/com/dituhui/pea/order/dao/EngineerSkillGroupMPDao.java
View file @
ef4f0ec
...
@@ -12,4 +12,7 @@ import java.util.List;
...
@@ -12,4 +12,7 @@ import java.util.List;
public
interface
EngineerSkillGroupMPDao
extends
BaseMapper
<
EngineerSkillGroup
>
{
public
interface
EngineerSkillGroupMPDao
extends
BaseMapper
<
EngineerSkillGroup
>
{
@Select
(
"select * from engineer_skill_group where engineer_code = #{engineerCode}"
)
@Select
(
"select * from engineer_skill_group where engineer_code = #{engineerCode}"
)
List
<
EngineerSkillGroup
>
selectByEngineerCode
(
String
engineerCode
);
List
<
EngineerSkillGroup
>
selectByEngineerCode
(
String
engineerCode
);
@Select
(
"select * from engineer_skill_group where skill_group_code = #{skillGroupCode}"
)
List
<
EngineerSkillGroup
>
selectBySkillGroupCode
(
String
skillGroupCode
);
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderAssignImpl.java
View file @
ef4f0ec
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.common.OrderAssignCheck
;
import
com.dituhui.pea.order.common.OrderAssignCheck
;
import
com.dituhui.pea.order.common.TimeUtils
;
import
com.dituhui.pea.order.common.TimeUtils
;
import
com.dituhui.pea.order.dao.EngineerInfoMPDao
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dao.OrderAppointmentMPDao
;
import
com.dituhui.pea.order.dao.OrderEventMPDao
;
import
com.dituhui.pea.order.dao.OrderRequestMPDao
;
import
com.dituhui.pea.order.dto.LabelValueDTO
;
import
com.dituhui.pea.order.dto.LabelValueDTO
;
import
com.dituhui.pea.order.dto.OrderAssignRecommendResp
;
import
com.dituhui.pea.order.dto.OrderAssignRecommendResp
;
import
com.dituhui.pea.order.dto.TimeLineDTO
;
import
com.dituhui.pea.order.dto.TimeLineDTO
;
import
com.dituhui.pea.order.entity.EngineerInfo
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.entity.OrderAppointment
;
import
com.dituhui.pea.order.entity.OrderEvent
;
import
com.dituhui.pea.order.entity.OrderRequest
;
import
com.dituhui.pea.order.service.CommonService
;
import
com.dituhui.pea.order.service.CommonService
;
import
com.dituhui.pea.order.service.OrderAssign
;
import
com.dituhui.pea.order.service.OrderAssign
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -27,10 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -27,10 +22,7 @@ import org.springframework.transaction.annotation.Transactional;
import
java.sql.Timestamp
;
import
java.sql.Timestamp
;
import
java.time.LocalDate
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.*
;
import
java.util.Comparator
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
...
@@ -55,6 +47,18 @@ public class OrderAssignImpl implements OrderAssign {
...
@@ -55,6 +47,18 @@ public class OrderAssignImpl implements OrderAssign {
@Autowired
@Autowired
private
OrderAssignCheck
orderAssignCheck
;
private
OrderAssignCheck
orderAssignCheck
;
@Autowired
private
OrgTeamMPDao
orgTeamMPDao
;
@Autowired
private
OrgTeamEngineerMPDao
orgTeamEngineerMPDao
;
@Autowired
private
SkillInfoMPDao
skillInfoMPDao
;
@Autowired
private
EngineerSkillGroupMPDao
engineerSkillGroupMPDao
;
@Transactional
@Transactional
@Override
@Override
public
Result
<?>
getOrderAssignRecommendEngineers
(
String
orderId
,
String
key
,
String
distance
,
String
recommend
)
{
public
Result
<?>
getOrderAssignRecommendEngineers
(
String
orderId
,
String
key
,
String
distance
,
String
recommend
)
{
...
@@ -67,18 +71,21 @@ public class OrderAssignImpl implements OrderAssign {
...
@@ -67,18 +71,21 @@ public class OrderAssignImpl implements OrderAssign {
String
date
=
TimeUtils
.
timestamp2DateTime
(
order
.
getExpectTimeBegin
(),
TimeUtils
.
DATE_GAP_FORMAT
);
String
date
=
TimeUtils
.
timestamp2DateTime
(
order
.
getExpectTimeBegin
(),
TimeUtils
.
DATE_GAP_FORMAT
);
// 获取group内的小组成员
// 获取group内的小组成员
List
<
EngineerInfo
>
engineers
=
engineerInfoMPDao
.
selectByGroupId
(
order
.
getOrgGroupId
());
List
<
String
>
engineerCodes
=
this
.
searchEngineerCodes
(
order
,
distance
,
key
,
recommend
);
List
<
EngineerInfo
>
engineers
=
engineerInfoMPDao
.
selectByEngineerCodes
(
engineerCodes
);
List
<
OrderAssignRecommendResp
.
Engineer
>
items
=
new
ArrayList
<>();
List
<
OrderAssignRecommendResp
.
Engineer
>
items
=
new
ArrayList
<>();
OrderRecommend
or
=
new
OrderRecommend
();
for
(
EngineerInfo
engineer
:
engineers
)
{
for
(
EngineerInfo
engineer
:
engineers
)
{
List
<
OrderAppointment
>
orderAppointments
=
orderAppointmentMPDao
.
selectByEngineerCodeAndDt
(
engineer
.
getEngineerCode
(),
order
.
getDt
());
RecommendResult
rr
=
or
.
recommend
(
order
,
orderAppointments
);
OrderAssignCheck
.
Result
result
=
orderAssignCheck
.
orderAssignCheck
(
orderId
,
engineer
.
getEngineerCode
());
if
(
rr
.
getIndex
()
==
-
1
)
{
log
.
info
(
"指派检查结果:{}"
,
result
);
if
(!
result
.
getCanAssign
())
{
continue
;
continue
;
}
}
List
<
OrderAppointment
>
orderAppointments
=
orderAppointmentMPDao
.
selectByEngineerCodeAndDt
(
engineer
.
getEngineerCode
(),
order
.
getDt
());
// 获取订单tips
// 获取订单tips
HashMap
<
String
,
List
<
LabelValueDTO
>>
orderTips
=
new
HashMap
<>();
HashMap
<
String
,
List
<
LabelValueDTO
>>
orderTips
=
new
HashMap
<>();
List
<
String
>
orderIds
=
orderAppointments
.
stream
().
map
(
OrderAppointment:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
String
>
orderIds
=
orderAppointments
.
stream
().
map
(
OrderAppointment:
:
getOrderId
).
collect
(
Collectors
.
toList
());
...
@@ -90,17 +97,19 @@ public class OrderAssignImpl implements OrderAssign {
...
@@ -90,17 +97,19 @@ public class OrderAssignImpl implements OrderAssign {
OrderAssignRecommendResp
.
Engineer
item
=
new
OrderAssignRecommendResp
.
Engineer
();
OrderAssignRecommendResp
.
Engineer
item
=
new
OrderAssignRecommendResp
.
Engineer
();
OrderAssignRecommendResp
.
InsertInfo
insertInfo
=
new
OrderAssignRecommendResp
.
InsertInfo
();
OrderAssignRecommendResp
.
InsertInfo
insertInfo
=
new
OrderAssignRecommendResp
.
InsertInfo
();
insertInfo
.
setNumber
(
String
.
format
(
"%d/%d"
,
r
r
.
index
+
1
,
orderAppointments
.
size
()
+
1
));
insertInfo
.
setNumber
(
String
.
format
(
"%d/%d"
,
r
esult
.
getIndex
()
,
orderAppointments
.
size
()
+
1
));
insertInfo
.
setTimeDesc
(
"+30分钟"
);
insertInfo
.
setTimeDesc
(
String
.
format
(
"+%d分钟"
,
result
.
getMinuteAddition
())
);
insertInfo
.
setDistanceDesc
(
"+4公里"
);
insertInfo
.
setDistanceDesc
(
String
.
format
(
"+%d公里"
,
result
.
getDistanceAddition
()
/
1000
)
);
item
.
setEngineerCode
(
engineer
.
getEngineerCode
());
item
.
setEngineerCode
(
engineer
.
getEngineerCode
());
item
.
setEngineerName
(
engineer
.
getName
());
item
.
setEngineerName
(
engineer
.
getName
());
item
.
setLocation
(
"120.753872,31.312792"
);
item
.
setLocation
(
String
.
format
(
"%s,%s"
,
order
.
getX
(),
order
.
getY
())
);
item
.
setInsertInfo
(
insertInfo
);
item
.
setInsertInfo
(
insertInfo
);
item
.
setDistanceDesc
(
"15.5公里"
);
item
.
setDistanceDesc
(
""
);
item
.
setTimeDesc
(
"520分钟"
);
item
.
setTimeDesc
(
""
);
item
.
setDesc
(
String
.
format
(
"将被插入在第%d单,受此影响原第%d单变化第%d单,第3单将增加5公里路程,比预计晚到30分钟,建议调整;"
,
rr
.
index
+
1
,
rr
.
index
+
1
,
rr
.
index
+
2
));
int
index
=
result
.
getIndex
()
+
1
;
item
.
setDesc
(
String
.
format
(
"将被插入在第%d单,受此影响原第%d单变化第%d单,第%d单将增加%d公里路程,比预计晚到%d分钟,建议调整;"
,
index
,
index
,
index
+
1
,
index
+
1
,
result
.
getDistanceAddition
()
/
1000
,
result
.
getMinuteAddition
()));
item
.
setStartTime
(
String
.
format
(
"%s 08:00:00"
,
date
));
item
.
setStartTime
(
String
.
format
(
"%s 08:00:00"
,
date
));
item
.
setEndTime
(
String
.
format
(
"%s 18:00:00"
,
date
));
item
.
setEndTime
(
String
.
format
(
"%s 18:00:00"
,
date
));
item
.
setOrders
(
this
.
packTimelines
(
orderAppointments
,
orderTips
));
item
.
setOrders
(
this
.
packTimelines
(
orderAppointments
,
orderTips
));
...
@@ -126,24 +135,24 @@ public class OrderAssignImpl implements OrderAssign {
...
@@ -126,24 +135,24 @@ public class OrderAssignImpl implements OrderAssign {
boolean
record
=
false
;
boolean
record
=
false
;
OrderAppointment
op
=
orderAppointmentMPDao
.
getByOrderIdAndDt
(
orderId
,
order
.
getDt
());
OrderAppointment
op
=
orderAppointmentMPDao
.
getByOrderIdAndDt
(
orderId
,
order
.
getDt
());
if
(
op
!=
null
)
{
if
(
op
!=
null
)
{
record
=
true
;
record
=
true
;
}
}
if
(
op
!=
null
&&
!
order
.
getAppointmentStatus
().
equals
(
"NOT_ASSIGNED"
)
&&
op
.
getEngineerCode
().
equals
(
engineerCode
))
{
if
(
op
!=
null
&&
!
order
.
getAppointmentStatus
().
equals
(
"NOT_ASSIGNED"
)
&&
op
.
getEngineerCode
().
equals
(
engineerCode
))
{
throw
new
BusinessException
(
String
.
format
(
"订单已指派个技术员[%s], 不必重复指派给同一个技术员"
,
engineer
.
getName
()));
throw
new
BusinessException
(
String
.
format
(
"订单已指派个技术员[%s], 不必重复指派给同一个技术员"
,
engineer
.
getName
()));
}
}
OrderAssignCheck
.
Result
result
=
orderAssignCheck
.
orderAssignCheck
(
orderId
,
engineerCode
);
OrderAssignCheck
.
Result
result
=
orderAssignCheck
.
orderAssignCheck
(
orderId
,
engineerCode
);
log
.
info
(
"指派检查结果:{}"
,
result
);
log
.
info
(
"指派检查结果:{}"
,
result
);
if
(!
result
.
getCanAssign
())
{
if
(!
result
.
getCanAssign
())
{
throw
new
BusinessException
(
"指派失败, 未能找到合适的时间段, 请选择其他技术员"
);
throw
new
BusinessException
(
"指派失败, 未能找到合适的时间段, 请选择其他技术员"
);
}
}
Timestamp
expectStartTime
=
Timestamp
.
valueOf
(
result
.
getStart
());
;
Timestamp
expectStartTime
=
Timestamp
.
valueOf
(
result
.
getStart
());
Timestamp
expectEndTime
=
Timestamp
.
valueOf
(
result
.
getEnd
());
Timestamp
expectEndTime
=
Timestamp
.
valueOf
(
result
.
getEnd
());
// 更新或插入指派单
// 更新或插入指派单
if
(!
record
)
{
if
(!
record
)
{
op
=
new
OrderAppointment
();
op
=
new
OrderAppointment
();
}
}
op
.
setOrderId
(
orderId
);
op
.
setOrderId
(
orderId
);
...
@@ -160,7 +169,7 @@ public class OrderAssignImpl implements OrderAssign {
...
@@ -160,7 +169,7 @@ public class OrderAssignImpl implements OrderAssign {
op
.
setPreStatus
(
"CONFIRM"
);
op
.
setPreStatus
(
"CONFIRM"
);
op
.
setStatus
(
"ASSIGNED"
);
op
.
setStatus
(
"ASSIGNED"
);
if
(!
record
)
{
if
(!
record
)
{
orderAppointmentMPDao
.
insert
(
op
);
orderAppointmentMPDao
.
insert
(
op
);
}
else
{
}
else
{
orderAppointmentMPDao
.
updateById
(
op
);
orderAppointmentMPDao
.
updateById
(
op
);
...
@@ -174,15 +183,15 @@ public class OrderAssignImpl implements OrderAssign {
...
@@ -174,15 +183,15 @@ public class OrderAssignImpl implements OrderAssign {
orderRequestMPDao
.
update
(
null
,
wrapper
);
orderRequestMPDao
.
update
(
null
,
wrapper
);
// 工单变更登记
// 工单变更登记
commonService
.
addOrderEvent
(
orderId
,
""
,
"PEA-WEB"
,
"API"
,
"工单指派"
,
"工单指派"
,
""
);
commonService
.
addOrderEvent
(
orderId
,
""
,
"PEA-WEB"
,
"API"
,
"工单指派"
,
"工单指派"
,
""
);
return
Result
.
success
(
null
);
return
Result
.
success
(
null
);
}
}
@Override
@Override
public
Result
<?>
orderRevokeAssign
(
String
orderId
)
throws
BusinessException
{
public
Result
<?>
orderRevokeAssign
(
String
orderId
)
throws
BusinessException
{
OrderRequest
order
=
orderRequestMPDao
.
getByOrderId
(
orderId
);
OrderRequest
order
=
orderRequestMPDao
.
getByOrderId
(
orderId
);
if
(
order
==
null
){
if
(
order
==
null
)
{
throw
new
BusinessException
(
"订单不存在"
);
throw
new
BusinessException
(
"订单不存在"
);
}
}
...
@@ -214,16 +223,16 @@ public class OrderAssignImpl implements OrderAssign {
...
@@ -214,16 +223,16 @@ public class OrderAssignImpl implements OrderAssign {
}
}
@Override
@Override
public
Result
<?>
orderReschedule
(
String
orderId
,
LocalDateTime
expectBegin
,
LocalDateTime
expectEnd
,
String
expectDesc
)
throws
BusinessException
{
public
Result
<?>
orderReschedule
(
String
orderId
,
LocalDateTime
expectBegin
,
LocalDateTime
expectEnd
,
String
expectDesc
)
throws
BusinessException
{
// 工单改约接口(当前同放回工单池处理)
// 工单改约接口(当前同放回工单池处理)
OrderRequest
order
=
orderRequestMPDao
.
getByOrderId
(
orderId
);
OrderRequest
order
=
orderRequestMPDao
.
getByOrderId
(
orderId
);
if
(
order
==
null
){
if
(
order
==
null
)
{
throw
new
BusinessException
(
"订单不存在"
);
throw
new
BusinessException
(
"订单不存在"
);
}
}
if
(
order
.
getDt
().
isEqual
(
expectBegin
.
toLocalDate
()))
{
if
(
order
.
getDt
().
isEqual
(
expectBegin
.
toLocalDate
()))
{
throw
new
BusinessException
(
"改约日期不应与之前日期相同"
);
throw
new
BusinessException
(
"改约日期不应与之前日期相同"
);
}
}
if
(
LocalDate
.
now
().
isAfter
(
expectBegin
.
toLocalDate
())){
if
(
LocalDate
.
now
().
isAfter
(
expectBegin
.
toLocalDate
()))
{
throw
new
BusinessException
(
"改约日期不能小于今日"
);
throw
new
BusinessException
(
"改约日期不能小于今日"
);
}
}
...
@@ -260,10 +269,91 @@ public class OrderAssignImpl implements OrderAssign {
...
@@ -260,10 +269,91 @@ public class OrderAssignImpl implements OrderAssign {
return
Result
.
success
(
null
);
return
Result
.
success
(
null
);
}
}
private
List
<
String
>
searchEngineerCodes
(
Integer
distance
,
String
key
,
String
recommend
){
private
List
<
String
>
searchEngineerCodes
(
OrderRequest
order
,
String
distance
,
String
key
,
String
recommend
)
{
Set
<
String
>
engineerCodes1
=
this
.
searchEngineerByRecommend
(
order
,
recommend
);
if
(
engineerCodes1
.
isEmpty
())
{
log
.
info
(
"recommend:{}筛选条件未找到技术员"
,
recommend
);
return
new
ArrayList
<>();
}
if
(
StringUtils
.
isNotEmpty
(
key
))
{
Set
<
String
>
engineerCodes2
=
this
.
searchEngineerByKey
(
key
);
if
(
engineerCodes2
.
isEmpty
())
{
log
.
info
(
"key:{}筛选条件未找到技术员"
,
key
);
return
new
ArrayList
<>();
}
engineerCodes1
.
retainAll
(
engineerCodes2
);
if
(
engineerCodes1
.
isEmpty
())
{
log
.
info
(
"recommend:{} 与 key:{}筛选条件交集未找到技术员"
,
recommend
,
key
);
return
new
ArrayList
<>();
}
}
// 匹配技能
SkillInfo
skill
=
skillInfoMPDao
.
getByBrandAndTypeAndSkill
(
order
.
getBrand
(),
order
.
getType
(),
order
.
getSkill
());
if
(
skill
==
null
)
{
log
.
info
(
"skill_info表没有匹配到技能配置:{}-{}-{}"
,
order
.
getBrand
(),
order
.
getY
(),
order
.
getSkill
());
return
new
ArrayList
<>();
}
Set
<
String
>
engineerCodes3
=
engineerSkillGroupMPDao
.
selectBySkillGroupCode
(
skill
.
getSkillGroupCode
()).
stream
().
map
(
EngineerSkillGroup:
:
getEngineerCode
).
collect
(
Collectors
.
toSet
());
if
(
engineerCodes3
.
isEmpty
())
{
log
.
info
(
"没有匹配到技能相匹配的技术员:{}-{}-{}"
,
order
.
getBrand
(),
order
.
getType
(),
order
.
getSkill
());
return
new
ArrayList
<>();
}
engineerCodes1
.
retainAll
(
engineerCodes3
);
if
(
engineerCodes1
.
isEmpty
())
{
log
.
info
(
"recommend:{} 与 key:{}筛选条件, 与技术员所需要的技能:{}-{}-{}交集未找到技术员"
,
recommend
,
key
,
order
.
getBrand
(),
order
.
getType
(),
order
.
getSkill
());
return
new
ArrayList
<>();
}
if
(
StringUtils
.
isEmpty
(
distance
))
{
return
new
ArrayList
<>(
engineerCodes1
);
}
//进行距离匹配TODO
return
null
;
return
null
;
}
}
private
Set
<
String
>
searchEngineerByRecommend
(
OrderRequest
order
,
String
recommend
)
{
if
(
StringUtils
.
isNotEmpty
(
recommend
)
&&
recommend
.
equals
(
"team"
))
{
return
orgTeamEngineerMPDao
.
selectByTeamId
(
order
.
getOrgTeamId
()).
stream
().
map
(
OrgTeamEngineer:
:
getEngineerCode
).
collect
(
Collectors
.
toSet
());
}
String
levelType
;
String
levelValue
;
if
(
StringUtils
.
isEmpty
(
recommend
)
||
recommend
.
equals
(
"branch"
))
{
levelType
=
"branch"
;
levelValue
=
order
.
getOrgBranchId
();
}
else
if
(
recommend
.
equals
(
"group"
))
{
levelType
=
"group"
;
levelValue
=
order
.
getOrgGroupId
();
}
else
{
return
new
HashSet
<>();
}
LambdaQueryWrapper
<
OrgTeam
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
levelType
.
equals
(
"cluster"
),
OrgTeam:
:
getClusterId
,
levelValue
);
lqw
.
eq
(
levelType
.
equals
(
"branch"
),
OrgTeam:
:
getBranchId
,
levelValue
);
lqw
.
eq
(
levelType
.
equals
(
"group"
),
OrgTeam:
:
getGroupId
,
levelValue
);
lqw
.
eq
(
levelType
.
equals
(
"team"
),
OrgTeam:
:
getTeamId
,
levelValue
);
List
<
String
>
groupIds
=
orgTeamMPDao
.
selectList
(
lqw
).
stream
().
map
(
OrgTeam:
:
getGroupId
).
collect
(
Collectors
.
toList
());
return
engineerInfoMPDao
.
selectByGroupIds
(
groupIds
).
stream
().
map
(
EngineerInfo:
:
getEngineerCode
).
collect
(
Collectors
.
toSet
());
}
private
Set
<
String
>
searchEngineerByKey
(
String
key
)
{
LambdaQueryWrapper
<
EngineerInfo
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
EngineerInfo:
:
getBeanStatus
,
1
);
if
(
StringUtils
.
isNotEmpty
(
key
))
{
lqw
.
and
(
w
->
w
.
like
(
EngineerInfo:
:
getPhone
,
key
)
.
or
()
.
like
(
EngineerInfo:
:
getName
,
key
)
.
or
()
.
like
(
EngineerInfo:
:
getEngineerCode
,
key
)
);
}
return
engineerInfoMPDao
.
selectList
(
lqw
).
stream
().
map
(
EngineerInfo:
:
getEngineerCode
).
collect
(
Collectors
.
toSet
());
}
private
List
<
TimeLineDTO
>
packTimelines
(
List
<
OrderAppointment
>
orders
,
HashMap
<
String
,
List
<
LabelValueDTO
>>
orderTips
)
{
private
List
<
TimeLineDTO
>
packTimelines
(
List
<
OrderAppointment
>
orders
,
HashMap
<
String
,
List
<
LabelValueDTO
>>
orderTips
)
{
List
<
LabelValueDTO
>
empty
=
new
ArrayList
<>();
List
<
LabelValueDTO
>
empty
=
new
ArrayList
<>();
...
@@ -297,90 +387,4 @@ public class OrderAssignImpl implements OrderAssign {
...
@@ -297,90 +387,4 @@ public class OrderAssignImpl implements OrderAssign {
items
.
add
(
new
LabelValueDTO
(
"标签"
,
order
.
getTags
()));
items
.
add
(
new
LabelValueDTO
(
"标签"
,
order
.
getTags
()));
return
items
;
return
items
;
}
}
}
}
\ No newline at end of file
@Data
class
RecommendResult
{
int
index
;
LineSegment
seg
;
}
class
Recommend
{
public
RecommendResult
recommend
(
List
<
LineSegment
>
used
,
Line
task
)
{
used
.
sort
(
Comparator
.
comparingInt
(
a
->
a
.
start
));
String
taskId
=
task
.
id
;
int
taskLength
=
task
.
length
;
boolean
scheduled
=
false
;
int
startRange
=
480
;
int
endRange
=
1440
;
RecommendResult
result
=
new
RecommendResult
();
if
(!
scheduled
)
{
for
(
int
i
=
0
;
i
<=
used
.
size
();
i
++)
{
int
start
;
if
(
i
==
0
)
{
start
=
startRange
;
}
else
{
start
=
used
.
get
(
i
-
1
).
end
;
}
int
end
;
if
(
i
==
used
.
size
()
||
used
.
get
(
i
).
start
>
endRange
)
{
end
=
endRange
;
}
else
{
end
=
used
.
get
(
i
).
start
;
}
if
(
end
-
start
>=
taskLength
)
{
int
taskStart
=
start
;
int
taskEnd
=
start
+
taskLength
;
LineSegment
s
=
new
LineSegment
(
taskId
,
taskStart
,
taskEnd
);
result
.
setIndex
(
i
);
result
.
setSeg
(
s
);
return
result
;
}
}
}
result
.
setIndex
(-
1
);
result
.
setSeg
(
null
);
return
result
;
}
}
class
OrderRecommend
{
public
RecommendResult
recommend
(
OrderRequest
orderRequest
,
List
<
OrderAppointment
>
orderAppointments
)
{
List
<
LineSegment
>
used
=
new
ArrayList
<>();
for
(
OrderAppointment
o
:
orderAppointments
)
{
LineSegment
s
=
new
LineSegment
(
o
.
getOrderId
(),
this
.
Timestamp2LinePoint
(
o
.
getExpectStartTime
()),
this
.
Timestamp2LinePoint
(
o
.
getExpectEndTime
()));
used
.
add
(
s
);
}
Line
task
=
new
Line
(
orderRequest
.
getOrderId
(),
30
);
Recommend
r
=
new
Recommend
();
return
r
.
recommend
(
used
,
task
);
}
public
int
Timestamp2LinePoint
(
Timestamp
t
)
{
LocalDateTime
datetime
=
t
.
toLocalDateTime
();
return
datetime
.
getHour
()
*
60
+
datetime
.
getMinute
();
}
public
Timestamp
linePoint2Timestamp
(
int
x
,
String
date
)
{
int
base
=
60
;
int
hour
=
x
/
base
;
int
minute
=
x
%
base
;
String
datetime
=
String
.
format
(
"%s %d:%d:00"
,
date
,
hour
,
minute
);
return
Timestamp
.
valueOf
(
datetime
);
}
}
project-user/src/main/java/com/dituhui/pea/user/controller/UserController.java
View file @
ef4f0ec
...
@@ -13,6 +13,7 @@ import com.dituhui.pea.enums.ThirdPartyEnum;
...
@@ -13,6 +13,7 @@ import com.dituhui.pea.enums.ThirdPartyEnum;
import
com.dituhui.pea.pojo.ThirdUserInfo
;
import
com.dituhui.pea.pojo.ThirdUserInfo
;
import
com.dituhui.pea.pojo.UserAuthInfo
;
import
com.dituhui.pea.pojo.UserAuthInfo
;
import
com.dituhui.pea.pojo.UserInfo
;
import
com.dituhui.pea.pojo.UserInfo
;
import
com.dituhui.pea.pojo.UserLoginDTO
;
import
com.dituhui.pea.pojo.UserLoginParam
;
import
com.dituhui.pea.pojo.UserLoginParam
;
import
com.dituhui.pea.pojo.WebResult
;
import
com.dituhui.pea.pojo.WebResult
;
import
com.dituhui.pea.user.IUser
;
import
com.dituhui.pea.user.IUser
;
...
@@ -32,12 +33,12 @@ public class UserController implements IUser {
...
@@ -32,12 +33,12 @@ public class UserController implements IUser {
private
UserService
userService
;
private
UserService
userService
;
@Override
@Override
public
Result
<
?
>
userLogin
(
UserLoginParam
user
)
{
public
Result
<
UserLoginDTO
>
userLogin
(
UserLoginParam
user
)
{
return
userService
.
userLogin
(
user
.
getAccount
(),
user
.
getPassword
());
return
userService
.
userLogin
(
user
.
getAccount
(),
user
.
getPassword
());
}
}
@Override
@Override
public
Result
<
?
>
getUserInfo
(
String
userId
)
{
public
Result
<
UserLoginDTO
>
getUserInfo
(
String
userId
)
{
return
userService
.
getUserInfo
(
userId
);
return
userService
.
getUserInfo
(
userId
);
}
}
...
...
project-user/src/main/java/com/dituhui/pea/user/service/UserService.java
View file @
ef4f0ec
...
@@ -93,12 +93,11 @@ public class UserService {
...
@@ -93,12 +93,11 @@ public class UserService {
@Autowired
@Autowired
IOrganization
organizationService
;
IOrganization
organizationService
;
public
Result
<
?
>
userLogin
(
String
account
,
String
password
)
{
public
Result
<
UserLoginDTO
>
userLogin
(
String
account
,
String
password
)
{
UserEntity
user
=
userDao
.
findByAccountAndPassword
(
account
,
SecureUtil
.
md5
(
password
));
UserEntity
user
=
userDao
.
findByAccountAndPassword
(
account
,
SecureUtil
.
md5
(
password
));
log
.
info
(
"{}/{} login"
,
account
,
password
);
log
.
info
(
"{}/{} login"
,
account
,
password
);
if
(
null
!=
user
)
{
if
(
null
!=
user
)
{
UserLoginDTO
userDTO
=
convertToUserLoginDTO
(
user
);
UserLoginDTO
userDTO
=
convertToUserLoginDTO
(
user
);
// 生成token
// 生成token
String
token
=
IdUtil
.
simpleUUID
();
String
token
=
IdUtil
.
simpleUUID
();
userDTO
.
setToken
(
token
);
userDTO
.
setToken
(
token
);
...
@@ -106,7 +105,7 @@ public class UserService {
...
@@ -106,7 +105,7 @@ public class UserService {
redisService
.
set
(
RedisKeyGroup
.
authToken
+
":"
+
token
,
gson
.
toJson
(
userDTO
),
timestamp
/
1000
);
redisService
.
set
(
RedisKeyGroup
.
authToken
+
":"
+
token
,
gson
.
toJson
(
userDTO
),
timestamp
/
1000
);
return
Result
.
success
(
userDTO
);
return
Result
.
success
(
userDTO
);
}
else
{
}
else
{
return
Result
.
fail
ed
(
"鉴权失败"
);
return
Result
.
fail
ure
(
"鉴权失败"
);
}
}
}
}
...
@@ -151,24 +150,16 @@ public class UserService {
...
@@ -151,24 +150,16 @@ public class UserService {
List
<
OrganizationDTO
>
allOrgs
=
resources
.
stream
().
filter
(
r
->
r
.
getType
()
==
3
).
map
(
r
->
{
List
<
OrganizationDTO
>
allOrgs
=
resources
.
stream
().
filter
(
r
->
r
.
getType
()
==
3
).
map
(
r
->
{
List
<
OrganizationDTO
>
orgs
=
Lists
.
newArrayList
();
List
<
OrganizationDTO
>
orgs
=
Lists
.
newArrayList
();
String
[]
temp
=
r
.
getExtra
().
split
(
"\\|"
);
String
[]
temp
=
r
.
getExtra
().
split
(
"\\|"
);
Result
<
?
>
result
=
organizationService
.
getAllOrganizations
(
temp
[
0
],
Result
<
List
<
OrganizationDTO
>
>
result
=
organizationService
.
getAllOrganizations
(
temp
[
0
],
Arrays
.
asList
(
temp
[
1
].
split
(
","
)));
Arrays
.
asList
(
temp
[
1
].
split
(
","
)));
if
(
StringUtils
.
equals
(
ResultEnum
.
SUCCESS
.
getCode
(),
result
.
getCode
()))
{
if
(
StringUtils
.
equals
(
ResultEnum
.
SUCCESS
.
getCode
(),
result
.
getCode
()))
{
orgs
=
(
List
<
OrganizationDTO
>)
result
.
getResult
();
orgs
=
result
.
getResult
();
}
}
return
orgs
;
return
orgs
;
}).
flatMap
(
a
->
a
.
stream
()).
collect
(
Collectors
.
toList
());
}).
flatMap
(
a
->
a
.
stream
()).
collect
(
Collectors
.
toList
());
if
(
CollectionUtils
.
isNotEmpty
(
allOrgs
))
{
if
(
CollectionUtils
.
isNotEmpty
(
allOrgs
))
{
log
.
info
(
"allOrgs2: {}"
,
allOrgs
.
size
());
// 设置第一个为当前权限等级
try
{
allOrgs
.
get
(
0
).
setIsActive
(
true
);
allOrgs
.
stream
().
forEach
(
o
->
o
.
setIsActive
(
true
));
log
.
info
(
"allOrgs3: {}"
,
allOrgs
.
get
(
0
));
log
.
info
(
"allOrgs4: {}"
,
allOrgs
.
get
(
0
).
getIsActive
());
allOrgs
.
get
(
0
).
setIsActive
(
true
);
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
log
.
error
(
"allOrgs4: {} {}"
,
e
.
getMessage
(),
e
);
}
}
}
userDTO
.
setAuths
(
allOrgs
);
userDTO
.
setAuths
(
allOrgs
);
}
}
...
@@ -184,7 +175,7 @@ public class UserService {
...
@@ -184,7 +175,7 @@ public class UserService {
resourceInfo
.
setExtra
(
null
);
resourceInfo
.
setExtra
(
null
);
}
}
public
Result
<
?
>
getUserInfo
(
String
userId
)
{
public
Result
<
UserLoginDTO
>
getUserInfo
(
String
userId
)
{
UserEntity
user
=
userDao
.
getById
(
userId
);
UserEntity
user
=
userDao
.
getById
(
userId
);
UserLoginDTO
userDTO
=
convertToUserLoginDTO
(
user
);
UserLoginDTO
userDTO
=
convertToUserLoginDTO
(
user
);
return
Result
.
success
(
userDTO
);
return
Result
.
success
(
userDTO
);
...
...
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