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
b2fc693d
Commit
b2fc693d
authored
Nov 28, 2023
by
吕明尚
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加房间语音播报
parent
e387b1f9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
102 additions
and
57 deletions
+102
-57
VoiceEnum.java
share-common/src/main/java/share/common/enums/VoiceEnum.java
+4
-1
RedisTask.java
share-quartz/src/main/java/share/quartz/task/RedisTask.java
+46
-48
SOrderServiceImpl.java
...ain/java/share/system/service/impl/SOrderServiceImpl.java
+47
-4
SRoomServiceImpl.java
...main/java/share/system/service/impl/SRoomServiceImpl.java
+5
-4
No files found.
share-common/src/main/java/share/common/enums/VoiceEnum.java
View file @
b2fc693d
...
@@ -37,7 +37,10 @@ public enum VoiceEnum {
...
@@ -37,7 +37,10 @@ public enum VoiceEnum {
}
}
public
String
getValue
(
String
name
)
{
public
String
getValue
(
String
name
)
{
return
name
+
value
;
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
name
);
sb
.
append
(
value
);
return
sb
.
toString
();
}
}
public
String
getValue
()
{
public
String
getValue
()
{
...
...
share-quartz/src/main/java/share/quartz/task/RedisTask.java
View file @
b2fc693d
...
@@ -4,17 +4,8 @@ import cn.hutool.core.date.DatePattern;
...
@@ -4,17 +4,8 @@ import cn.hutool.core.date.DatePattern;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
import
com.alibaba.fastjson2.JSON
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse
;
import
com.dianping.openapi.sdk.api.oauth.entity.CustomerRefreshTokenResponse
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.HttpClients
;
import
org.apache.http.util.EntityUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
org.springframework.util.CollectionUtils
;
...
@@ -26,8 +17,6 @@ import share.system.domain.Device;
...
@@ -26,8 +17,6 @@ import share.system.domain.Device;
import
share.system.domain.SOrder
;
import
share.system.domain.SOrder
;
import
share.system.domain.SRoom
;
import
share.system.domain.SRoom
;
import
share.system.service.*
;
import
share.system.service.*
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.Set
;
...
@@ -109,54 +98,22 @@ public class RedisTask {
...
@@ -109,54 +98,22 @@ public class RedisTask {
//获取key对应的value
//获取key对应的value
String
value
=
redisUtil
.
get
(
String
.
valueOf
(
o
));
String
value
=
redisUtil
.
get
(
String
.
valueOf
(
o
));
JSONObject
jsonObject
=
new
JSONObject
(
value
);
JSONObject
jsonObject
=
new
JSONObject
(
value
);
long
expire
=
redisUtil
.
getExpire
(
o
);
Date
expirationTime
=
jsonObject
.
getDate
(
"expirationTime"
);
//判断时间是否在15分钟到14分钟
//判断时间是否在15分钟到14分钟
long
expire
=
(
expirationTime
.
getTime
()
-
new
Date
().
getTime
())
/
1000
;
if
(
expire
<
60
*
15
&&
expire
>
60
*
14
)
{
if
(
expire
<
60
*
15
&&
expire
>
60
*
14
)
{
//语音
//语音
String
orderNo
=
jsonObject
.
getStr
(
"orderNo"
);
getResult
(
o
,
jsonObject
,
VoiceEnum
.
RENEWAL_REMINDER1
.
getValue
());
SOrder
sOrder
=
isOrderService
.
selectSOrderByOrderNo
(
orderNo
);
//判断订单单是否存在
if
(
ObjectUtils
.
isEmpty
(
sOrder
))
{
redisUtil
.
delete
(
o
);
throw
new
BaseException
(
"订单不存在!"
);
}
LambdaQueryWrapper
<
Device
>
deviceLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
deviceLambdaQueryWrapper
.
eq
(
Device:
:
getRoomId
,
sOrder
.
getRoomId
());
deviceLambdaQueryWrapper
.
eq
(
Device:
:
getDevType
,
DeviceType
.
DEVICE_0001
.
getCode
());
Device
device
=
deviceService
.
getOne
(
deviceLambdaQueryWrapper
);
if
(
ObjectUtils
.
isEmpty
(
device
))
{
throw
new
BaseException
(
"设备不存在!"
);
}
mqttxService
.
actionExecute
(
device
.
getDevId
(),
sOrder
.
getConsumerPhone
(),
VoiceEnum
.
RENEWAL_REMINDER1
.
getValue
(),
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
DateUtil
.
format
(
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
);
return
;
return
;
}
}
//判断时间是否在5分钟到4分钟
//判断时间是否在5分钟到4分钟
if
(
expire
<
60
*
5
&&
expire
>
60
*
4
)
{
if
(
expire
<
60
*
5
&&
expire
>
60
*
4
)
{
String
orderNo
=
jsonObject
.
getStr
(
"orderNo"
);
getResult
(
o
,
jsonObject
,
VoiceEnum
.
RENEWAL_REMINDER2
.
getValue
());
SOrder
sOrder
=
isOrderService
.
selectSOrderByOrderNo
(
orderNo
);
//判断订单单是否存在
if
(
ObjectUtils
.
isEmpty
(
sOrder
))
{
redisUtil
.
delete
(
o
);
throw
new
BaseException
(
"订单不存在!"
);
}
LambdaQueryWrapper
<
Device
>
deviceLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>();
deviceLambdaQueryWrapper
.
eq
(
Device:
:
getRoomId
,
sOrder
.
getRoomId
());
deviceLambdaQueryWrapper
.
eq
(
Device:
:
getDevType
,
DeviceType
.
DEVICE_0001
.
getCode
());
Device
device
=
deviceService
.
getOne
(
deviceLambdaQueryWrapper
);
if
(
ObjectUtils
.
isEmpty
(
device
))
{
throw
new
BaseException
(
"设备不存在!"
);
}
mqttxService
.
actionExecute
(
device
.
getDevId
(),
sOrder
.
getConsumerPhone
(),
VoiceEnum
.
RENEWAL_REMINDER2
.
getValue
(),
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
DateUtil
.
format
(
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
);
return
;
return
;
}
}
Date
expirationTime
=
jsonObject
.
getDate
(
"expirationTime"
);
//判断是否过期
//判断是否过期
if
(
expirationTime
.
getTime
()
<
new
Date
().
getTime
())
{
if
(
expirationTime
.
getTime
()
<
new
Date
().
getTime
())
{
//获取redis中的订单编号
String
orderNo
=
jsonObject
.
getStr
(
"orderNo"
);
String
orderNo
=
jsonObject
.
getStr
(
"orderNo"
);
SOrder
sOrder
=
isOrderService
.
selectSOrderByOrderNo
(
orderNo
);
SOrder
sOrder
=
isOrderService
.
selectSOrderByOrderNo
(
orderNo
);
//判断订单单是否存在
//判断订单单是否存在
...
@@ -196,10 +153,51 @@ public class RedisTask {
...
@@ -196,10 +153,51 @@ public class RedisTask {
if
(
b
)
{
if
(
b
)
{
//删除redis中的值
//删除redis中的值
redisUtil
.
delete
(
o
);
redisUtil
.
delete
(
o
);
Device
device
=
new
Device
();
device
.
setRoomId
(
sOrder
.
getRoomId
());
device
.
setDevType
(
DeviceType
.
DEVICE_0001
.
getCode
());
Device
device1
=
deviceService
.
selectDeviceList
(
device
).
get
(
0
);
if
(
ObjectUtils
.
isEmpty
(
device1
))
{
throw
new
BaseException
(
"设备不存在!"
);
}
mqttxService
.
actionExecute
(
device
.
getDevId
(),
sOrder
.
getConsumerPhone
(),
VoiceEnum
.
SEND_CUSTOMER
.
getValue
(),
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
DateUtil
.
format
(
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
);
}
}
}
}
});
});
}
}
private
void
getResult
(
String
o
,
JSONObject
jsonObject
,
String
value
)
{
String
orderNo
=
jsonObject
.
getStr
(
"orderNo"
);
SOrder
sOrder
=
isOrderService
.
selectSOrderByOrderNo
(
orderNo
);
//判断订单单是否存在
if
(
ObjectUtils
.
isEmpty
(
sOrder
))
{
redisUtil
.
delete
(
o
);
throw
new
BaseException
(
"订单不存在!"
);
}
Device
device
=
new
Device
();
device
.
setRoomId
(
sOrder
.
getRoomId
());
device
.
setDevType
(
DeviceType
.
DEVICE_0001
.
getCode
());
Device
device1
=
deviceService
.
selectDeviceList
(
device
).
get
(
0
);
if
(
ObjectUtils
.
isEmpty
(
device1
))
{
throw
new
BaseException
(
"设备不存在!"
);
}
mqttxService
.
actionExecute
(
device
.
getDevId
(),
sOrder
.
getConsumerPhone
(),
value
,
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
DateUtil
.
format
(
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
);
}
private
static
class
Result
{
public
final
SOrder
sOrder
;
public
final
Device
device
;
public
Result
(
SOrder
sOrder
,
Device
device
)
{
this
.
sOrder
=
sOrder
;
this
.
device
=
device
;
}
}
}
}
share-system/src/main/java/share/system/service/impl/SOrderServiceImpl.java
View file @
b2fc693d
...
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
...
@@ -4,6 +4,7 @@ import java.math.BigDecimal;
import
java.util.*
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
cn.hutool.core.date.DatePattern
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.date.DateUnit
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONObject
;
...
@@ -16,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
...
@@ -16,6 +17,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.util.ObjectUtils
;
import
share.common.constant.Constants
;
import
share.common.constant.Constants
;
import
share.common.core.redis.RedisUtil
;
import
share.common.core.redis.RedisUtil
;
import
share.common.enums.*
;
import
share.common.enums.*
;
...
@@ -89,6 +91,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -89,6 +91,9 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
@Autowired
@Autowired
private
ISConsumptionRecordsService
sConsumptionRecordsService
;
private
ISConsumptionRecordsService
sConsumptionRecordsService
;
@Autowired
private
MqttxService
mqttxService
;
/**
/**
* 查询订单
* 查询订单
*
*
...
@@ -612,6 +617,25 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -612,6 +617,25 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
consumerCouponService
.
updateById
(
consumerCoupon
);
consumerCouponService
.
updateById
(
consumerCoupon
);
}
}
}
}
//续费成功语音播报
if
(
sOrder
.
getOrderType
().
equals
(
OrderTypeEnum
.
RENEW
.
getCode
()))
{
SOrder
sOrder1
=
baseMapper
.
selectSOrderById
(
sOrder
.
getId
());
//判断订单单是否存在
if
(
ObjectUtils
.
isEmpty
(
sOrder1
))
{
redisUtil
.
delete
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
sOrder
.
getOrderNo
());
throw
new
BaseException
(
"订单不存在!"
);
}
Device
device
=
new
Device
();
device
.
setRoomId
(
sOrder
.
getRoomId
());
device
.
setDevType
(
DeviceType
.
DEVICE_0001
.
getCode
());
Device
device1
=
deviceService
.
selectDeviceList
(
device
).
get
(
0
);
if
(
ObjectUtils
.
isEmpty
(
device1
))
{
throw
new
BaseException
(
"设备不存在!"
);
}
mqttxService
.
actionExecute
(
device1
.
getDevId
(),
sOrder1
.
getConsumerPhone
(),
VoiceEnum
.
RENEWAL_SUCCESS
.
getValue
(),
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
);
}
SConsumptionRecords
sConsumptionRecords
=
new
SConsumptionRecords
();
SConsumptionRecords
sConsumptionRecords
=
new
SConsumptionRecords
();
sConsumptionRecords
.
setConsumerId
(
sOrder
.
getConsumerId
());
sConsumptionRecords
.
setConsumerId
(
sOrder
.
getConsumerId
());
sConsumptionRecords
.
setOrderId
(
sOrder
.
getId
());
sConsumptionRecords
.
setOrderId
(
sOrder
.
getId
());
...
@@ -762,10 +786,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -762,10 +786,10 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if
(
Objects
.
isNull
(
sRoomVo
))
{
if
(
Objects
.
isNull
(
sRoomVo
))
{
throw
new
BaseException
(
"房间不存在!"
);
throw
new
BaseException
(
"房间不存在!"
);
}
}
LambdaQueryWrapper
<
Device
>
deviceLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>
();
Device
device
=
new
Device
();
device
LambdaQueryWrapper
.
eq
(
Device:
:
getRoomId
,
sOrder
.
getRoomId
());
device
.
setRoomId
(
sOrder
.
getRoomId
());
device
LambdaQueryWrapper
.
eq
(
Device:
:
getDevType
,
DeviceType
.
DEVICE_CCEE
.
getCode
());
device
.
setDevType
(
DeviceType
.
DEVICE_CCEE
.
getCode
());
Device
one
=
deviceService
.
getOne
(
deviceLambdaQueryWrapper
);
Device
one
=
deviceService
.
selectDeviceList
(
device
).
get
(
0
);
if
(
Objects
.
isNull
(
one
))
{
if
(
Objects
.
isNull
(
one
))
{
throw
new
BaseException
(
"设备不存在!"
);
throw
new
BaseException
(
"设备不存在!"
);
}
}
...
@@ -786,6 +810,25 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
...
@@ -786,6 +810,25 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
JSONObject
jsonObject
=
new
JSONObject
(
map
);
JSONObject
jsonObject
=
new
JSONObject
(
map
);
redisUtils
.
set
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
sOrder
.
getOrderNo
(),
jsonObject
.
toString
());
redisUtils
.
set
(
ReceiptRdeisEnum
.
ORDER_NO_KEY
.
getValue
()
+
sOrder
.
getOrderNo
(),
jsonObject
.
toString
());
baseMapper
.
updateById
(
sOrder
);
baseMapper
.
updateById
(
sOrder
);
Device
device1
=
new
Device
();
device1
.
setRoomId
(
sOrder
.
getRoomId
());
device1
.
setDevType
(
DeviceType
.
DEVICE_0001
.
getCode
());
Device
device2
=
deviceService
.
selectDeviceList
(
device1
).
get
(
0
);
if
(
ObjectUtils
.
isEmpty
(
device2
))
{
throw
new
BaseException
(
"设备不存在!"
);
}
SStore
sStore
=
storeService
.
getById
(
sOrder
.
getStoreId
());
String
value
=
"欢迎来到凑角共享棋牌"
+
sStore
.
getName
();
//延时5秒
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
mqttxService
.
actionExecute
(
device2
.
getDevId
(),
sOrder
.
getConsumerPhone
(),
VoiceEnum
.
OPEN
.
getValue
(
value
),
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
new
Date
(),
DatePattern
.
NORM_DATETIME_PATTERN
),
cn
.
hutool
.
core
.
date
.
DateUtil
.
format
(
cn
.
hutool
.
core
.
date
.
DateUtil
.
offsetMinute
(
new
Date
(),
1
),
DatePattern
.
NORM_DATETIME_PATTERN
),
"1"
);
//查询非当前用户,预约时间或使用时间为当前时间的订单,如果存在,房间不可开门
//查询非当前用户,预约时间或使用时间为当前时间的订单,如果存在,房间不可开门
}
}
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
SConsumer
user
=
FrontTokenComponent
.
getWxSConsumerEntry
();
...
...
share-system/src/main/java/share/system/service/impl/SRoomServiceImpl.java
View file @
b2fc693d
...
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.util.ObjectUtils
;
import
share.common.enums.DeviceType
;
import
share.common.enums.DeviceType
;
import
share.common.enums.RoleTypeEnum
;
import
share.common.enums.RoleTypeEnum
;
import
share.common.exception.base.BaseException
;
import
share.common.exception.base.BaseException
;
...
@@ -232,10 +233,10 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
...
@@ -232,10 +233,10 @@ public class SRoomServiceImpl extends ServiceImpl<SRoomMapper, SRoom> implements
if
(
Objects
.
isNull
(
room
))
{
if
(
Objects
.
isNull
(
room
))
{
throw
new
RuntimeException
(
"房间不存在"
);
throw
new
RuntimeException
(
"房间不存在"
);
}
}
LambdaQueryWrapper
<
Device
>
deviceLambdaQueryWrapper
=
new
LambdaQueryWrapper
<>
();
Device
device
=
new
Device
();
device
LambdaQueryWrapper
.
eq
(
Device:
:
getRoomId
,
id
);
device
.
setRoomId
(
id
);
device
LambdaQueryWrapper
.
eq
(
Device:
:
getDevType
,
DeviceType
.
DEVICE_CCEE
.
getCode
());
device
.
setDevType
(
DeviceType
.
DEVICE_CCEE
.
getCode
());
Device
one
=
deviceService
.
getOne
(
deviceLambdaQueryWrapper
);
Device
one
=
deviceService
.
selectDeviceList
(
device
).
get
(
0
);
if
(
Objects
.
isNull
(
one
))
{
if
(
Objects
.
isNull
(
one
))
{
throw
new
BaseException
(
"设备不存在!"
);
throw
new
BaseException
(
"设备不存在!"
);
}
}
...
...
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