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 33b71214
authored
Jun 19, 2023
by
丁伟峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
技术员甘特图,从"工作区",移到"技术员"模块
1 parent
a89acf66
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
122 additions
and
115 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/EngineerController.java
project-order/src/main/java/com/dituhui/pea/order/controller/WorkbenchController.java
project-order/src/main/java/com/dituhui/pea/order/service/EngineerService.java
project-order/src/main/java/com/dituhui/pea/order/service/WorkbenchService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/WorkbenchServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/controller/EngineerController.java
View file @
33b7121
...
...
@@ -4,10 +4,14 @@ import com.dituhui.pea.common.BusinessException;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.EngineerBusinessUpdateReqDTO
;
import
com.dituhui.pea.order.dto.EngineerSkillUpdateReqDTO
;
import
com.dituhui.pea.order.dto.EngineersGanttReqDTO
;
import
com.dituhui.pea.order.service.EngineerService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
@Slf4j
@RestController
@RequestMapping
(
"/pea-order"
)
public
class
EngineerController
{
...
...
@@ -111,4 +115,17 @@ public class EngineerController {
}
return
res
;
}
@PostMapping
(
value
=
"/engineer/schedule/gantt"
)
public
Result
<?>
getEngineersGanttList
(
@Validated
@RequestBody
EngineersGanttReqDTO
reqDTO
)
{
// todo 待移到 controller的engineer中
log
.
info
(
"getEngineersGanttList: {}"
,
reqDTO
);
Result
<?>
res
=
null
;
try
{
res
=
engineerService
.
getEngineersGanttList
(
reqDTO
);
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
}
project-order/src/main/java/com/dituhui/pea/order/controller/WorkbenchController.java
View file @
33b7121
...
...
@@ -2,13 +2,14 @@ package com.dituhui.pea.order.controller;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.EngineersGanttReqDTO
;
import
com.dituhui.pea.order.dto.OrderChangeListReqDTO
;
import
com.dituhui.pea.order.service.WorkbenchService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@Slf4j
@RestController
...
...
@@ -28,17 +29,4 @@ public class WorkbenchController {
}
return
res
;
}
@PostMapping
(
value
=
"/engineer/schedule/gantt"
)
public
Result
<?>
getEngineersGanttList
(
@Validated
@RequestBody
EngineersGanttReqDTO
reqDTO
)
{
// todo 待移到 controller的engineer中
log
.
info
(
"getEngineersGanttList: {}"
,
reqDTO
);
Result
<?>
res
=
null
;
try
{
res
=
workbenchService
.
getEngineersGanttList
(
reqDTO
);
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
}
project-order/src/main/java/com/dituhui/pea/order/service/EngineerService.java
View file @
33b7121
package
com
.
dituhui
.
pea
.
order
.
service
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dto.EngineersGanttReqDTO
;
import
java.util.List
;
...
...
@@ -21,4 +22,6 @@ public interface EngineerService {
// 技术员业务属性配置修改
Result
<?>
engineerBusinessUpdate
(
String
engineerCode
,
Integer
maxNum
,
Integer
maxMutine
,
String
departure
,
String
priority
);
Result
<?>
getEngineersGanttList
(
EngineersGanttReqDTO
ganttReqDTO
);
}
project-order/src/main/java/com/dituhui/pea/order/service/WorkbenchService.java
View file @
33b7121
...
...
@@ -6,6 +6,4 @@ import com.dituhui.pea.order.dto.OrderChangeListReqDTO;
public
interface
WorkbenchService
{
Result
<?>
getOrderChangeList
(
OrderChangeListReqDTO
orderChangeListReqDTO
);
Result
<?>
getEngineersGanttList
(
EngineersGanttReqDTO
ganttReqDTO
);
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/EngineerServiceImpl.java
View file @
33b7121
...
...
@@ -2,24 +2,16 @@ package com.dituhui.pea.order.service.impl;
import
com.dituhui.pea.common.BusinessException
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dao.EngineerBusinessMPDao
;
import
com.dituhui.pea.order.dao.EngineerInfoMPDao
;
import
com.dituhui.pea.order.dao.EngineerSkillMPDao
;
import
com.dituhui.pea.order.dao.OrgGroupMPDao
;
import
com.dituhui.pea.order.dto.EngineerBusinessListResp
;
import
com.dituhui.pea.order.dto.EngineerInfoListResp
;
import
com.dituhui.pea.order.dto.EngineerSkillListResp
;
import
com.dituhui.pea.order.entity.EngineerBusiness
;
import
com.dituhui.pea.order.entity.EngineerInfo
;
import
com.dituhui.pea.order.entity.EngineerSkill
;
import
com.dituhui.pea.order.entity.OrgGroup
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.service.EngineerService
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
com.baomidou.mybatisplus.extension.plugins.pagination.Page
;
import
org.slf4j.Logger
;
import
org.
slf4j.LoggerFactory
;
import
lombok.extern.slf4j.Slf4j
;
import
org.
apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
...
...
@@ -30,11 +22,10 @@ import java.time.format.DateTimeFormatter;
import
java.util.*
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
public
class
EngineerServiceImpl
implements
EngineerService
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
getClass
());
@Autowired
private
EngineerInfoMPDao
engineerInfoMPDao
;
...
...
@@ -47,6 +38,18 @@ public class EngineerServiceImpl implements EngineerService {
@Autowired
private
EngineerBusinessMPDao
engineerBusinessDao
;
@Autowired
private
OrderRequestDao
orderRequestDao
;
@Autowired
private
OrderAppointmentDao
orderAppointmentDao
;
@Autowired
private
EngineerInfoDao
engineerInfoDao
;
@Autowired
private
CapacityEngineerStatDao
capacityEngineerStatDao
;
@Transactional
@Override
public
Result
<?>
getEngineerInfoList
(
long
page
,
long
size
)
{
...
...
@@ -459,4 +462,80 @@ public class EngineerServiceImpl implements EngineerService {
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
pattern
);
return
df
.
format
(
t
.
toLocalDateTime
());
}
@Override
public
Result
<?>
getEngineersGanttList
(
EngineersGanttReqDTO
reqDTO
)
{
// 按日期返回技术员们当天的服务甘特图,不需要翻页
log
.
info
(
"getEngineersGanttList: {}"
,
reqDTO
);
List
<
OrderAppointmentEntity
>
orderAppointments
=
orderAppointmentDao
.
findByDateAndEngineerCodeIn
(
reqDTO
.
getDate
(),
reqDTO
.
getEngineerCodes
());
List
<
String
>
orderIds
=
orderAppointments
.
stream
().
map
(
OrderAppointmentEntity:
:
getOrderId
).
collect
(
Collectors
.
toList
());
Map
<
String
,
OrderRequestEntity
>
mapOrderRequest
=
getOrdersByOrderIds
(
orderIds
);
HashMap
<
String
,
List
<
EngineersGanttRespDTO
.
Order
>>
mapEngineers
=
new
HashMap
<>();
for
(
OrderAppointmentEntity
e
:
orderAppointments
)
{
log
.
info
(
"===== order_id: [{}]"
,
e
.
getOrderId
());
EngineersGanttRespDTO
.
Order
order
=
new
EngineersGanttRespDTO
.
Order
();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
order
.
setStartTime
(
e
.
getExpectStartTime
()).
setEndTime
(
e
.
getExpectEndTime
());
order
.
setOrderId
(
e
.
getOrderId
()).
setPreStatus
(
e
.
getPreStatus
());
order
.
setTips
(
getOrderTips
(
e
.
getOrderId
()));
order
.
setAppointmentStatus
(
mapOrderRequest
.
get
(
e
.
getOrderId
()).
getAppointmentStatus
());
List
<
EngineersGanttRespDTO
.
Order
>
orders
=
null
;
if
(
mapEngineers
.
containsKey
(
e
.
getEngineerCode
()))
{
orders
=
mapEngineers
.
get
(
e
.
getEngineerCode
());
}
else
{
orders
=
new
ArrayList
<>();
}
orders
.
add
(
order
);
mapEngineers
.
put
(
e
.
getEngineerCode
(),
orders
);
}
List
<
EngineersGanttRespDTO
.
GanttChart
>
engineers
=
new
ArrayList
<>();
for
(
String
engineerCode
:
mapEngineers
.
keySet
())
{
EngineerInfoEntity
engineerInfo
=
engineerInfoDao
.
getByEngineerCode
(
engineerCode
);
EngineersGanttRespDTO
.
GanttChart
engineer
=
new
EngineersGanttRespDTO
.
GanttChart
();
engineer
.
setEngineerCode
(
engineerCode
)
.
setStartTime
(
String
.
format
(
"%s 08:00"
,
reqDTO
.
getDate
()))
.
setEndTime
(
String
.
format
(
"%s 18:00"
,
reqDTO
.
getDate
()))
.
setHoliday
(
false
)
// todo
.
setOrders
(
mapEngineers
.
get
(
engineerCode
))
.
setEngineerName
(
engineerInfo
.
getName
())
.
setGrade
(
engineerInfo
.
getGrade
());
CapacityEngineerStatEntity
capacityEngineerStat
=
capacityEngineerStatDao
.
getByEngineerCodeAndWorkday
(
engineerCode
,
reqDTO
.
getDate
());
if
(
capacityEngineerStat
==
null
)
{
log
.
warn
(
"技术员当日的容量数据不存在,{}{}"
,
engineerCode
,
reqDTO
.
getDate
());
}
else
{
engineer
.
setCapTotal
(
capacityEngineerStat
.
getCapTotal
().
toString
()).
setCapUsed
(
capacityEngineerStat
.
getCapUsed
().
toString
());
}
// engineer.setErrorTip(); todo
engineers
.
add
(
engineer
);
}
EngineersGanttRespDTO
data
=
new
EngineersGanttRespDTO
().
setDate
(
reqDTO
.
getDate
()).
setEngineers
(
engineers
);
return
Result
.
success
(
data
);
}
public
Map
<
String
,
OrderRequestEntity
>
getOrdersByOrderIds
(
List
<
String
>
orderIds
)
{
List
<
OrderRequestEntity
>
orders
=
orderRequestDao
.
findAllByOrderIdIn
(
orderIds
);
return
orders
.
stream
()
.
collect
(
Collectors
.
toMap
(
OrderRequestEntity:
:
getOrderId
,
order
->
order
));
}
private
List
<?>
getOrderTips
(
String
orderId
)
{
log
.
info
(
"==> getOrderTips: orderId[{}]"
,
orderId
);
OrderRequestEntity
order
=
orderRequestDao
.
getByOrderId
(
orderId
);
if
(
order
==
null
)
{
log
.
error
(
"对应的订单不存在!{}"
,
orderId
);
return
null
;
}
List
<
LabelValueDTO
>
tips
=
new
ArrayList
<>();
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"工单号码"
).
setValue
(
orderId
));
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"类型/品牌"
).
setValue
(
String
.
format
(
"%s %s"
,
order
.
getBrand
(),
order
.
getType
())));
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"电话/地址"
).
setValue
(
String
.
format
(
"%s %s\n %s"
,
order
.
getName
(),
order
.
getPhone
(),
order
.
getAddress
())));
if
(
StringUtils
.
isNotBlank
(
order
.
getApplyNote
()))
{
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"备注"
).
setValue
(
order
.
getApplyNote
()));
}
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"标签"
).
setValue
(
order
.
getTags
()));
return
tips
;
}
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/WorkbenchServiceImpl.java
View file @
33b7121
...
...
@@ -2,22 +2,20 @@ package com.dituhui.pea.order.service.impl;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.*
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.dto.OrderChangeListReqDTO
;
import
com.dituhui.pea.order.dto.OrderChangeListRespDTO
;
import
com.dituhui.pea.order.entity.OrderChangeEntity
;
import
com.dituhui.pea.order.entity.OrderRequestEntity
;
import
com.dituhui.pea.order.service.WorkbenchService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.stereotype.Service
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
@Slf4j
@Service
...
...
@@ -71,80 +69,4 @@ public class WorkbenchServiceImpl implements WorkbenchService {
.
setContent
(
contents
);
return
Result
.
success
(
respDTO
);
}
@Override
public
Result
<?>
getEngineersGanttList
(
EngineersGanttReqDTO
reqDTO
)
{
// 按日期返回技术员们当天的服务甘特图,不需要翻页
log
.
info
(
"getEngineersGanttList: {}"
,
reqDTO
);
List
<
OrderAppointmentEntity
>
orderAppointments
=
orderAppointmentDao
.
findByDateAndEngineerCodeIn
(
reqDTO
.
getDate
(),
reqDTO
.
getEngineerCodes
());
List
<
String
>
orderIds
=
orderAppointments
.
stream
().
map
(
OrderAppointmentEntity:
:
getOrderId
).
collect
(
Collectors
.
toList
());
Map
<
String
,
OrderRequestEntity
>
mapOrderRequest
=
getOrdersByOrderIds
(
orderIds
);
HashMap
<
String
,
List
<
EngineersGanttRespDTO
.
Order
>>
mapEngineers
=
new
HashMap
<>();
for
(
OrderAppointmentEntity
e
:
orderAppointments
)
{
log
.
info
(
"===== order_id: [{}]"
,
e
.
getOrderId
());
EngineersGanttRespDTO
.
Order
order
=
new
EngineersGanttRespDTO
.
Order
();
// todo 需要根据订单时间和状态,采用expectXXXX或者actualXXXX
order
.
setStartTime
(
e
.
getExpectStartTime
()).
setEndTime
(
e
.
getExpectEndTime
());
order
.
setOrderId
(
e
.
getOrderId
()).
setPreStatus
(
e
.
getPreStatus
());
order
.
setTips
(
getOrderTips
(
e
.
getOrderId
()));
order
.
setAppointmentStatus
(
mapOrderRequest
.
get
(
e
.
getOrderId
()).
getAppointmentStatus
());
List
<
EngineersGanttRespDTO
.
Order
>
orders
=
null
;
if
(
mapEngineers
.
containsKey
(
e
.
getEngineerCode
()))
{
orders
=
mapEngineers
.
get
(
e
.
getEngineerCode
());
}
else
{
orders
=
new
ArrayList
<>();
}
orders
.
add
(
order
);
mapEngineers
.
put
(
e
.
getEngineerCode
(),
orders
);
}
List
<
EngineersGanttRespDTO
.
GanttChart
>
engineers
=
new
ArrayList
<>();
for
(
String
engineerCode
:
mapEngineers
.
keySet
())
{
EngineerInfoEntity
engineerInfo
=
engineerInfoDao
.
getByEngineerCode
(
engineerCode
);
EngineersGanttRespDTO
.
GanttChart
engineer
=
new
EngineersGanttRespDTO
.
GanttChart
();
engineer
.
setEngineerCode
(
engineerCode
)
.
setStartTime
(
String
.
format
(
"%s 08:00"
,
reqDTO
.
getDate
()))
.
setEndTime
(
String
.
format
(
"%s 18:00"
,
reqDTO
.
getDate
()))
.
setHoliday
(
false
)
// todo
.
setOrders
(
mapEngineers
.
get
(
engineerCode
))
.
setEngineerName
(
engineerInfo
.
getName
())
.
setGrade
(
engineerInfo
.
getGrade
());
CapacityEngineerStatEntity
capacityEngineerStat
=
capacityEngineerStatDao
.
getByEngineerCodeAndWorkday
(
engineerCode
,
reqDTO
.
getDate
());
if
(
capacityEngineerStat
==
null
)
{
log
.
warn
(
"技术员当日的容量数据不存在,{}{}"
,
engineerCode
,
reqDTO
.
getDate
());
}
else
{
engineer
.
setCapTotal
(
capacityEngineerStat
.
getCapTotal
().
toString
()).
setCapUsed
(
capacityEngineerStat
.
getCapUsed
().
toString
());
}
// engineer.setErrorTip(); todo
engineers
.
add
(
engineer
);
}
EngineersGanttRespDTO
data
=
new
EngineersGanttRespDTO
().
setDate
(
reqDTO
.
getDate
()).
setEngineers
(
engineers
);
return
Result
.
success
(
data
);
}
public
Map
<
String
,
OrderRequestEntity
>
getOrdersByOrderIds
(
List
<
String
>
orderIds
)
{
List
<
OrderRequestEntity
>
orders
=
orderRequestDao
.
findAllByOrderIdIn
(
orderIds
);
return
orders
.
stream
()
.
collect
(
Collectors
.
toMap
(
OrderRequestEntity:
:
getOrderId
,
order
->
order
));
}
private
List
<?>
getOrderTips
(
String
orderId
)
{
log
.
info
(
"==> getOrderTips: orderId[{}]"
,
orderId
);
OrderRequestEntity
order
=
orderRequestDao
.
getByOrderId
(
orderId
);
if
(
order
==
null
)
{
log
.
error
(
"对应的订单不存在!{}"
,
orderId
);
return
null
;
}
List
<
LabelValueDTO
>
tips
=
new
ArrayList
<>();
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"工单号码"
).
setValue
(
orderId
));
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"类型/品牌"
).
setValue
(
String
.
format
(
"%s %s"
,
order
.
getBrand
(),
order
.
getType
())));
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"电话/地址"
).
setValue
(
String
.
format
(
"%s %s\n %s"
,
order
.
getName
(),
order
.
getPhone
(),
order
.
getAddress
())));
if
(
StringUtils
.
isNotBlank
(
order
.
getApplyNote
()))
{
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"备注"
).
setValue
(
order
.
getApplyNote
()));
}
tips
.
add
(
new
LabelValueDTO
().
setLabel
(
"标签"
).
setValue
(
order
.
getTags
()));
return
tips
;
}
}
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