添加utils模块;

定时任务模块引入utils模块
wushunjie
吴顺杰 2 months ago
parent 3a38a3eb9b
commit 50d7f0a07f

@ -48,7 +48,7 @@ spring:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: ruoyi
login-password: 123456
login-password: jichuang@123
filter:
stat:
enabled: true

@ -17,6 +17,14 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.yingji</groupId>
<artifactId>utils</artifactId>
</dependency>
</dependencies>
<build>
<!--打包成jar包时的名字-->
<finalName>alarm</finalName>

@ -3,7 +3,7 @@ spring:
datasource:
url: jdbc:mysql://localhost:3306/algorithms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
password: jichuang@123
driverClassName: com.mysql.cj.jdbc.Driver

@ -17,6 +17,14 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.yingji</groupId>
<artifactId>utils</artifactId>
</dependency>
</dependencies>
<build>
<!--打包成jar包时的名字-->
<finalName>fire</finalName>

@ -16,6 +16,15 @@
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.yingji</groupId>
<artifactId>utils</artifactId>
</dependency>
</dependencies>
<build>
<!--打包成jar包时的名字-->
<finalName>page</finalName>

@ -3,7 +3,7 @@ spring:
datasource:
url: jdbc:mysql://localhost:3306/algorithms?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: 123456
password: jichuang@123
driverClassName: com.mysql.cj.jdbc.Driver

@ -13,6 +13,7 @@
<module>rescue</module>
<module>page</module>
<module>fire</module>
<module>utils</module>
</modules>
<properties>
<java.version>1.8</java.version>

@ -17,6 +17,14 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 通用工具-->
<dependency>
<groupId>com.yingji</groupId>
<artifactId>utils</artifactId>
</dependency>
</dependencies>
<build>
<!--打包成jar包时的名字-->
<finalName>rescue</finalName>

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yingji</groupId>
<artifactId>yingjiAlgorithms</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>utils</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

@ -0,0 +1,64 @@
package com.utils;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* @author wu
* @since 2024/9/24 10:18
*/
public class SmsUtil {
/**
* token
*
* @return token
*/
public static String getSmsToken() {
Map<String, Object> bodyMap = new HashMap<>();
bodyMap.put("uid", "yjglj_yjjyszzh");
bodyMap.put("pwd", "f604d2d6de51573b5cef5c95c11ffabe");
String bodyJson = JSONUtil.toJsonStr(bodyMap);
String responseStr = HttpRequest.post("http://2.46.42.43:80/admin-api/sms/token")
.body(bodyJson)
.execute()
.body();
JSONObject responseJson = JSONUtil.parseObj(responseStr);
return (String) responseJson.get("data");
}
/**
*
*
* @param content
* @param tel 使,
* @return
*/
public static Object sendSms(String content, String tel) {
String token = getSmsToken();
Map<String, Object> bodyMap = new HashMap<>();
bodyMap.put("uid", "yjglj_yjjyszzh");
bodyMap.put("pwd", "f604d2d6de51573b5cef5c95c11ffabe");
bodyMap.put("extensionNo", "2559");
if (StrUtil.isNotEmpty(tel)) {
bodyMap.put("tel", tel);
} else {
bodyMap.put("tel", "18870257135,18261462112,15850922852,18112760590");
}
bodyMap.put("content", "市应急局提醒: " + content);
String bodyJson = JSONUtil.toJsonStr(bodyMap);
String responseStr = HttpRequest.post("http://2.46.42.43:80/admin-api/sms/send")
.header("Authorization", token)
.body(bodyJson)
.execute()
.body();
return JSONUtil.parseObj(responseStr);
}
}
Loading…
Cancel
Save