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
1156ca14
Commit
1156ca14
authored
Nov 14, 2023
by
YG8999
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
短信发送
parent
6eadd203
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
233 additions
and
18 deletions
+233
-18
application-dev.yml
share-admin/src/main/resources/application-dev.yml
+6
-0
SmsConts.java
...-common/src/main/java/share/common/constant/SmsConts.java
+1
-1
SmsUtil.java
share-common/src/main/java/share/common/utils/SmsUtil.java
+29
-12
application-dev.yml
share-front/src/main/resources/application-dev.yml
+6
-0
CleanRecordsTask.java
...rtz/src/main/java/share/quartz/task/CleanRecordsTask.java
+23
-0
SCleanRecordsMapper.java
...rc/main/java/share/system/mapper/SCleanRecordsMapper.java
+2
-0
ISCleanRecordsService.java
...main/java/share/system/service/ISCleanRecordsService.java
+6
-0
SCleanRecordsServiceImpl.java
...a/share/system/service/impl/SCleanRecordsServiceImpl.java
+16
-0
SmsServiceImpl.java
...c/main/java/share/system/service/impl/SmsServiceImpl.java
+92
-5
SCleanRecordsMapper.xml
.../src/main/resources/mapper/system/SCleanRecordsMapper.xml
+52
-0
No files found.
share-admin/src/main/resources/application-dev.yml
View file @
1156ca14
...
...
@@ -141,6 +141,12 @@ spring:
defaultTopic
:
"
ydlink/#"
completion-timeout
:
15000
is-subscribe-topic
:
true
sms
:
url
:
"
http://121.36.230.249:7862/smsv2"
username
:
"
799243"
password
:
"
RjaI8uA"
extno
:
"
10690"
signature
:
"
【凑角】"
# token配置
token
:
...
...
share-common/src/main/java/share/common/constant/SmsConts.java
View file @
1156ca14
...
...
@@ -31,7 +31,7 @@ public class SmsConts {
/**
* 短信一对一发送接口
*/
public
final
static
String
smsCodeTemp
=
"
【消费保】
您的验证码是:{0},有效期为{1}分钟。如非本人操作,可不予理会。"
;
public
final
static
String
smsCodeTemp
=
"您的验证码是:{0},有效期为{1}分钟。如非本人操作,可不予理会。"
;
}
share-common/src/main/java/share/common/utils/SmsUtil.java
View file @
1156ca14
package
share
.
common
.
utils
;
import
cn.hutool.core.date.DateUtil
;
import
cn.hutool.core.util.StrUtil
;
import
cn.hutool.crypto.SecureUtil
;
import
cn.hutool.json.JSONObject
;
import
cn.hutool.json.JSONUtil
;
...
...
@@ -14,6 +15,8 @@ import share.common.constant.SmsConts;
import
share.common.utils.http.RestTemplateUtil
;
import
share.common.exception.base.BaseException
;
import
java.text.MessageFormat
;
/**
* @author wuwenlong
* @date 2022年10月13日 15:33
...
...
@@ -54,20 +57,34 @@ public class SmsUtil {
return
SecureUtil
.
md5
(
SmsConts
.
USERNAME
+
timestamp
+
SecureUtil
.
md5
(
SmsConts
.
PASSWORD
));
}
/**
* 短信平台密码加密
* @param password
* @param extno
* @param mobile
* @param content
* @return
*/
public
String
md5Password
(
String
password
,
String
extno
,
String
mobile
,
String
content
)
{
return
SecureUtil
.
md5
(
StrUtil
.
concat
(
true
,
password
,
extno
,
mobile
,
content
));
}
public
static
void
main
(
String
[]
args
)
{
Integer
code
=
BaseUtil
.
randomCount
(
111111
,
999999
);
long
timestamp
=
DateUtil
.
date
().
getTime
();
String
content
=
MessageFormat
.
format
(
SmsConts
.
smsCodeTemp
,
code
.
toString
(),
"5"
);
// 发送内容添加短信签名
String
smsContent
=
StrUtil
.
concat
(
true
,
"【凑角】"
,
content
);
String
mobile
=
"18062577819"
;
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
put
(
"
userName"
,
SmsConts
.
USERNAME
);
param
.
put
(
"
timestamp"
,
timestamp
);
param
.
put
(
"
sign"
,
SecureUtil
.
md5
(
SmsConts
.
USERNAME
+
timestamp
+
SecureUtil
.
md5
(
SmsConts
.
PASSWORD
)));
//
JSONObject json = JSONUtil.createObj(
);
// json.put("phone", "18771045387"
);
//
json.put("content", MessageFormat.format(SmsConts.smsCodeTemp, code.toString(), 3)
);
// JSONArray array = JSONUtil.createArray(
);
// array.add(json
);
// param.put("
messageList",array
);
param
.
put
(
"
action"
,
"send"
);
param
.
put
(
"
account"
,
"799243"
);
param
.
put
(
"
password"
,
SecureUtil
.
md5
(
StrUtil
.
concat
(
true
,
"RjaI8uA"
,
"10690"
,
mobile
,
smsContent
)));
//
param.put("password","RjaI8uA"
);
param
.
put
(
"mobile"
,
mobile
);
//
param.put("mobileEencryptionMode", ""
);
param
.
put
(
"content"
,
smsContent
);
param
.
put
(
"extno"
,
"10690"
);
// param.put("
atTime", ""
);
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
param
));
HttpHeaders
headers
=
new
HttpHeaders
();
...
...
@@ -78,7 +95,7 @@ public class SmsUtil {
HttpEntity
<
JSONObject
>
requestEntity
=
new
HttpEntity
<>(
param
,
headers
);
RestTemplate
restTemplate
=
new
RestTemplate
();
cn
.
hutool
.
json
.
JSONObject
body
=
restTemplate
.
postForEntity
(
SmsConts
.
BASE_URL
+
SmsConts
.
querySignature
,
requestEntity
,
cn
.
hutool
.
json
.
JSONObject
.
class
).
getBody
();
cn
.
hutool
.
json
.
JSONObject
body
=
restTemplate
.
postForEntity
(
"http://121.36.230.249:7862/smsv2"
,
requestEntity
,
cn
.
hutool
.
json
.
JSONObject
.
class
).
getBody
();
System
.
out
.
println
(
JSONUtil
.
toJsonStr
(
body
));
}
...
...
share-front/src/main/resources/application-dev.yml
View file @
1156ca14
...
...
@@ -143,6 +143,12 @@ spring:
defaultTopic
:
"
ydlink/#"
completion-timeout
:
15000
is-subscribe-topic
:
false
sms
:
url
:
"
http://121.36.230.249:7862/smsv2"
username
:
"
799243"
password
:
"
RjaI8uA"
extno
:
"
10690"
signature
:
"
【凑角】"
# token配置
token
:
...
...
share-quartz/src/main/java/share/quartz/task/CleanRecordsTask.java
0 → 100644
View file @
1156ca14
package
share
.
quartz
.
task
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
share.system.service.ISCleanRecordsService
;
/**
* @className: share.quartz.task.CleanRecordsTask
* @description: 保洁记录定时任务
* @author: lwj
* @create: 2023-11-13 10:52
*/
@Component
(
"cleanRecordsTask"
)
public
class
CleanRecordsTask
{
@Autowired
private
ISCleanRecordsService
cleanRecordsService
;
public
void
finishCleanRecords
()
{
cleanRecordsService
.
finishCleanRecords
();
}
}
share-system/src/main/java/share/system/mapper/SCleanRecordsMapper.java
View file @
1156ca14
...
...
@@ -65,4 +65,6 @@ public interface SCleanRecordsMapper extends BaseMapper<SCleanRecords>
List
<
SCleanRecords
>
unCleanList
(
SCleanRecords
sCleanRecords
);
List
<
SCleanRecords
>
myCleanList
(
SCleanRecords
sCleanRecords
);
int
updateBatch
(
List
<
SCleanRecords
>
list
);
}
share-system/src/main/java/share/system/service/ISCleanRecordsService.java
View file @
1156ca14
...
...
@@ -74,4 +74,10 @@ public interface ISCleanRecordsService
SCleanRecords
getByRoomId
(
Long
roomId
);
SCleanRecords
getByCleanerId
();
/**
* 超时未打扫房间自动结束打扫
* @return
*/
boolean
finishCleanRecords
();
}
share-system/src/main/java/share/system/service/impl/SCleanRecordsServiceImpl.java
View file @
1156ca14
...
...
@@ -2,6 +2,7 @@ package share.system.service.impl;
import
java.util.List
;
import
cn.hutool.core.date.DateUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
share.common.enums.CleaningStatusEnum
;
import
share.common.enums.RoleTypeEnum
;
...
...
@@ -165,6 +166,21 @@ public class SCleanRecordsServiceImpl implements ISCleanRecordsService
return
sCleanRecords
;
}
@Override
public
boolean
finishCleanRecords
()
{
LambdaQueryWrapper
<
SCleanRecords
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
SCleanRecords:
:
getStatus
,
0
);
queryWrapper
.
ge
(
SCleanRecords:
:
getCreateTime
,
DateUtil
.
offsetMinute
(
DateUtil
.
date
(),
-
30
));
List
<
SCleanRecords
>
list
=
sCleanRecordsMapper
.
selectList
(
queryWrapper
);
for
(
SCleanRecords
sCleanRecords
:
list
)
{
sCleanRecords
.
setStatus
(
2
);
sCleanRecords
.
setStartDate
(
DateUtil
.
date
());
sCleanRecords
.
setEndDate
(
DateUtil
.
date
());
sCleanRecords
.
setUpdateTime
(
DateUtil
.
date
());
}
return
0
<
sCleanRecordsMapper
.
updateBatch
(
list
);
}
private
void
sendSms
(
Long
storeId
)
{
List
<
SConsumer
>
list
=
sConsumerMapper
.
selectListByStoreId
(
storeId
);
for
(
SConsumer
consumer
:
list
)
{
...
...
share-system/src/main/java/share/system/service/impl/SmsServiceImpl.java
View file @
1156ca14
...
...
@@ -8,6 +8,7 @@ import cn.hutool.json.JSONUtil;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
share.common.constant.Constants
;
import
share.common.constant.SmsConstants
;
...
...
@@ -19,6 +20,8 @@ import share.system.service.SConsumerService;
import
share.system.service.SmsService
;
import
java.text.MessageFormat
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Objects
;
import
java.util.concurrent.TimeUnit
;
...
...
@@ -32,6 +35,21 @@ import java.util.concurrent.TimeUnit;
public
class
SmsServiceImpl
implements
SmsService
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
SmsServiceImpl
.
class
);
@Value
(
"${spring.sms.url}"
)
private
String
url
;
@Value
(
"${spring.sms.extno}"
)
private
String
extno
;
@Value
(
"${spring.sms.username}"
)
private
String
userName
;
@Value
(
"${spring.sms.password}"
)
private
String
passWord
;
@Value
(
"${spring.sms.signature}"
)
private
String
signature
;
@Autowired
private
SmsUtil
smsUtil
;
@Autowired
...
...
@@ -62,8 +80,7 @@ public class SmsServiceImpl implements SmsService {
try
{
if
(
tag
.
equals
(
SmsConstants
.
SMS_CONFIG_TYPE_VERIFICATION_CODE
))
{
//TODO 发送短信
JSONObject
jsonObject
=
smsUtil
.
postFrom
(
SmsConts
.
BASE_URL
+
SmsConts
.
sendMessageOne
,
new
JSONObject
());
JSONObject
jsonObject
=
sendOneSms
(
phone
,
getSmsContent
(
phone
,
tag
));
Boolean
isSendCode
=
Objects
.
nonNull
(
jsonObject
);
//TODO 发送成功判断??
if
(
isSendCode
)
{
return
isSendCode
;
...
...
@@ -80,9 +97,8 @@ public class SmsServiceImpl implements SmsService {
@Override
public
boolean
sendSmsCode
(
String
phone
)
{
redisUtil
.
set
(
sConsumerService
.
getValidateCodeRedisKey
(
phone
),
"123456"
,
Long
.
valueOf
(
Constants
.
CONFIG_KEY_SMS_CODE_EXPIRE
),
TimeUnit
.
MINUTES
);
return
true
;
//TODO 手机验证吗待对接短信平台 sendSms(phone, SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE);
// redisUtil.set(sConsumerService.getValidateCodeRedisKey(phone), "123456", Long.valueOf(Constants.CONFIG_KEY_SMS_CODE_EXPIRE), TimeUnit.MINUTES);
return
sendSms
(
phone
,
SmsConstants
.
SMS_CONFIG_TYPE_VERIFICATION_CODE
);
//TODO 手机验证吗待对接短信平台 sendSms(phone, SmsConstants.SMS_CONFIG_TYPE_VERIFICATION_CODE);
}
private
String
getSmsContent
(
String
phone
,
Integer
tag
)
{
...
...
@@ -105,4 +121,75 @@ public class SmsServiceImpl implements SmsService {
}
}
/**
* 短信群发
* @param phoneList 手机号码集合
* @param content 发送内容
* @return
*/
private
JSONObject
sendGroupSms
(
List
<
String
>
phoneList
,
String
content
)
{
// 发送内容添加短信签名
String
smsContent
=
StrUtil
.
concat
(
true
,
signature
,
content
);
String
phoneStr
=
String
.
join
(
","
,
phoneList
);
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
put
(
"action"
,
"send"
);
param
.
put
(
"account"
,
userName
);
param
.
put
(
"password"
,
smsUtil
.
md5Password
(
passWord
,
extno
,
phoneStr
,
smsContent
));
param
.
put
(
"mobile"
,
phoneStr
);
// param.put("mobileEencryptionMode", "");
param
.
put
(
"content"
,
smsContent
);
param
.
put
(
"extno"
,
extno
);
// param.put("atTime", "");
return
smsUtil
.
postFrom
(
url
,
param
);
}
/**
* 单独发送
* @param phone 手机号
* @param content 发送内容
* @return
*/
private
JSONObject
sendOneSms
(
String
phone
,
String
content
)
{
// 发送内容添加短信签名
String
smsContent
=
StrUtil
.
concat
(
true
,
signature
,
content
);
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
put
(
"action"
,
"send"
);
param
.
put
(
"account"
,
userName
);
param
.
put
(
"password"
,
smsUtil
.
md5Password
(
passWord
,
extno
,
phone
,
smsContent
));
param
.
put
(
"mobile"
,
phone
);
// param.put("mobileEencryptionMode", "");
param
.
put
(
"content"
,
smsContent
);
param
.
put
(
"extno"
,
extno
);
// param.put("atTime", "");
return
smsUtil
.
postFrom
(
url
,
param
);
}
/**
* 点对点发送
* @param map 手机号码:发送内容 {"15100000000":"【测试】test1","15100000001":"【测试】test2"}
* @return
*/
private
JSONObject
sendP2PSms
(
Map
<
String
,
String
>
map
)
{
String
content
=
""
;
if
(
map
!=
null
)
{
for
(
Map
.
Entry
<
String
,
String
>
entry
:
map
.
entrySet
())
{
// 发送内容添加短信签名
String
smsContent
=
StrUtil
.
concat
(
true
,
signature
,
entry
.
getValue
());
map
.
put
(
entry
.
getKey
(),
smsContent
);
content
=
StrUtil
.
concat
(
true
,
content
,
entry
.
getKey
(),
entry
.
getValue
());
}
}
JSONObject
param
=
JSONUtil
.
createObj
();
param
.
put
(
"action"
,
"p2p"
);
param
.
put
(
"account"
,
userName
);
param
.
put
(
"password"
,
smsUtil
.
md5Password
(
passWord
,
extno
,
""
,
content
));
param
.
put
(
"mobileContentKvp"
,
map
);
// param.put("mobileEencryptionMode", "");
param
.
put
(
"extno"
,
extno
);
// param.put("atTime", "");
return
smsUtil
.
postFrom
(
url
,
param
);
}
}
share-system/src/main/resources/mapper/system/SCleanRecordsMapper.xml
View file @
1156ca14
...
...
@@ -138,6 +138,58 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim>
where id = #{id}
</update>
<update
id=
"updateBatch"
parameterType=
"list"
>
update s_clean_records
<trim
prefix=
"set"
suffixOverrides=
","
>
<trim
prefix=
" start_date =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.startDate!=null"
>
when id=#{i.id} then #{i.startDate}
</if>
</foreach>
</trim>
<trim
prefix=
" end_date =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.endDate!=null"
>
when id=#{i.id} then #{i.endDate}
</if>
</foreach>
</trim>
<trim
prefix=
" status =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.status!=null"
>
when id=#{i.id} then #{i.status}
</if>
</foreach>
</trim>
<trim
prefix=
" update_time =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.updateTime!=null"
>
when id=#{i.id} then #{i.updateTime}
</if>
</foreach>
</trim>
<trim
prefix=
" start_image =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.startImage!=null"
>
when id=#{i.id} then #{i.startImage}
</if>
</foreach>
</trim>
<trim
prefix=
" end_image =case"
suffix=
"end,"
>
<foreach
collection=
"list"
item=
"i"
index=
"index"
>
<if
test=
"i.endImage!=null"
>
when id=#{i.id} then #{i.endImage}
</if>
</foreach>
</trim>
</trim>
where
<foreach
collection=
"list"
separator=
"or"
item=
"i"
index=
"index"
>
id=#{i.id}
</foreach>
</update>
<delete
id=
"deleteSCleanRecordsById"
parameterType=
"Long"
>
delete from s_clean_records where id = #{id}
...
...
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