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 ac7f53ee
authored
Nov 15, 2023
by
刘鑫
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://gitlab.dituhui.com/bsh/project/project
into develop
2 parents
6fd6fd46
f747a586
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
27 deletions
project-order/src/main/java/com/dituhui/pea/order/dao/OrgTeamEngineerDao.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/DispatchServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderCreateServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderInfoServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/dao/OrgTeamEngineerDao.java
View file @
ac7f53e
...
...
@@ -34,6 +34,7 @@ public interface OrgTeamEngineerDao extends JpaRepository<OrgTeamEngineerEntity,
@Query
(
"UPDATE OrgTeamEngineerEntity tt SET tt.status = :status WHERE tt.teamId = :teamId AND tt.engineerCode IN :engineerCodes"
)
void
updateStatusByEngineerCodes
(
String
teamId
,
List
<
String
>
engineerCodes
,
int
status
);
@Query
(
"select t from OrgTeamEngineerEntity t where t.engineerCode in :engineerCode and t.status=1"
)
List
<
OrgTeamEngineerEntity
>
findByEngineerCode
(
String
engineerCode
);
/**
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/DispatchServiceImpl.java
View file @
ac7f53e
...
...
@@ -326,6 +326,7 @@ public class DispatchServiceImpl implements DispatchService {
if
(!
entityResult
.
getCode
().
equals
(
ResultEnum
.
SUCCESS
.
getCode
()))
{
// return Result.failed("当前工程师无法预约合适时间");
errorList
.
add
(
entity
.
getOrderId
());
continue
;
}
entity
=
entityResult
.
getResult
();
entity
.
setTakeTime
(
skill
.
getTakeTime
());
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderCreateServiceImpl.java
View file @
ac7f53e
...
...
@@ -440,6 +440,9 @@ public class OrderCreateServiceImpl implements OrderCreateService {
if
(
special
==
1
)
{
tags
.
add
(
OrderPeaTagsEnum
.
special
.
getTag
());
}
if
(
CollectionUtils
.
isNotEmpty
(
tags
))
{
tags
=
tags
.
stream
().
filter
(
e
->
StringUtils
.
isNotBlank
(
e
)).
collect
(
Collectors
.
toList
());
}
MsgDTO
msgDTO
=
new
MsgDTO
();
msgDTO
.
setBranchId
(
branchId
);
msgDTO
.
setType
(
0
);
...
...
project-order/src/main/java/com/dituhui/pea/order/service/impl/OrderInfoServiceImpl.java
View file @
ac7f53e
...
...
@@ -7,6 +7,7 @@ import com.dituhui.pea.common.Result;
import
com.dituhui.pea.common.ResultEnum
;
import
com.dituhui.pea.dispatch.IPath
;
import
com.dituhui.pea.enums.StatusCodeEnum
;
import
com.dituhui.pea.order.common.OccupyInfoDetail
;
import
com.dituhui.pea.order.common.TimeUtils
;
import
com.dituhui.pea.order.common.jackson.JsonUtil
;
import
com.dituhui.pea.order.constant.OrderReschedulingReason
;
...
...
@@ -74,6 +75,9 @@ public class OrderInfoServiceImpl implements OrderInfoService {
@Autowired
private
IPath
pathService
;
@Autowired
private
EngineerCalendarService
engineerCalendarService
;
/**
* 新增订单处理一家多单逻辑
...
...
@@ -452,29 +456,25 @@ public class OrderInfoServiceImpl implements OrderInfoService {
@Transactional
@Override
public
Result
<
OrderInfoEntity
>
insterEngineerOrders
(
List
<
OrderInfoEntity
>
engineerOrders
,
OrderInfoEntity
insertOrder
,
SkillInfoEntity
skillInfo
,
OrgTeamEntity
orgTeam
,
EngineerInfoEntity
engineer
)
{
// 没有单直接返回
// 获取团队工作起止时间
String
[]
teamWorkStartTime
=
orgTeam
.
getWorkOn
().
split
(
":"
);
String
[]
teamWorkEndTime
=
orgTeam
.
getWorkOff
().
split
(
":"
);
LocalDateTime
startTeam
=
insertOrder
.
getDt
().
atTime
(
Integer
.
parseInt
(
teamWorkStartTime
[
0
]),
Integer
.
parseInt
(
teamWorkStartTime
[
1
]),
0
);
LocalDateTime
endTeam
=
insertOrder
.
getDt
().
atTime
(
Integer
.
parseInt
(
teamWorkEndTime
[
0
]),
Integer
.
parseInt
(
teamWorkEndTime
[
1
]),
0
);
// 获取客户期望时间段
LocalDateTime
start
=
insertOrder
.
getExpectTimeBegin
();
LocalDateTime
end
=
insertOrder
.
getExpectTimeEnd
();
LocalDateTime
workStartTime
=
insertOrder
.
getExpectTimeBegin
();
LocalDateTime
workEndTime
=
insertOrder
.
getExpectTimeEnd
();
//查询工程师当天出勤时间
List
<
OccupyInfoDetail
>
engineerWorkTimeSlice
=
engineerCalendarService
.
timeWindowsSlice
(
engineer
.
getEngineerCode
(),
orgTeam
.
getTeamId
(),
insertOrder
.
getDt
());
log
.
info
(
"【engineerWorkTimeSlice】结果------------->{}"
,
JsonUtil
.
toJson
(
engineerWorkTimeSlice
));
// 没有单直接返回
if
(
CollectionUtils
.
isEmpty
(
engineerOrders
))
{
// 特殊时间不插单
if
(
LocalDateTime
.
now
().
isBefore
(
startTeam
)
||
LocalDateTime
.
now
().
isAfter
(
endTeam
)
||
end
.
isAfter
(
endTeam
)
||
end
.
isBefore
(
startTeam
))
{
LocalDateTime
planStartTime
=
handleWorkTime
(
engineerWorkTimeSlice
,
insertOrder
.
getExpectTimeBegin
(),
insertOrder
.
getExpectTimeBegin
().
plusMinutes
(
skillInfo
.
getTakeTime
()));
if
(
ObjectUtil
.
isNull
(
planStartTime
))
{
return
Result
.
failed
(
insertOrder
);
}
insertOrder
.
setTakeTime
(
skillInfo
.
getTakeTime
());
insertOrder
.
setPlanStartTime
(
insertOrder
.
getExpectTimeBegin
()
);
insertOrder
.
setPlanEndTime
(
insertOrder
.
getExpectTimeBegin
()
.
plusMinutes
(
skillInfo
.
getTakeTime
()));
insertOrder
.
setPlanStartTime
(
planStartTime
);
insertOrder
.
setPlanEndTime
(
planStartTime
.
plusMinutes
(
skillInfo
.
getTakeTime
()));
return
Result
.
success
(
insertOrder
);
}
int
takeTime
=
skillInfo
.
getTakeTime
();
// 计算最早派工和最晚派工时间
LocalDateTime
workStartTime
=
start
.
isAfter
(
startTeam
)
?
start
:
startTeam
;
LocalDateTime
workEndTime
=
end
.
isBefore
(
endTeam
)
?
end
:
endTeam
;
// 订单工作时间顺序排序
List
<
OrderSegment
>
orderSegments
=
new
ArrayList
<>();
for
(
OrderInfoEntity
orderInfo
:
engineerOrders
)
{
...
...
@@ -493,9 +493,13 @@ public class OrderInfoServiceImpl implements OrderInfoService {
}
// 没有单直接返回
if
(
CollectionUtils
.
isEmpty
(
orderSegments
))
{
LocalDateTime
planStartTime
=
handleWorkTime
(
engineerWorkTimeSlice
,
insertOrder
.
getExpectTimeBegin
(),
insertOrder
.
getExpectTimeBegin
().
plusMinutes
(
skillInfo
.
getTakeTime
()));
if
(
ObjectUtil
.
isNull
(
planStartTime
))
{
return
Result
.
failed
(
insertOrder
);
}
insertOrder
.
setTakeTime
(
skillInfo
.
getTakeTime
());
insertOrder
.
setPlanStartTime
(
insertOrder
.
getExpectTimeBegin
()
);
insertOrder
.
setPlanEndTime
(
insertOrder
.
getExpectTimeBegin
()
.
plusMinutes
(
skillInfo
.
getTakeTime
()));
insertOrder
.
setPlanStartTime
(
planStartTime
);
insertOrder
.
setPlanEndTime
(
planStartTime
.
plusMinutes
(
skillInfo
.
getTakeTime
()));
return
Result
.
success
(
insertOrder
);
}
orderSegments
=
orderSegments
.
stream
().
sorted
(
Comparator
.
comparing
(
OrderSegment:
:
getStart
)).
collect
(
Collectors
.
toList
());
...
...
@@ -511,11 +515,13 @@ public class OrderInfoServiceImpl implements OrderInfoService {
int
roadTime
=
distanceDTO
.
getTime
()
/
1000
;
// 先判断第一单开始时间
if
(
i
==
0
&&
orderSegment
.
getStart
().
compareTo
(
workStartTime
.
plusMinutes
(
takeTime
+
roadTime
))
>=
0
)
{
LocalDateTime
planStartTime
=
handleWorkTime
(
engineerWorkTimeSlice
,
insertOrder
.
getExpectTimeBegin
(),
insertOrder
.
getExpectTimeBegin
().
plusMinutes
(
skillInfo
.
getTakeTime
()));
if
(
ObjectUtil
.
isNull
(
planStartTime
))
{
return
Result
.
failed
(
insertOrder
);
}
insertOrder
.
setTakeTime
(
skillInfo
.
getTakeTime
());
// insertOrder.setArriveDistance(roadTime);
// insertOrder.setArriveDistance(Integer.valueOf(String.valueOf(distanceDTO.getDis() * 1000)));
insertOrder
.
setPlanStartTime
(
insertOrder
.
getExpectTimeBegin
());
insertOrder
.
setPlanEndTime
(
insertOrder
.
getExpectTimeBegin
().
plusMinutes
(
skillInfo
.
getTakeTime
()));
insertOrder
.
setPlanStartTime
(
planStartTime
);
insertOrder
.
setPlanEndTime
(
planStartTime
.
plusMinutes
(
skillInfo
.
getTakeTime
()));
OrderInfoEntity
nestOrder
=
orderInfoDao
.
getByOrderId
(
orderSegment
.
getOrderId
());
nestOrder
.
setArriveDistance
(
roadTime
);
...
...
@@ -529,11 +535,18 @@ public class OrderInfoServiceImpl implements OrderInfoService {
if
(
workEndTime
.
compareTo
(
orderSegment
.
getEnd
().
plusMinutes
(
takeTime
+
roadTime
))
<
0
)
{
return
Result
.
failed
(
insertOrder
);
}
insertOrder
.
setTakeTime
(
skillInfo
.
getTakeTime
());
// 判断工单开始时间
LocalDateTime
planStartTime
=
insertOrder
.
getExpectTimeBegin
().
compareTo
(
orderSegment
.
getEnd
().
plusMinutes
(
roadTime
))
>=
0
?
insertOrder
.
getExpectTimeBegin
()
:
orderSegment
.
getEnd
().
plusMinutes
(
roadTime
);
planStartTime
=
handleWorkTime
(
engineerWorkTimeSlice
,
planStartTime
,
planStartTime
.
plusMinutes
(
skillInfo
.
getTakeTime
()));
if
(
ObjectUtil
.
isNull
(
planStartTime
))
{
return
Result
.
failed
(
insertOrder
);
}
insertOrder
.
setArriveDistance
(
roadTime
);
insertOrder
.
setArriveDistance
(
BigDecimal
.
valueOf
(
distanceDTO
.
getDis
()
*
1000
).
intValue
());
insertOrder
.
setPlanStartTime
(
orderSegment
.
getEnd
().
plusMinutes
(
roadTime
));
insertOrder
.
setPlanEndTime
(
orderSegment
.
getEnd
().
plusMinutes
(
takeTime
+
roadTime
));
insertOrder
.
setTakeTime
(
skillInfo
.
getTakeTime
());
insertOrder
.
setPlanStartTime
(
planStartTime
);
insertOrder
.
setPlanEndTime
(
planStartTime
.
plusMinutes
(
skillInfo
.
getTakeTime
()));
return
Result
.
success
(
insertOrder
);
}
// 当前单在中间
...
...
@@ -545,11 +558,18 @@ public class OrderInfoServiceImpl implements OrderInfoService {
continue
;
}
if
(
nestOrderSegment
.
getStart
().
minusMinutes
(
roadResult2
.
getResult
().
getTime
()
/
1000
).
compareTo
(
orderSegment
.
getEnd
().
plusMinutes
(
takeTime
+
roadTime
))
>=
0
)
{
insertOrder
.
setTakeTime
(
skillInfo
.
getTakeTime
());
// 判断工单开始时间
LocalDateTime
planStartTime
=
insertOrder
.
getExpectTimeBegin
().
compareTo
(
orderSegment
.
getEnd
().
plusMinutes
(
roadTime
))
>=
0
?
insertOrder
.
getExpectTimeBegin
()
:
orderSegment
.
getEnd
().
plusMinutes
(
roadTime
);
planStartTime
=
handleWorkTime
(
engineerWorkTimeSlice
,
planStartTime
,
planStartTime
.
plusMinutes
(
skillInfo
.
getTakeTime
()));
if
(
ObjectUtil
.
isNull
(
planStartTime
))
{
return
Result
.
failed
(
insertOrder
);
}
insertOrder
.
setArriveDistance
(
roadTime
);
insertOrder
.
setArriveElapsed
(
BigDecimal
.
valueOf
(
distanceDTO
.
getDis
()
*
1000
).
intValue
());
insertOrder
.
setPlanStartTime
(
orderSegment
.
getEnd
().
plusMinutes
(
roadTime
));
insertOrder
.
setPlanEndTime
(
orderSegment
.
getEnd
().
plusMinutes
(
takeTime
+
roadTime
));
insertOrder
.
setArriveDistance
(
BigDecimal
.
valueOf
(
distanceDTO
.
getDis
()
*
1000
).
intValue
());
insertOrder
.
setTakeTime
(
skillInfo
.
getTakeTime
());
insertOrder
.
setPlanStartTime
(
planStartTime
);
insertOrder
.
setPlanEndTime
(
planStartTime
.
plusMinutes
(
skillInfo
.
getTakeTime
()));
OrderInfoEntity
nestOrder
=
orderInfoDao
.
getByOrderId
(
nestOrderSegment
.
getOrderId
());
nestOrder
.
setArriveDistance
(
roadResult2
.
getResult
().
getTime
()
/
1000
);
...
...
@@ -561,6 +581,28 @@ public class OrderInfoServiceImpl implements OrderInfoService {
return
Result
.
failed
(
insertOrder
);
}
/**
* 处理工程师出勤时间和工单计划开始时间
*
* @param engineerWorkTimeSlice
* @param expectTimeBegin
* @param expectTimeEnd
* @return 工单计划开始时间
*/
private
LocalDateTime
handleWorkTime
(
List
<
OccupyInfoDetail
>
engineerWorkTimeSlice
,
LocalDateTime
expectTimeBegin
,
LocalDateTime
expectTimeEnd
)
{
if
(
CollectionUtils
.
isEmpty
(
engineerWorkTimeSlice
))
{
return
null
;
}
for
(
int
i
=
0
;
i
<
engineerWorkTimeSlice
.
size
();
i
++)
{
OccupyInfoDetail
occupyInfoDetail
=
engineerWorkTimeSlice
.
get
(
i
);
if
(
expectTimeBegin
.
compareTo
(
occupyInfoDetail
.
getBeginTime
())
<
0
||
expectTimeEnd
.
compareTo
(
occupyInfoDetail
.
getEndTime
())
>
0
)
{
continue
;
}
return
expectTimeBegin
.
compareTo
(
occupyInfoDetail
.
getBeginTime
())
>=
0
?
expectTimeBegin
:
occupyInfoDetail
.
getBeginTime
();
}
return
null
;
}
/**
* 订单重新分单
...
...
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