Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
task3.0
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
首航-临时账号
task3.0
Commits
4140c265
Commit
4140c265
authored
May 06, 2019
by
zt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加检测功能
parent
d91c74b8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
56 deletions
+82
-56
DbSoundsMonitorTask.java
src/main/java/com/foc/DbSoundsMonitorTask.java
+30
-1
Email.java
src/main/java/com/foc/service/Email.java
+0
-1
Sms.java
src/main/java/com/foc/service/Sms.java
+22
-28
SoundMonitorService.java
src/main/java/com/foc/service/SoundMonitorService.java
+4
-9
PropertiesUtil.java
src/main/java/com/foc/util/PropertiesUtil.java
+11
-6
global.properties
src/main/resources/global.properties
+15
-11
No files found.
src/main/java/com/foc/DbSoundsMonitorTask.java
View file @
4140c265
package
com
.
foc
;
import
com.foc.entity.AccessInfo
;
import
com.foc.service.Sms
;
import
com.foc.service.SoundMonitorService
;
import
com.foc.util.PropertiesUtil
;
import
java.util.Properties
;
/**
* @Author: lisu
* @Date: 2019/4/29 15:35
...
...
@@ -9,7 +16,29 @@ package com.foc;
* 3.查看安科数据库最后一条数据
*/
public
class
DbSoundsMonitorTask
{
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
if
(
args
==
null
||
args
.
length
==
0
){
loadConf
(
Thread
.
currentThread
().
getContextClassLoader
().
getResource
(
"global.properties"
).
getPath
());
}
else
{
loadConf
(
args
[
0
]);
}
}
public
static
void
loadConf
(
String
path
)
throws
Exception
{
//查看定时任务最后同步时间
SoundMonitorService
.
init
();
Integer
i
=
SoundMonitorService
.
test
();
if
(
i
==
2
){
//发送短信
AccessInfo
accessInfo
=
new
AccessInfo
();
accessInfo
.
setAicc
(
"5"
);
accessInfo
.
setAicp
(
"10.68.26.52"
);
// accessInfo.setAict("21");
Properties
properties
=
PropertiesUtil
.
getProperties
(
path
);
String
result
=
Sms
.
sendSms
(
accessInfo
,
properties
.
getProperty
(
"mobile"
),
"警告"
);
System
.
out
.
println
(
result
);
}
}
}
src/main/java/com/foc/service/Email.java
View file @
4140c265
...
...
@@ -93,7 +93,6 @@ public class Email {
return
res
;
}
public
void
testEmail
()
throws
Exception
{
//拼装附件mapList
...
...
src/main/java/com/foc/service/Sms.java
View file @
4140c265
package
com
.
foc
.
service
;
import
com.foc.entity.AccessInfo
;
import
com.foc.util.HttpClientUtils
;
import
com.foc.util.PropertiesUtil
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.client.HttpClient
;
...
...
@@ -36,36 +37,29 @@ public class Sms {
String
smsUrl
=
properties
.
getProperty
(
"smsUrl"
);
String
result
;
HttpClient
httpClient
=
HttpClients
.
createDefault
();
result
=
HttpClientUtils
.
doGet
(
smsUrl
+
"?ai.cp="
+
accessInfo
.
getAicp
()
+
"&ai.cc="
+
accessInfo
.
getAicc
()
+
"&mobile="
+
mobile
+
"&msg="
+
msg
);
try
{
HttpPost
httpPost
=
new
HttpPost
(
smsUrl
+
"?ai.cp="
+
accessInfo
.
getAicp
()
+
"&ai.cc="
+
accessInfo
.
getAicc
()
+
"&mobile="
+
mobile
+
"&msg="
+
msg
);
HttpResponse
response
=
httpClient
.
execute
(
httpPost
);
logger
.
info
(
response
.
toString
());
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
}
//发送get请求
// if (StringUtils.isEmpty(accessInfo.getAisign())){
// // + "&Ai.ct=" + accessInfo.getAict()
// result = HttpClientUtils.doGet(smsUrl + "?ai.cp=" + accessInfo.getAicp() + "&ai.cc=" + accessInfo.getAicc()
// + "&mobile=" + mobile + "&msg=" + msg );
// }else{
// result = HttpClientUtils.doGet(smsUrl + "?ai.cp=" + accessInfo.getAicp() + "&ai.cc=" + accessInfo.getAicc()
// + "&Ai.ct=" + accessInfo.getAict() + "&ai.sign=" + accessInfo.getAisign() + "&mobile=" + mobile + "&msg=" + msg );
// HttpClient httpClient = HttpClients.createDefault();
// try {
// HttpPost httpPost = new HttpPost(smsUrl + "?ai.cp=" + accessInfo.getAicp() + "&ai.cc=" + accessInfo.getAicc()
// + "&mobile=" + mobile + "&msg=" + msg);
// HttpResponse response = httpClient.execute(httpPost);
// logger.info(response.toString());
// return response.toString();
// } catch (Exception ex) {
// ex.printStackTrace();
// }
return
null
;
}
public
static
void
main
(
String
[]
args
)
{
AccessInfo
accessInfo
=
new
AccessInfo
();
accessInfo
.
setAicc
(
"5"
);
accessInfo
.
setAicp
(
"123.56.146.7"
);
// accessInfo.setAict("21");
String
res
=
Sms
.
sendSms
(
accessInfo
,
"13222650486"
,
"HelloWorld"
);
System
.
out
.
println
(
res
);
return
result
;
}
// public static void main(String[] args) {
// AccessInfo accessInfo = new AccessInfo();
// accessInfo.setAicc("5");
// accessInfo.setAicp("10.68.26.52");
//// accessInfo.setAict("21");
// String res = Sms.sendSms(accessInfo, "13222650486", "HelloWorld");
// System.out.println(res);
// }
}
src/main/java/com/foc/service/SoundMonitorService.java
View file @
4140c265
...
...
@@ -49,7 +49,6 @@ public class SoundMonitorService {
String
updateTime
=
maxId
.
getUpdateDate
();
log
.
info
(
"当前系统时间:"
+
new
Date
());
//比较时间,如果相差20分钟没有执行
//计数
int
i
=
0
;
List
<
SoundInfo
>
list
=
soundsMaxIdDao
.
getInfo
(
updateTime
);
...
...
@@ -59,28 +58,24 @@ public class SoundMonitorService {
i
++;
}
}
if
(
i
!=
0
&&
list
!=
null
){
double
d
=
i
/
list
.
size
();
if
(
d
>
0.8
){
log
.
info
(
"成功率不足80%"
);
return
1
;
}
}
else
{
log
.
info
(
"全部成功"
);
return
2
;
}
return
null
;
}
public
static
void
main
(
String
[]
args
)
{
init
();
System
.
out
.
println
(
test
());
}
//
public static void main(String[] args) {
//
init();
//
System.out.println(test());
//
}
}
src/main/java/com/foc/util/PropertiesUtil.java
View file @
4140c265
package
com
.
foc
.
util
;
import
java.io.FileInputStream
;
import
java.io.InputStream
;
import
java.util.Properties
;
...
...
@@ -8,18 +9,19 @@ import java.util.Properties;
*/
public
class
PropertiesUtil
{
private
PropertiesUtil
()
{
}
private
PropertiesUtil
()
{}
private
static
Properties
properties
=
null
;
public
static
Properties
getProperties
()
{
public
static
Properties
getProperties
(
String
path
)
{
if
(
properties
==
null
)
{
try
{
Properties
properties
=
new
Properties
();
InputStream
in
=
PropertiesUtil
.
class
.
getClassLoader
().
getResourceAsStream
(
"global.properties"
);
properties
.
load
(
in
);
Properties
prop
=
new
Properties
();
InputStream
in
=
new
FileInputStream
(
path
);
// InputStream in = PropertiesUtil.class.getClassLoader().getResourceAsStream("global.properties");
prop
.
load
(
in
);
properties
=
prop
;
return
properties
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -28,5 +30,8 @@ public class PropertiesUtil {
return
properties
;
}
public
static
Properties
getProperties
()
{
return
properties
;
}
}
src/main/resources/global.properties
View file @
4140c265
#短信外网测试URL
smsUrl
=
http://114.251.242.194:808/flightinterface/uss/json/mobile/messSend.json
#短信内网测试URL
#������������URL
#smsUrl=http://114.251.242.194:808/flightinterface/uss/json/mobile/messSend.json
smsUrl
=
http://user.jdair.net/ussinterface/uss/json/mobile/messSend.json
#������������URL
#smsUrl=http://10.70.35.68:808/flightinterface/uss/json/mobile/messSend.json?
#
邮件测试环境
#
�ʼ����Ի���
emailUrl
=
http://10.70.72.110/api/inner/ESBService
#
邮件正式环境
#
�ʼ���ʽ����
#emailUrl=http://esb.hna.net/api
#API
接口名称,查看个人订单-接口名称
#API
�ӿ����ƣ��鿴���˶���-�ӿ�����
emailMethod
=
Exchange_MailService_SendMail
#app
密钥,查看个人中心
-app key
#app
��Կ���鿴��������-app ke
y
Appsecret
=
9eztwb08qdvkzk0zadzdvtl6j1bssqvp
#应
用票据,查看个人中心
-app key
#Ӧ
��Ʊ�ݣ��鿴��������-app ke
y
AccessToken
=
A6BD747ECB212285E6DC3528EFB482AF04B40F17
#
发件人邮箱
#
����������
fromEmail
=
sdhkyxglzx@hnair.com
#
发件人的内网账号
#
�����˵������˺�
UserName
=
sdhkyxglzx
#
发件人的密码
#
�����˵�����
UserPwd
=
075.wxp
#手机
mobile
=
13222650486
\ No newline at end of file
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