Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gxpt_ht
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
pseer
gxpt_ht
Commits
8c9a7505
Commit
8c9a7505
authored
Nov 15, 2024
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时任务增加异常捕获
parent
e78932ff
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
91 additions
and
87 deletions
+91
-87
RedisTask.java
share-quartz/src/main/java/share/quartz/task/RedisTask.java
+91
-87
No files found.
share-quartz/src/main/java/share/quartz/task/RedisTask.java
View file @
8c9a7505
...
...
@@ -275,88 +275,89 @@ public class RedisTask {
add
(
OrderStatusEnum
.
INUSE
.
getCode
());
}});
List
<
SOrder
>
sOrders
=
isOrderService
.
list
(
queryWrapper
);
keys
.
stream
().
forEach
(
o
->
{
//获取key对应的value
String
value
=
redisUtil
.
get
(
String
.
valueOf
(
o
));
JSONObject
jsonObject
=
new
JSONObject
(
value
);
Date
expirationTime
=
jsonObject
.
getDate
(
"expirationTime"
);
SOrder
sOrder
;
sOrder
=
sOrders
.
stream
().
filter
(
item
->
item
.
getOrderNo
().
equals
(
jsonObject
.
getStr
(
"orderNo"
))).
findFirst
().
orElse
(
null
);
if
(
ObjectUtils
.
isEmpty
(
sOrder
))
{
sOrder
=
isOrderService
.
getByOrderNo
(
jsonObject
.
getStr
(
"orderNo"
));
for
(
String
o
:
keys
)
{
try
{
//获取key对应的value
String
value
=
redisUtil
.
get
(
String
.
valueOf
(
o
));
JSONObject
jsonObject
=
new
JSONObject
(
value
);
Date
expirationTime
=
jsonObject
.
getDate
(
"expirationTime"
);
SOrder
sOrder
;
sOrder
=
sOrders
.
stream
().
filter
(
item
->
item
.
getOrderNo
().
equals
(
jsonObject
.
getStr
(
"orderNo"
))).
findFirst
().
orElse
(
null
);
if
(
ObjectUtils
.
isEmpty
(
sOrder
))
{
redisUtil
.
delete
(
o
);
logger
.
debug
(
"订单号为:{}的订单不存在"
,
jsonObject
.
getStr
(
"orderNo"
));
throw
new
BaseException
(
"订单不存在!"
);
}
}
long
expire
=
(
expirationTime
.
getTime
()
-
new
Date
().
getTime
())
/
1000
;
//判断时间是否在15分钟到14分钟
if
(
expire
<
FIFTEEN_MINUTES
&&
expire
>
FOURTEEN_MINUTES
)
{
if
(
extracted
(
o
,
sOrders
,
sOrder
))
return
;
deviceOpService
.
actionExecute
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
VoiceEnum
.
RENEWAL_REMINDER1
.
getCode
(),
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
DateUtil
.
format
(
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
,
DeviceOpSourceEnum
.
DEVICE_SOURCE_20
.
getCode
());
logger
.
debug
(
"订单号为:"
+
sOrder
.
getOrderNo
()
+
"的订单距离结束时间还有15分钟"
);
// 从门店集合中判断门店id相同的门店对象
SOrder
finalSOrder
=
sOrder
;
SStore
sStore
=
sStoreList
.
stream
().
filter
(
item
->
item
.
getId
().
equals
(
finalSOrder
.
getStoreId
())).
findFirst
().
orElse
(
null
);
// 从房间集合中判断房间id相同的房间对象
SRoom
sRoom
=
sRoomList
.
stream
().
filter
(
item
->
item
.
getId
().
equals
(
finalSOrder
.
getRoomId
())).
findFirst
().
orElse
(
null
);
// 通知用户
smsService
.
sendSmsOrderEndRemind
(
sOrder
.
getConsumerPhone
(),
sStore
,
sRoom
);
//推送订单结束消息
wechatNewService
.
sendMiniSubscribeMessage
(
sOrder
,
MessageReminderEnum
.
END
);
logger
.
debug
(
"保洁工单派单通知发送开始"
);
//通知保洁人员
sConsumerService
.
selectListByStoreId
(
sOrder
.
getStoreId
()).
stream
().
forEach
(
item
->
{
if
(
item
.
getTextMessage
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
// 循环发送短信提示门店保洁打扫卫生
smsService
.
sendSmsCleanRecordsRemind15
(
item
.
getPhone
(),
sStore
,
sRoom
);
sOrder
=
isOrderService
.
getByOrderNo
(
jsonObject
.
getStr
(
"orderNo"
));
if
(
ObjectUtils
.
isEmpty
(
sOrder
))
{
redisUtil
.
delete
(
o
);
logger
.
debug
(
"订单号为:{}的订单不存在"
,
jsonObject
.
getStr
(
"orderNo"
));
throw
new
BaseException
(
"订单不存在!"
);
}
if
(
item
.
getOfficialAccount
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
//公众号发送保洁工单派单通知
wechatNewService
.
sendPublicTemplateMessage
(
finalSOrder
,
MessageReminderEnum
.
CLEANING
,
item
.
getId
());
}
});
logger
.
debug
(
"保洁工单派单通知发送结束"
);
return
;
}
//判断时间是否在5分钟到4分钟
if
(
expire
<
FIVE_MINUTES
&&
expire
>
FOUR_MINUTES
)
{
if
(
extracted
(
o
,
sOrders
,
sOrder
))
return
;
deviceOpService
.
actionExecute
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
VoiceEnum
.
RENEWAL_REMINDER2
.
getCode
(),
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
DateUtil
.
format
(
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
,
DeviceOpSourceEnum
.
DEVICE_SOURCE_20
.
getCode
());
logger
.
debug
(
"订单号为:"
+
sOrder
.
getOrderNo
()
+
"的订单距离结束时间还有5分钟"
);
}
//判断是否过期
if
(
expirationTime
.
getTime
()
<
new
Date
().
getTime
())
{
//判断订单单是否存在
if
(
ObjectUtils
.
isEmpty
(
sOrder
))
{
redisUtil
.
delete
(
o
);
throw
new
BaseException
(
"订单不存在!"
);
}
//权益返利活动
equityFundExcessService
.
extracted
(
sOrder
);
if
(
extracted
(
o
,
sOrders
,
sOrder
))
return
;
//更改订单状态
sOrder
.
setStatus
(
OrderStatusEnum
.
USED
.
getCode
());
isOrderService
.
updateById
(
sOrder
);
// 修改房间状态
SRoom
room
=
roomService
.
getById
(
sOrder
.
getRoomId
());
if
(
ObjectUtil
.
isNotEmpty
(
room
))
{
room
.
setStatus
(
RoomStatusEnum
.
FREE
.
getValue
());
room
.
setUpdateTime
(
new
Date
());
roomService
.
updateById
(
room
);
long
expire
=
(
expirationTime
.
getTime
()
-
new
Date
().
getTime
())
/
1000
;
//判断时间是否在15分钟到14分钟
if
(
expire
<
FIFTEEN_MINUTES
&&
expire
>
FOURTEEN_MINUTES
)
{
if
(
extracted
(
o
,
sOrders
,
sOrder
))
return
;
deviceOpService
.
actionExecute
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
VoiceEnum
.
RENEWAL_REMINDER1
.
getCode
(),
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
DateUtil
.
format
(
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
,
DeviceOpSourceEnum
.
DEVICE_SOURCE_20
.
getCode
());
logger
.
debug
(
"订单号为:"
+
sOrder
.
getOrderNo
()
+
"的订单距离结束时间还有15分钟"
);
// 从门店集合中判断门店id相同的门店对象
SOrder
finalSOrder
=
sOrder
;
SStore
sStore
=
sStoreList
.
stream
().
filter
(
item
->
item
.
getId
().
equals
(
finalSOrder
.
getStoreId
())).
findFirst
().
orElse
(
null
);
// 从房间集合中判断房间id相同的房间对象
SRoom
sRoom
=
sRoomList
.
stream
().
filter
(
item
->
item
.
getId
().
equals
(
finalSOrder
.
getRoomId
())).
findFirst
().
orElse
(
null
);
// 通知用户
smsService
.
sendSmsOrderEndRemind
(
sOrder
.
getConsumerPhone
(),
sStore
,
sRoom
);
//推送订单结束消息
wechatNewService
.
sendMiniSubscribeMessage
(
sOrder
,
MessageReminderEnum
.
END
);
logger
.
debug
(
"保洁工单派单通知发送开始"
);
//通知保洁人员
sConsumerService
.
selectListByStoreId
(
sOrder
.
getStoreId
()).
stream
().
forEach
(
item
->
{
if
(
item
.
getTextMessage
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
// 循环发送短信提示门店保洁打扫卫生
smsService
.
sendSmsCleanRecordsRemind15
(
item
.
getPhone
(),
sStore
,
sRoom
);
}
if
(
item
.
getOfficialAccount
().
equals
(
YesNoEnum
.
yes
.
getIndex
()))
{
//公众号发送保洁工单派单通知
wechatNewService
.
sendPublicTemplateMessage
(
finalSOrder
,
MessageReminderEnum
.
CLEANING
,
item
.
getId
());
}
});
logger
.
debug
(
"保洁工单派单通知发送结束"
);
return
;
}
//判断订单是否已经添加保洁记录
SCleanRecords
cleanRecords
=
isCleanRecordsService
.
lastCleanByRoomId
(
sOrder
.
getRoomId
());
if
(
ObjectUtils
.
isEmpty
(
cleanRecords
)
||
cleanRecords
.
getStatus
().
compareTo
(
CleaningStatusEnum
.
UNCLEAN
.
getCode
())
!=
0
)
{
boolean
b
=
isCleanRecordsService
.
addSCleanRecords
(
sOrder
.
getStoreId
(),
sOrder
.
getRoomId
());
//判断时间是否在5分钟到4分钟
if
(
expire
<
FIVE_MINUTES
&&
expire
>
FOUR_MINUTES
)
{
if
(
extracted
(
o
,
sOrders
,
sOrder
))
return
;
deviceOpService
.
actionExecute
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
VoiceEnum
.
RENEWAL_REMINDER2
.
getCode
(),
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
DateUtil
.
format
(
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
,
DeviceOpSourceEnum
.
DEVICE_SOURCE_20
.
getCode
());
logger
.
debug
(
"订单号为:"
+
sOrder
.
getOrderNo
()
+
"的订单距离结束时间还有5分钟"
);
}
//判断是否过期
if
(
expirationTime
.
getTime
()
<
new
Date
().
getTime
())
{
//判断订单单是否存在
if
(
ObjectUtils
.
isEmpty
(
sOrder
))
{
redisUtil
.
delete
(
o
);
throw
new
BaseException
(
"订单不存在!"
);
}
//权益返利活动
equityFundExcessService
.
extracted
(
sOrder
);
if
(
extracted
(
o
,
sOrders
,
sOrder
))
return
;
//更改订单状态
sOrder
.
setStatus
(
OrderStatusEnum
.
USED
.
getCode
());
isOrderService
.
updateById
(
sOrder
);
// 修改房间状态
SRoom
room
=
roomService
.
getById
(
sOrder
.
getRoomId
());
if
(
ObjectUtil
.
isNotEmpty
(
room
))
{
room
.
setStatus
(
RoomStatusEnum
.
FREE
.
getValue
());
room
.
setUpdateTime
(
new
Date
());
roomService
.
updateById
(
room
);
}
//判断订单是否已经添加保洁记录
SCleanRecords
cleanRecords
=
isCleanRecordsService
.
lastCleanByRoomId
(
sOrder
.
getRoomId
());
if
(
ObjectUtils
.
isEmpty
(
cleanRecords
)
||
cleanRecords
.
getStatus
().
compareTo
(
CleaningStatusEnum
.
UNCLEAN
.
getCode
())
!=
0
)
{
boolean
b
=
isCleanRecordsService
.
addSCleanRecords
(
sOrder
.
getStoreId
(),
sOrder
.
getRoomId
());
}
//删除redis中的值
redisUtil
.
delete
(
o
);
deviceOpService
.
actionExecute
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
VoiceEnum
.
SEND_CUSTOMER
.
getCode
(),
...
...
@@ -364,18 +365,21 @@ public class RedisTask {
DateUtil
.
format
(
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
,
DeviceOpSourceEnum
.
DEVICE_SOURCE_20
.
getCode
());
//延时3分钟断电
deviceOpService
.
openOrCloseDevice
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
OpTypeEnum
.
CUT_ELECTRIC
.
getCode
(),
false
,
0L
,
deviceOpService
.
openOrCloseDevice
(
sOrder
.
getRoomId
(),
sOrder
.
getConsumerPhone
(),
OpTypeEnum
.
CUT_ELECTRIC
.
getCode
(),
false
,
0L
,
DeviceOpSourceEnum
.
DEVICE_SOURCE_20
.
getCode
());
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"orderNo"
,
sOrder
.
getOrderNo
());
//当前时间加15分钟
Date
date
=
DateUtil
.
offsetMinute
(
sOrder
.
getEndDate
(),
15
);
map
.
put
(
"expirationTime"
,
date
.
toString
());
JSONObject
json
=
new
JSONObject
(
map
);
redisUtil
.
set
(
ReceiptRdeisEnum
.
ROOM_EXPIRE_TIME
.
getValue
()
+
sOrder
.
getOrderNo
(),
json
.
toString
());
logger
.
debug
(
"订单号为:"
+
sOrder
.
getOrderNo
()
+
"的订单已结束,更改订单状态为已使用"
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"orderNo"
,
sOrder
.
getOrderNo
());
//当前时间加15分钟
Date
date
=
DateUtil
.
offsetMinute
(
sOrder
.
getEndDate
(),
15
);
map
.
put
(
"expirationTime"
,
date
.
toString
());
JSONObject
json
=
new
JSONObject
(
map
);
redisUtil
.
set
(
ReceiptRdeisEnum
.
ROOM_EXPIRE_TIME
.
getValue
()
+
sOrder
.
getOrderNo
(),
json
.
toString
());
logger
.
debug
(
"订单号为:"
+
sOrder
.
getOrderNo
()
+
"的订单已结束,更改订单状态为已使用"
);
}
}
catch
(
BaseException
e
)
{
continue
;
}
}
);
}
logger
.
debug
(
"AutoAddSCleanRecords:自动添加保洁记录结束"
);
}
@XxlJob
(
"autoRoomExpireTime"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment