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 b16e65d0
authored
Nov 16, 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
920ac40a
8df57e96
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
119 additions
and
2 deletions
project-order/src/main/java/com/dituhui/pea/order/dao/OrderInfoDao.java
project-order/src/main/java/com/dituhui/pea/order/scheduler/ServiceMsgScheduler.java
project-order/src/main/resources/application-dev.yaml
project-order/src/main/resources/application.yaml
project-order/src/main/java/com/dituhui/pea/order/dao/OrderInfoDao.java
View file @
b16e65d
...
@@ -104,4 +104,10 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
...
@@ -104,4 +104,10 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
@Query
(
value
=
"SELECT count(*) from order_info WHERE dt =:dt and service_status ='STARTED' and actual_end_time is null "
+
@Query
(
value
=
"SELECT count(*) from order_info WHERE dt =:dt and service_status ='STARTED' and actual_end_time is null "
+
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_branch_id = :orgBranchId"
,
nativeQuery
=
true
)
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_branch_id = :orgBranchId"
,
nativeQuery
=
true
)
long
countOvertimeByDtAndOrgBranchId
(
LocalDate
dt
,
String
orgBranchId
);
long
countOvertimeByDtAndOrgBranchId
(
LocalDate
dt
,
String
orgBranchId
);
@Query
(
value
=
"from OrderInfoEntity where orderStatus <> 'CANCELED' and engineerCode is not null"
+
" and planStartTime is not null and planEndTime is not null and planStartTime>?1"
+
" and ((actualStartTime is null and planStartTime<= ?2) "
+
" or (actualStartTime is not null and actualEndTime is null and planEndTime<= ?2))"
)
List
<
OrderInfoEntity
>
getDelayOrTimeoutOrder
(
LocalDateTime
today
,
LocalDateTime
now
);
}
}
project-order/src/main/java/com/dituhui/pea/order/scheduler/ServiceMsgScheduler.java
0 → 100644
View file @
b16e65d
package
com
.
dituhui
.
pea
.
order
.
scheduler
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.dituhui.pea.order.dao.*
;
import
com.dituhui.pea.order.dto.MsgDTO
;
import
com.dituhui.pea.order.entity.*
;
import
com.dituhui.pea.order.enums.MsgTagEnum
;
import
com.dituhui.pea.order.enums.MsgTypeEnum
;
import
com.dituhui.pea.order.service.MsgService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.List
;
import
java.util.Objects
;
@Slf4j
@Component
public
class
ServiceMsgScheduler
{
@Resource
private
OrderInfoDao
orderInfoDao
;
@Resource
private
MsgService
msgService
;
@Resource
private
OrgGroupDao
orgGroupDao
;
@Resource
private
OrgBranchDao
orgBranchDao
;
@Resource
private
OrgClusterDao
orgClusterDao
;
@Resource
private
EngineerInfoDao
engineerInfoDao
;
@Scheduled
(
cron
=
"${scheduler.service-msg}"
)
public
void
run
()
{
log
.
info
(
">>> 服务类消息预警开始"
);
LocalDateTime
today
=
LocalDateTimeUtil
.
beginOfDay
(
LocalDateTime
.
now
());
LocalDateTime
now
=
LocalDateTime
.
now
().
plusMinutes
(
10
);
List
<
OrderInfoEntity
>
orderList
=
orderInfoDao
.
getDelayOrTimeoutOrder
(
today
,
now
);
String
delayContent
=
"%s机构%s员工(工号%s)的%s工单未按预约开始时间%s上门"
;
String
timeoutContent
=
"%s机构%s员工(工号%s)的%s工单未按预约结束时间%s结束服务"
;
for
(
OrderInfoEntity
orderInfoEntity
:
orderList
)
{
try
{
MsgDTO
dto
=
new
MsgDTO
();
dto
.
setClusterId
(
orderInfoEntity
.
getOrgClusterId
());
dto
.
setBranchId
(
orderInfoEntity
.
getOrgBranchId
());
dto
.
setGroupId
(
orderInfoEntity
.
getOrgGroupId
());
dto
.
setType
(
MsgTypeEnum
.
SERVICE
.
getCode
());
dto
.
setTag
(
MsgTagEnum
.
URGENT
.
getCode
());
dto
.
setOrderIds
(
orderInfoEntity
.
getOrderId
());
String
orgName
=
null
;
try
{
if
(
StrUtil
.
isNotEmpty
(
dto
.
getGroupId
()))
{
orgName
=
orgGroupDao
.
getByGroupId
(
dto
.
getGroupId
()).
getGroupName
();
}
else
if
(
StrUtil
.
isNotEmpty
(
dto
.
getBranchId
()))
{
orgName
=
orgBranchDao
.
getByBranchId
(
dto
.
getBranchId
()).
getBranchName
();
}
else
if
(
StrUtil
.
isNotEmpty
(
dto
.
getClusterId
()))
{
orgName
=
orgClusterDao
.
getByClusterId
(
dto
.
getClusterId
()).
getName
();
}
}
catch
(
Exception
e
)
{
log
.
error
(
"工单({}) 组织机构未找到"
,
orderInfoEntity
.
getOrderId
());
}
String
engineerName
=
null
;
try
{
engineerName
=
engineerInfoDao
.
getByEngineerCode
(
orderInfoEntity
.
getEngineerCode
()).
getName
();
}
catch
(
Exception
e
)
{
log
.
error
(
"工程师({}) 未找到"
,
orderInfoEntity
.
getEngineerCode
());
}
if
(
Objects
.
isNull
(
orderInfoEntity
.
getActualStartTime
()))
{
//delay
dto
.
setContent
(
String
.
format
(
delayContent
,
orgName
,
engineerName
,
orderInfoEntity
.
getEngineerCode
(),
orderInfoEntity
.
getOrderId
(),
DateUtil
.
format
(
orderInfoEntity
.
getPlanStartTime
(),
"yyyy-MM-dd HH:mm"
)
));
}
else
{
//超时
dto
.
setContent
(
String
.
format
(
timeoutContent
,
orgName
,
engineerName
,
orderInfoEntity
.
getEngineerCode
(),
orderInfoEntity
.
getOrderId
(),
DateUtil
.
format
(
orderInfoEntity
.
getPlanEndTime
(),
"yyyy-MM-dd HH:mm"
)
));
}
msgService
.
add
(
dto
);
}
catch
(
Exception
e
)
{
log
.
error
(
"工单("
+
orderInfoEntity
.
getOrderId
()
+
") 预警消息保存失败:"
+
e
.
getMessage
(),
e
);
}
}
log
.
info
(
">>> 服务类消息预警结束"
);
}
}
project-order/src/main/resources/application-dev.yaml
View file @
b16e65d
...
@@ -90,4 +90,6 @@ scheduler:
...
@@ -90,4 +90,6 @@ scheduler:
# 8-20点,每小时1次
# 8-20点,每小时1次
cron-expr
:
0 0 1-23 * * ?
cron-expr
:
0 0 1-23 * * ?
day-offset-begin
:
0
day-offset-begin
:
0
day-offset-end
:
14
day-offset-end
:
14
\ No newline at end of file
service-msg
:
0 40 11,17 * * ?
\ No newline at end of file
project-order/src/main/resources/application.yaml
View file @
b16e65d
...
@@ -90,6 +90,9 @@ scheduler:
...
@@ -90,6 +90,9 @@ scheduler:
cron-expr
:
0 0 1-23 * * ?
cron-expr
:
0 0 1-23 * * ?
day-offset-begin
:
0
day-offset-begin
:
0
day-offset-end
:
20
day-offset-end
:
20
service-msg
:
0 0 11,17 * * ?
logging
:
logging
:
level
:
level
:
root
:
info
root
:
info
...
...
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