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 3ebc5005
authored
Jun 16, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
1 parent
b5c25cd1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
117 additions
and
4 deletions
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/ScheduleServiceImpl.java
project-order/src/main/java/com/alibaba/cloud/integration/order/service/impl/ScheduleServiceImpl.java
View file @
3ebc500
package
com
.
alibaba
.
cloud
.
integration
.
order
.
service
.
impl
;
import
com.alibaba.cloud.integration.common.BusinessException
;
import
com.alibaba.cloud.integration.common.Result
;
import
com.alibaba.cloud.integration.order.dao.*
;
import
com.alibaba.cloud.integration.order.dto.ScheduleEngineerOverviewResp
;
import
com.alibaba.cloud.integration.order.dto.ScheduleOverviewResp
;
import
com.alibaba.cloud.integration.order.entity.*
;
import
com.alibaba.cloud.integration.order.service.ScheduleService
;
...
...
@@ -12,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.sql.Timestamp
;
import
java.time.format.DateTimeFormatter
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -27,6 +30,9 @@ public class ScheduleServiceImpl implements ScheduleService {
private
OrgTeamEngineerMPDao
orgTeamEngineerMPDao
;
@Autowired
private
OrgGroupMPDao
orgGroupMPDao
;
@Autowired
private
OrderRequestMPDao
orderRequestMPDao
;
@Autowired
...
...
@@ -56,7 +62,7 @@ public class ScheduleServiceImpl implements ScheduleService {
team
.
setOrder
(
this
.
getTeamOrderSum
(
orders
));
List
<
ScheduleOverviewResp
.
Item
>
children
=
new
ArrayList
<>();
if
(
orders
==
null
||
orders
.
isEmpty
())
{
if
(
orders
==
null
||
orders
.
isEmpty
())
{
team
.
setChildren
(
children
);
teams
.
add
(
team
);
continue
;
...
...
@@ -119,8 +125,75 @@ public class ScheduleServiceImpl implements ScheduleService {
}
@Override
public
Result
<?>
getScheduleEngineerOverview
(
String
date
,
String
engineerCode
)
{
return
null
;
public
Result
<?>
getScheduleEngineerOverview
(
String
date
,
String
engineerCode
)
throws
BusinessException
{
EngineerInfo
engineer
=
this
.
queryEngineerInfo
(
engineerCode
);
if
(
engineer
==
null
)
{
throw
new
BusinessException
(
"分销员不存在"
);
}
List
<
OrderAppointment
>
orderAppointments
=
this
.
queryOrderAppointmentsByEngineerCode
(
engineerCode
,
date
);
List
<
ScheduleEngineerOverviewResp
.
Timeline
>
timelines
=
new
ArrayList
<>();
for
(
OrderAppointment
o
:
orderAppointments
)
{
ScheduleEngineerOverviewResp
.
Timeline
item
=
new
ScheduleEngineerOverviewResp
.
Timeline
();
item
.
setStartTime
(
this
.
Timestamp2Datetime
(
o
.
getExpectStartTime
(),
"hh:mm"
));
item
.
setEndTime
(
this
.
Timestamp2Datetime
(
o
.
getExpectEndTime
(),
"hh:mm"
));
item
.
setType
(
o
.
getStatus
());
timelines
.
add
(
item
);
}
List
<
ScheduleEngineerOverviewResp
.
Dynamic
>
dynamics
=
new
ArrayList
<>();
dynamics
.
add
(
this
.
packDynamic
(
"姓名"
,
engineer
.
getName
()));
dynamics
.
add
(
this
.
packDynamic
(
"日期"
,
date
));
dynamics
.
add
(
this
.
packDynamic
(
"状态"
,
"上班"
));
dynamics
.
add
(
this
.
packDynamic
(
"待服务"
,
"5"
));
dynamics
.
add
(
this
.
packDynamic
(
"服务中"
,
"1"
));
dynamics
.
add
(
this
.
packDynamic
(
"已完成"
,
"2"
));
dynamics
.
add
(
this
.
packDynamic
(
"已取消"
,
"2"
));
dynamics
.
add
(
this
.
packDynamic
(
"已改约"
,
"3"
));
dynamics
.
add
(
this
.
packDynamic
(
"预计总耗时"
,
"6小时"
));
dynamics
.
add
(
this
.
packDynamic
(
"公里数"
,
"42公里"
));
dynamics
.
add
(
this
.
packDynamic
(
"工作时间"
,
"08:00-19:00"
));
dynamics
.
add
(
this
.
packDynamic
(
"交通工具"
,
"电动车"
));
List
<
String
>
orderIds
=
orderAppointments
.
stream
().
map
(
OrderAppointment:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
OrderRequest
>
orderRequests
=
this
.
queryOrderRequestByOrderIds
(
orderIds
);
List
<
ScheduleEngineerOverviewResp
.
Order
>
orders
=
new
ArrayList
<>();
for
(
OrderRequest
o
:
orderRequests
)
{
ScheduleEngineerOverviewResp
.
Order
item
=
new
ScheduleEngineerOverviewResp
.
Order
();
item
.
setOrderId
(
o
.
getOrderId
());
item
.
setLocation
(
String
.
format
(
"%s,%s"
,
o
.
getX
(),
o
.
getY
()));
item
.
setType
(
o
.
getType
());
item
.
setSkill
(
o
.
getSkill
());
item
.
setOrderStatus
(
o
.
getAppointmentStatus
());
item
.
setOrderStatusName
(
""
);
item
.
setDistance
(
3000
);
item
.
setArriveTime
(
""
);
item
.
setTimeType
(
""
);
item
.
setExpectArriveDuration
(
""
);
item
.
setArriveTime
(
""
);
item
.
setWorkDuration
(
""
);
item
.
setExpectWorkDuration
(
""
);
orders
.
add
(
item
);
}
String
groupName
=
""
;
OrgGroup
group
=
this
.
queryOrgGroupInfo
(
engineer
.
getGroupId
());
if
(
group
!=
null
)
{
groupName
=
group
.
getGroupName
();
}
ScheduleEngineerOverviewResp
res
=
new
ScheduleEngineerOverviewResp
();
res
.
setTitle
(
String
.
format
(
"%s_%s"
,
groupName
,
engineer
.
getName
()));
res
.
setEngineerCode
(
engineerCode
);
res
.
setStartTime
(
"08:00"
);
// TODO
res
.
setEndTime
(
"18:00"
);
res
.
setDynamics
(
dynamics
);
res
.
setTimelines
(
timelines
);
res
.
setOrders
(
orders
);
return
Result
.
success
(
res
);
}
private
IPage
<
OrgTeam
>
queryOrgTeams
(
long
page
,
long
size
,
String
levelType
,
List
<
String
>
levelIds
)
{
...
...
@@ -154,10 +227,25 @@ public class ScheduleServiceImpl implements ScheduleService {
return
orderRequestMPDao
.
selectList
(
lqw
);
}
private
List
<
OrderRequest
>
queryOrderRequestByOrderIds
(
List
<
String
>
orderIds
)
{
LambdaQueryWrapper
<
OrderRequest
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
OrderRequest:
:
getOrderId
,
orderIds
);
return
orderRequestMPDao
.
selectList
(
lqw
);
}
private
List
<
OrderAppointment
>
queryOrderAppointments
(
List
<
String
>
orderIds
,
String
date
)
{
LambdaQueryWrapper
<
OrderAppointment
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
OrderAppointment:
:
getOrderId
,
orderIds
);
lqw
.
ge
(
OrderAppointment:
:
getExpectStartTime
,
this
.
getTimestampFromDate
(
date
,
"00:00:00"
));
lqw
.
le
(
OrderAppointment:
:
getExpectEndTime
,
this
.
getTimestampFromDate
(
date
,
"23:59:59"
));
return
orderAppointmentMPDao
.
selectList
(
lqw
);
}
private
List
<
OrderAppointment
>
queryOrderAppointmentsByEngineerCode
(
String
engineerCode
,
String
date
)
{
LambdaQueryWrapper
<
OrderAppointment
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
in
(
OrderAppointment:
:
getEngineerCode
,
engineerCode
);
lqw
.
ge
(
OrderAppointment:
:
getExpectStartTime
,
this
.
getTimestampFromDate
(
date
,
"00:00:00"
));
lqw
.
le
(
OrderAppointment:
:
getExpectEndTime
,
this
.
getTimestampFromDate
(
date
,
"23:59:59"
));
return
orderAppointmentMPDao
.
selectList
(
lqw
);
}
...
...
@@ -167,6 +255,18 @@ public class ScheduleServiceImpl implements ScheduleService {
return
engineerInfoMPDao
.
selectList
(
lqw
);
}
private
EngineerInfo
queryEngineerInfo
(
String
engineerCode
)
{
LambdaQueryWrapper
<
EngineerInfo
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
EngineerInfo:
:
getEngineerCode
,
engineerCode
);
return
engineerInfoMPDao
.
selectOne
(
lqw
);
}
private
OrgGroup
queryOrgGroupInfo
(
String
groupId
)
{
LambdaQueryWrapper
<
OrgGroup
>
lqw
=
new
LambdaQueryWrapper
<>();
lqw
.
eq
(
OrgGroup:
:
getGroupId
,
groupId
);
return
orgGroupMPDao
.
selectOne
(
lqw
);
}
private
ScheduleOverviewResp
.
OrderSum
getTeamOrderSum
(
List
<
OrderRequest
>
orders
)
{
ScheduleOverviewResp
.
OrderSum
s
=
new
ScheduleOverviewResp
.
OrderSum
();
...
...
@@ -182,7 +282,19 @@ public class ScheduleServiceImpl implements ScheduleService {
return
s
;
}
public
Timestamp
getTimestampFromDate
(
String
date
,
String
t
)
{
private
ScheduleEngineerOverviewResp
.
Dynamic
packDynamic
(
String
label
,
String
value
)
{
ScheduleEngineerOverviewResp
.
Dynamic
item
=
new
ScheduleEngineerOverviewResp
.
Dynamic
();
item
.
setLabel
(
label
);
item
.
setValue
(
value
);
return
item
;
}
private
Timestamp
getTimestampFromDate
(
String
date
,
String
t
)
{
return
Timestamp
.
valueOf
(
date
+
" "
+
t
);
}
private
String
Timestamp2Datetime
(
Timestamp
t
,
String
pattern
)
{
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
pattern
);
return
df
.
format
(
t
.
toLocalDateTime
());
}
}
\ No newline at end of file
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