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 383cc4a8
authored
Jul 06, 2023
by
wangli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增实现工单统计
1 parent
90bf1153
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
201 additions
and
48 deletions
project-order/src/main/java/com/dituhui/pea/order/controller/WorkbenchController.java
project-order/src/main/java/com/dituhui/pea/order/service/WorkbenchService.java
project-order/src/main/java/com/dituhui/pea/order/service/impl/WorkbenchServiceImpl.java
project-order/src/main/java/com/dituhui/pea/order/controller/WorkbenchController.java
View file @
383cc4a
...
...
@@ -9,8 +9,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDate
;
@Slf4j
@RestController
@RequestMapping
(
"/pea-order"
)
...
...
@@ -29,4 +32,15 @@ public class WorkbenchController {
}
return
res
;
}
@GetMapping
(
"/workbench/summary"
)
public
Result
<?>
workbenchSummary
(
@RequestParam
String
levelType
,
@RequestParam
String
levelValue
,
@RequestParam
LocalDate
date
)
{
Result
<?>
res
=
null
;
try
{
res
=
workbenchService
.
getWorkbenchSummary
(
levelType
,
levelValue
,
date
);
}
catch
(
BusinessException
e
)
{
return
Result
.
failed
(
e
.
getMessage
());
}
return
res
;
}
}
project-order/src/main/java/com/dituhui/pea/order/service/WorkbenchService.java
View file @
383cc4a
...
...
@@ -4,6 +4,10 @@ import com.dituhui.pea.common.Result;
import
com.dituhui.pea.order.dto.EngineersGanttReqDTO
;
import
com.dituhui.pea.order.dto.OrderChangeListReqDTO
;
import
java.time.LocalDate
;
public
interface
WorkbenchService
{
Result
<?>
getOrderChangeList
(
OrderChangeListReqDTO
orderChangeListReqDTO
);
Result
<?>
getWorkbenchSummary
(
String
levelType
,
String
levelValue
,
LocalDate
dt
);
}
project-order/src/main/java/com/dituhui/pea/order/service/impl/WorkbenchServiceImpl.java
View file @
383cc4a
package
com
.
dituhui
.
pea
.
order
.
service
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.dituhui.pea.common.Result
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.OrderChangeListReqDTO
;
import
com.dituhui.pea.order.dto.OrderChangeListRespDTO
;
import
com.dituhui.pea.order.dto.WorkbenchSummaryResp
;
import
com.dituhui.pea.order.entity.OrderChangeEntity
;
import
com.dituhui.pea.order.entity.OrderRequest
;
import
com.dituhui.pea.order.entity.OrderRequestEntity
;
import
com.dituhui.pea.order.service.WorkbenchService
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -14,59 +17,191 @@ import org.springframework.data.domain.PageRequest;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDate
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Slf4j
@Service
public
class
WorkbenchServiceImpl
implements
WorkbenchService
{
@Autowired
private
OrderChangeDao
orderChangeDao
;
@Autowired
private
OrderRequestDao
orderRequestDao
;
@Autowired
private
OrderAppointmentDao
orderAppointmentDao
;
@Autowired
private
EngineerInfoDao
engineerInfoDao
;
@Autowired
private
CapacityEngineerStatDao
capacityEngineerStatDao
;
@Override
public
Result
<?>
getOrderChangeList
(
OrderChangeListReqDTO
reqDTO
)
{
Pageable
pageable
=
PageRequest
.
of
(
reqDTO
.
getPage
()
-
1
,
reqDTO
.
getSize
());
Page
<?>
changes
;
String
levelType
=
reqDTO
.
getLevelType
();
String
levelValue
=
reqDTO
.
getLevelValue
();
if
(
"cluster"
.
equals
(
levelType
))
{
changes
=
orderChangeDao
.
findAllByClusterId
(
levelValue
,
reqDTO
.
getDate
(),
pageable
);
}
else
if
(
"branch"
.
equals
(
levelType
))
{
changes
=
orderChangeDao
.
findAllByBranchId
(
levelValue
,
reqDTO
.
getDate
(),
pageable
);
}
else
{
changes
=
orderChangeDao
.
findAllByGroupId
(
levelValue
,
reqDTO
.
getDate
(),
pageable
);
}
List
<
OrderChangeListRespDTO
.
Content
>
contents
=
new
ArrayList
<>();
for
(
Object
e1
:
changes
.
getContent
())
{
OrderChangeEntity
e
=
(
OrderChangeEntity
)
e1
;
OrderChangeListRespDTO
.
Content
content
=
new
OrderChangeListRespDTO
.
Content
();
OrderRequestEntity
orderRequestEntity
=
orderRequestDao
.
getByOrderId
(
e
.
getOrderId
());
content
.
setOrderId
(
e
.
getOrderId
())
.
setCustomerName
(
orderRequestEntity
.
getName
())
.
setOperator
(
e
.
getOperator
())
.
setDescription
(
e
.
getContent
())
.
setMemo
(
e
.
getMemo
())
.
setUpdateTime
(
e
.
getUpdateTime
().
toString
());
contents
.
add
(
content
);
}
OrderChangeListRespDTO
respDTO
=
new
OrderChangeListRespDTO
();
respDTO
.
setTotal
(
changes
.
getTotalElements
())
.
setPages
(
changes
.
getTotalPages
())
.
setPageSize
(
changes
.
getSize
())
.
setContent
(
contents
);
return
Result
.
success
(
respDTO
);
}
@Autowired
private
OrderChangeDao
orderChangeDao
;
@Autowired
private
OrderRequestDao
orderRequestDao
;
@Autowired
private
OrderAppointmentDao
orderAppointmentDao
;
@Autowired
private
EngineerInfoDao
engineerInfoDao
;
@Autowired
private
CapacityEngineerStatDao
capacityEngineerStatDao
;
@Autowired
private
OrderRequestMPDao
orderRequestMPDao
;
@Override
public
Result
<?>
getOrderChangeList
(
OrderChangeListReqDTO
reqDTO
)
{
Pageable
pageable
=
PageRequest
.
of
(
reqDTO
.
getPage
()
-
1
,
reqDTO
.
getSize
());
Page
<?>
changes
;
String
levelType
=
reqDTO
.
getLevelType
();
String
levelValue
=
reqDTO
.
getLevelValue
();
if
(
"cluster"
.
equals
(
levelType
))
{
changes
=
orderChangeDao
.
findAllByClusterId
(
levelValue
,
reqDTO
.
getDate
(),
pageable
);
}
else
if
(
"branch"
.
equals
(
levelType
))
{
changes
=
orderChangeDao
.
findAllByBranchId
(
levelValue
,
reqDTO
.
getDate
(),
pageable
);
}
else
{
changes
=
orderChangeDao
.
findAllByGroupId
(
levelValue
,
reqDTO
.
getDate
(),
pageable
);
}
List
<
OrderChangeListRespDTO
.
Content
>
contents
=
new
ArrayList
<>();
for
(
Object
e1
:
changes
.
getContent
())
{
OrderChangeEntity
e
=
(
OrderChangeEntity
)
e1
;
OrderChangeListRespDTO
.
Content
content
=
new
OrderChangeListRespDTO
.
Content
();
OrderRequestEntity
orderRequestEntity
=
orderRequestDao
.
getByOrderId
(
e
.
getOrderId
());
content
.
setOrderId
(
e
.
getOrderId
())
.
setCustomerName
(
orderRequestEntity
.
getName
())
.
setOperator
(
e
.
getOperator
())
.
setDescription
(
e
.
getContent
())
.
setMemo
(
e
.
getMemo
())
.
setUpdateTime
(
e
.
getUpdateTime
().
toString
());
contents
.
add
(
content
);
}
OrderChangeListRespDTO
respDTO
=
new
OrderChangeListRespDTO
();
respDTO
.
setTotal
(
changes
.
getTotalElements
())
.
setPages
(
changes
.
getTotalPages
())
.
setPageSize
(
changes
.
getSize
())
.
setContent
(
contents
);
return
Result
.
success
(
respDTO
);
}
@Override
public
Result
<?>
getWorkbenchSummary
(
String
levelType
,
String
levelValue
,
LocalDate
dt
)
{
List
<
WorkbenchSummaryResp
.
ItemDTO
>
items
=
new
ArrayList
<>();
HashMap
<
String
,
Integer
>
methodSummary
=
this
.
transAppointmentMethod
(
this
.
queryCountByAppointmentMethod
(
levelType
,
levelValue
,
dt
));
WorkbenchSummaryResp
.
ItemDTO
methodItem
=
new
WorkbenchSummaryResp
.
ItemDTO
();
methodItem
.
setType
(
"order"
);
methodItem
.
setRows
(
this
.
packValueAppointmentMethod
(
methodSummary
));
items
.
add
(
methodItem
);
HashMap
<
String
,
Integer
>
statusSummary
=
this
.
transOrderStatus
(
this
.
queryCountByOrderStatus
(
levelType
,
levelValue
,
dt
));
WorkbenchSummaryResp
.
ItemDTO
statusItem
=
new
WorkbenchSummaryResp
.
ItemDTO
();
methodItem
.
setType
(
"order"
);
methodItem
.
setRows
(
this
.
packValueOrderStatus
(
statusSummary
));
items
.
add
(
statusItem
);
WorkbenchSummaryResp
res
=
new
WorkbenchSummaryResp
();
res
.
setSummary
(
items
);
return
Result
.
success
(
res
);
}
private
List
<
Map
<
String
,
Object
>>
queryCountByAppointmentMethod
(
String
levelType
,
String
levelValue
,
LocalDate
dt
)
{
QueryWrapper
<
OrderRequest
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
select
(
"appointment_method, appointment_status, COUNT(*) as count"
)
.
lambda
()
.
eq
(
OrderRequest:
:
getDt
,
dt
)
.
eq
(
levelType
.
equals
(
"cluster"
),
OrderRequest:
:
getOrgClusterId
,
levelValue
)
.
eq
(
levelType
.
equals
(
"branch"
),
OrderRequest:
:
getOrgBranchId
,
levelValue
)
.
eq
(
levelType
.
equals
(
"group"
),
OrderRequest:
:
getOrgGroupId
,
levelValue
)
.
groupBy
(
OrderRequest:
:
getAppointmentMethod
,
OrderRequest:
:
getAppointmentStatus
);
return
orderRequestMPDao
.
selectMaps
(
wrapper
);
}
private
List
<
Map
<
String
,
Object
>>
queryCountByOrderStatus
(
String
levelType
,
String
levelValue
,
LocalDate
dt
)
{
QueryWrapper
<
OrderRequest
>
wrapper
=
new
QueryWrapper
<>();
wrapper
.
select
(
"appointment_status, COUNT(*) as count"
)
.
lambda
()
.
eq
(
OrderRequest:
:
getDt
,
dt
)
.
eq
(
levelType
.
equals
(
"cluster"
),
OrderRequest:
:
getOrgClusterId
,
levelValue
)
.
eq
(
levelType
.
equals
(
"branch"
),
OrderRequest:
:
getOrgBranchId
,
levelValue
)
.
eq
(
levelType
.
equals
(
"group"
),
OrderRequest:
:
getOrgGroupId
,
levelValue
)
.
groupBy
(
OrderRequest:
:
getAppointmentStatus
);
return
orderRequestMPDao
.
selectMaps
(
wrapper
);
}
private
HashMap
<
String
,
Integer
>
transAppointmentMethod
(
List
<
Map
<
String
,
Object
>>
results
)
{
HashMap
<
String
,
Integer
>
map
=
new
HashMap
<>();
Integer
manualTotal
=
0
;
// 人工
Integer
autoTotal
=
0
;
Integer
total
=
0
;
for
(
Map
<
String
,
Object
>
result
:
results
)
{
String
method
=
(
String
)
result
.
get
(
"appointment_method"
);
String
status
=
(
String
)
result
.
get
(
"appointment_status"
);
Integer
count
=
(
int
)
result
.
get
(
"count"
);
total
+=
count
;
if
(
method
.
equals
(
"MANUAL"
))
{
manualTotal
+=
count
;
}
else
if
(
method
.
startsWith
(
"AUTO_"
))
{
autoTotal
+=
count
;
}
if
(
method
.
equals
(
"MANUAL"
)
&&
status
.
equals
(
"NOT_ASSIGNED"
))
{
map
.
put
(
"manualDealing"
,
count
);
}
else
if
(
method
.
equals
(
"AUTO_"
)
&&
status
.
equals
(
"NOT_ASSIGNED"
))
{
map
.
put
(
"autoDealing"
,
count
);
}
}
map
.
put
(
"manualTotal"
,
manualTotal
);
map
.
put
(
"autoTotal"
,
autoTotal
);
map
.
put
(
"total"
,
total
);
return
map
;
}
private
HashMap
<
String
,
Integer
>
transOrderStatus
(
List
<
Map
<
String
,
Object
>>
results
)
{
HashMap
<
String
,
Integer
>
map
=
new
HashMap
<>();
for
(
Map
<
String
,
Object
>
result
:
results
)
{
String
status
=
(
String
)
result
.
get
(
"appointment_status"
);
Integer
count
=
(
int
)
result
.
get
(
"count"
);
map
.
put
(
status
,
count
);
}
return
map
;
}
private
List
<
WorkbenchSummaryResp
.
ValueDTO
>
packValueAppointmentMethod
(
HashMap
<
String
,
Integer
>
summary
)
{
List
<
WorkbenchSummaryResp
.
ValueDTO
>
items
=
new
ArrayList
<>();
String
url
=
"/dispatchBench/index"
;
Integer
manualDealing
=
summary
.
getOrDefault
(
"manualDealing"
,
0
);
Integer
manualTotal
=
summary
.
getOrDefault
(
"manualTotal"
,
0
);
Integer
autoDealing
=
summary
.
getOrDefault
(
"autoDealing"
,
0
);
Integer
autoTotal
=
summary
.
getOrDefault
(
"autoTotal"
,
0
);
Integer
total
=
summary
.
getOrDefault
(
"total"
,
0
);
items
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"待人工处理"
,
manualDealing
.
toString
(),
manualTotal
.
toString
(),
"#FF8000"
,
url
));
items
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"待自动处理"
,
autoDealing
.
toString
(),
autoTotal
.
toString
(),
"#469967"
,
url
));
items
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"全部订单"
,
null
,
total
.
toString
(),
null
,
url
));
return
items
;
}
private
List
<
WorkbenchSummaryResp
.
ValueDTO
>
packValueOrderStatus
(
HashMap
<
String
,
Integer
>
summary
)
{
List
<
WorkbenchSummaryResp
.
ValueDTO
>
items
=
new
ArrayList
<>();
String
url
=
"/dispatchBench/index"
;
Integer
assigned
=
summary
.
getOrDefault
(
"ASSIGNED"
,
0
);
Integer
contacted
=
summary
.
getOrDefault
(
"CONTACTED"
,
0
);
Integer
departed
=
summary
.
getOrDefault
(
"DEPARTED"
,
0
);
Integer
dealing
=
assigned
+
contacted
+
departed
;
Integer
started
=
summary
.
getOrDefault
(
"STARTED"
,
0
);
Integer
cancel
=
summary
.
getOrDefault
(
"CANCELED"
,
0
);
Integer
finished
=
summary
.
getOrDefault
(
"FINISHED"
,
0
);
items
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"待上门"
,
dealing
.
toString
(),
null
,
"#469967"
,
url
));
items
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"服务中"
,
started
.
toString
(),
null
,
"#016FFF"
,
url
));
items
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"已完成"
,
finished
.
toString
(),
null
,
null
,
url
));
items
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"已取消"
,
cancel
.
toString
(),
null
,
null
,
url
));
items
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"已改约"
,
"0"
,
null
,
null
,
url
));
items
.
add
(
new
WorkbenchSummaryResp
.
ValueDTO
(
"已延误"
,
"0"
,
null
,
"#FF3D44"
,
url
));
return
items
;
}
}
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