Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
Y
yifu-mvp
Project
Project
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
fangxinjiang
yifu-mvp
Commits
78dd39a9
Commit
78dd39a9
authored
Oct 21, 2025
by
fangxinjiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
短信模板替换-fxj
parent
303d8207
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
348 additions
and
160 deletions
+348
-160
EmployeeRegistrationPreServiceImpl.java
...ives/service/impl/EmployeeRegistrationPreServiceImpl.java
+217
-159
pom.xml
yifu-common/yifu-common-core/pom.xml
+12
-0
RlySmsUtil.java
.../yifu/cloud/plus/v1/yifu/common/core/util/RlySmsUtil.java
+117
-0
spring.factories
...-common-core/src/main/resources/META-INF/spring.factories
+2
-1
No files found.
yifu-archives/yifu-archives-biz/src/main/java/com/yifu/cloud/plus/v1/yifu/archives/service/impl/EmployeeRegistrationPreServiceImpl.java
View file @
78dd39a9
This diff is collapsed.
Click to expand it.
yifu-common/yifu-common-core/pom.xml
View file @
78dd39a9
...
...
@@ -121,5 +121,17 @@
<artifactId>
xlsx-streamer
</artifactId>
<version>
2.2.0
</version>
</dependency>
<!-- 容联云短信SDK -->
<dependency>
<groupId>
com.cloopen
</groupId>
<artifactId>
java-sms-sdk
</artifactId>
<version>
1.0.3
</version>
</dependency>
<!-- gson 解析 -->
<dependency>
<groupId>
com.google.code.gson
</groupId>
<artifactId>
gson
</artifactId>
<version>
2.8.6
</version>
</dependency>
</dependencies>
</project>
yifu-common/yifu-common-core/src/main/java/com/yifu/cloud/plus/v1/yifu/common/core/util/RlySmsUtil.java
0 → 100644
View file @
78dd39a9
package
com
.
yifu
.
cloud
.
plus
.
v1
.
yifu
.
common
.
core
.
util
;
import
com.cloopen.rest.sdk.BodyType
;
import
com.cloopen.rest.sdk.CCPRestSmsSDK
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.stereotype.Component
;
import
java.util.HashMap
;
import
java.util.Set
;
/**
* 容联云短信实现工具类,可以单个发送短信,批量发送短信
*
* @author fxj
* @version 1.0
* @since 2025/10/21
*/
@Component
@Data
@Slf4j
public
class
RlySmsUtil
{
private
CCPRestSmsSDK
sdk
;
// 服务器地址
private
String
serverIp
=
"app.cloopen.com"
;
// 服务器端口
private
String
serverPort
=
"8883"
;
// 主账号
private
String
accountSId
=
"8a48b5515388ec150153acb1cd5b3899"
;
// 主账号令牌
private
String
accountToken
=
"5487aa42bb574b47aca1c785b4e7c018"
;
// 应用ID
private
String
appId
=
"2c94811c9787a27f019854cd1b532b7e"
;
/**
* 初始化SDK
*
* @param accountSId 主账号
* @param accountToken 主账号令牌
* @param appId 应用ID
*/
public
void
init
(
String
accountSId
,
String
accountToken
,
String
appId
)
{
if
(
null
==
sdk
){
this
.
accountSId
=
accountSId
;
this
.
accountToken
=
accountToken
;
this
.
appId
=
appId
;
sdk
=
new
CCPRestSmsSDK
();
sdk
.
init
(
serverIp
,
serverPort
);
sdk
.
setAccount
(
accountSId
,
accountToken
);
sdk
.
setAppId
(
appId
);
sdk
.
setBodyType
(
BodyType
.
Type_JSON
);
}
}
/**
* 单个发送短信
*
* @param phoneNumber 手机号码
* @param templateId 模板ID
* @param datas 短信参数
* @return 发送结果 true-成功 false-失败
*/
public
boolean
sendSingleSms
(
String
phoneNumber
,
String
templateId
,
String
[]
datas
)
{
init
(
accountSId
,
accountToken
,
appId
);
HashMap
<
String
,
Object
>
result
=
sdk
.
sendTemplateSMS
(
phoneNumber
,
templateId
,
datas
);
if
(
"000000"
.
equals
(
result
.
get
(
"statusCode"
)))
{
// 正常返回输出data包体信息
HashMap
<
String
,
Object
>
data
=
(
HashMap
<
String
,
Object
>)
result
.
get
(
"data"
);
Set
<
String
>
keySet
=
data
.
keySet
();
for
(
String
key
:
keySet
)
{
Object
object
=
data
.
get
(
key
);
}
return
true
;
}
else
{
// 异常返回输出错误码和错误信息
log
.
error
(
"错误码="
+
result
.
get
(
"statusCode"
)
+
" 错误信息= "
+
result
.
get
(
"statusMsg"
));
return
false
;
}
}
/**
* 批量发送短信
*
* @param phoneNumbers 手机号码数组
* @param templateId 模板ID
* @param datas 短信参数
* @return 发送结果 true-成功 false-失败
*/
public
HashMap
<
String
,
Object
>
sendBatchSms
(
String
[]
phoneNumbers
,
String
templateId
,
String
[][]
datas
)
{
init
(
accountSId
,
accountToken
,
appId
);
// 将手机号数组转换为逗号分隔的字符串
StringBuilder
phoneNumbersStr
=
new
StringBuilder
();
for
(
int
i
=
0
;
i
<
phoneNumbers
.
length
;
i
++)
{
if
(
i
>
0
)
{
phoneNumbersStr
.
append
(
","
);
}
phoneNumbersStr
.
append
(
phoneNumbers
[
i
]);
}
// 容联云短信SDK只支持单个模板参数数组,不直接支持多个不同参数
// 这里假设所有手机号使用相同参数发送
// 如果需要不同的参数,需要多次调用单个发送方法
String
[]
singleData
=
datas
.
length
>
0
?
datas
[
0
]
:
new
String
[
0
];
HashMap
<
String
,
Object
>
result
=
sdk
.
sendTemplateSMS
(
phoneNumbersStr
.
toString
(),
templateId
,
singleData
);
return
result
;
}
}
\ No newline at end of file
yifu-common/yifu-common-core/src/main/resources/META-INF/spring.factories
View file @
78dd39a9
...
...
@@ -7,4 +7,5 @@ org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.yifu.cloud.plus.v1.yifu.common.core.config.WebMvcConfiguration,\
com.yifu.cloud.plus.v1.yifu.common.core.util.OSSUtil,\
com.yifu.cloud.plus.v1.yifu.common.core.util.RedisUtil,\
com.yifu.cloud.plus.v1.yifu.common.core.redis.lock4j.MyLockFailureStrategy
com.yifu.cloud.plus.v1.yifu.common.core.redis.lock4j.MyLockFailureStrategy,\
com.yifu.cloud.plus.v1.yifu.common.core.util.RlySmsUtil
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