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 44d95322
authored
Nov 01, 2023
by
huangjinxin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/develop' into develop
2 parents
f3c3199c
b50888f0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
4 deletions
project-order/src/main/java/com/dituhui/pea/order/enums/VehicleEnum.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/ScheduleServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/enums/VehicleEnum.java
0 → 100644
View file @
44d9532
package
com
.
dituhui
.
pea
.
order
.
enums
;
import
cn.hutool.core.util.ObjectUtil
;
import
java.util.Objects
;
/**
* 交通工具:1汽车;2电动车;3自行车;4步行 默认是汽车
*
* @author RenPing
* @date 2023/10/24
*/
public
enum
VehicleEnum
{
CAR
(
1
,
"汽车"
),
ELECTRIC_CAR
(
2
,
"电动车"
),
BICYCLE
(
3
,
"自行车"
),
WALK
(
4
,
"步行"
);
private
Integer
code
;
private
String
name
;
private
VehicleEnum
(
Integer
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
public
Integer
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
public
static
String
getNameByValue
(
Integer
value
)
{
if
(
Objects
.
isNull
(
value
))
{
return
null
;
}
for
(
VehicleEnum
enums
:
VehicleEnum
.
values
())
{
if
(
ObjectUtil
.
equal
(
enums
.
getCode
(),
value
))
{
return
enums
.
getName
();
}
}
return
null
;
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/ScheduleServiceImpl.java
View file @
44d9532
...
...
@@ -13,6 +13,7 @@ import com.dituhui.pea.order.dao.*;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.enums.OrderFlowEnum
;
import
com.dituhui.pea.order.enums.VehicleEnum
;
import
com.dituhui.pea.order.service.ScheduleService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
...
...
@@ -22,6 +23,8 @@ import org.springframework.data.jpa.domain.Specification;
import
org.springframework.stereotype.Service
;
import
javax.persistence.criteria.Predicate
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.time.LocalDate
;
import
java.time.LocalDateTime
;
import
java.time.temporal.ChronoUnit
;
...
...
@@ -51,6 +54,9 @@ public class ScheduleServiceImpl implements ScheduleService {
private
EngineerInfoDao
engineerInfoDao
;
@Autowired
private
EngineerBusinessDao
engineerBusinessDao
;
@Autowired
private
SkillInfoDao
skillInfoDao
;
@Override
...
...
@@ -166,11 +172,14 @@ public class ScheduleServiceImpl implements ScheduleService {
if
(
engineer
==
null
)
{
throw
new
BusinessException
(
"分销员不存在"
);
}
EngineerBusinessEntity
engineerBusinessEntity
=
engineerBusinessDao
.
getByEngineerCode
(
engineerCode
);
List
<
LabelValueDTO
>
emptyTips
=
new
ArrayList
<>();
List
<
OrderInfoEntity
>
orderAppointments
=
orderInfoDao
.
findByEngineerCodeAndDtAndAppointmentStatusIn
(
engineerCode
,
date
,
List
.
of
(
OrderFlowEnum
.
PRE
.
name
(),
OrderFlowEnum
.
CONFIRM
.
name
()));
List
<
TimeLineDTO
>
timelines
=
new
ArrayList
<>();
int
sumDistance
=
0
;
int
sumElapsed
=
0
;
for
(
OrderInfoEntity
o
:
orderAppointments
)
{
TimeLineDTO
item
=
new
TimeLineDTO
();
item
.
setOrderId
(
o
.
getOrderId
());
...
...
@@ -179,6 +188,8 @@ public class ScheduleServiceImpl implements ScheduleService {
item
.
setEndTime
(
TimeUtils
.
IsoLocalDateTime2String
(
o
.
getPlanEndTime
()));
item
.
setTips
(
emptyTips
);
timelines
.
add
(
item
);
sumDistance
+=
Objects
.
isNull
(
o
.
getArriveDistance
())
?
0
:
o
.
getArriveDistance
();
sumElapsed
+=
Objects
.
isNull
(
o
.
getArriveElapsed
())
?
0
:
o
.
getArriveElapsed
();
}
Map
<
String
,
List
<
OrderInfoEntity
>>
statusGroup
=
orderAppointments
.
stream
().
collect
(
Collectors
.
groupingBy
(
OrderInfoEntity:
:
getServiceStatus
));
...
...
@@ -194,10 +205,17 @@ public class ScheduleServiceImpl implements ScheduleService {
dynamics
.
add
(
new
LabelValueDTO
(
"已完成"
,
Integer
.
toString
(
statusGroup
.
getOrDefault
(
"FINISHED"
,
empty
).
size
())));
dynamics
.
add
(
new
LabelValueDTO
(
"已取消"
,
Integer
.
toString
(
statusGroup
.
getOrDefault
(
"CANCELED"
,
empty
).
size
())));
dynamics
.
add
(
new
LabelValueDTO
(
"已改约"
,
Integer
.
toString
(
statusGroup
.
getOrDefault
(
"RESCHEDULED"
,
empty
).
size
())));
dynamics
.
add
(
new
LabelValueDTO
(
"预计总耗时"
,
"6小时"
));
dynamics
.
add
(
new
LabelValueDTO
(
"公里数"
,
"42公里"
));
dynamics
.
add
(
new
LabelValueDTO
(
"工作时间"
,
"08:00-18:00"
));
dynamics
.
add
(
new
LabelValueDTO
(
"交通工具"
,
"电动车"
));
dynamics
.
add
(
new
LabelValueDTO
(
"预计总耗时"
,
new
BigDecimal
(
sumElapsed
)
.
divide
(
new
BigDecimal
(
60
),
2
,
RoundingMode
.
HALF_UP
)
.
stripTrailingZeros
()
+
"小时"
));
dynamics
.
add
(
new
LabelValueDTO
(
"公里数"
,
sumDistance
+
""
));
if
(
Objects
.
nonNull
(
engineerBusinessEntity
))
{
dynamics
.
add
(
new
LabelValueDTO
(
"工作时间"
,
engineerBusinessEntity
.
getWorkOn
()
+
"-"
+
engineerBusinessEntity
.
getWorkOff
()));
}
else
{
dynamics
.
add
(
new
LabelValueDTO
(
"工作时间"
,
"08:00-18:00"
));
}
dynamics
.
add
(
new
LabelValueDTO
(
"交通工具"
,
VehicleEnum
.
getNameByValue
(
engineer
.
getVehicle
())));
List
<
String
>
orderIds
=
orderAppointments
.
stream
().
map
(
OrderInfoEntity:
:
getOrderId
).
collect
(
Collectors
.
toList
());
List
<
OrderInfoEntity
>
orderRequests
=
new
ArrayList
<>();
...
...
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