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
95690c91
Commit
95690c91
authored
Oct 15, 2019
by
java-李谡
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改20分钟内梧桐花记录仍会预警bug
parent
fceef1eb
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
63 additions
and
76 deletions
+63
-76
pom.xml
pom.xml
+1
-1
SoundMonitorService.java
src/main/java/com/foc/service/SoundMonitorService.java
+60
-59
SoundsMaxIdMapper.xml
src/main/resources/mapper/SoundsMaxIdMapper.xml
+1
-5
mybatis-config.xml
src/main/resources/mybatis-config.xml
+1
-11
No files found.
pom.xml
View file @
95690c91
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
<groupId>
com.foc
</groupId>
<groupId>
com.foc
</groupId>
<artifactId>
task
</artifactId>
<artifactId>
task
</artifactId>
<version>
3.
0
-SNAPSHOT
</version>
<version>
3.
1
-SNAPSHOT
</version>
<properties>
<properties>
<!-- log4j日志文件管理包版本 -->
<!-- log4j日志文件管理包版本 -->
...
...
src/main/java/com/foc/service/SoundMonitorService.java
View file @
95690c91
...
@@ -58,62 +58,63 @@ public class SoundMonitorService {
...
@@ -58,62 +58,63 @@ public class SoundMonitorService {
*/
*/
public
static
boolean
test
()
{
public
static
boolean
test
()
{
Properties
properties
=
PropertiesUtils
.
getProperties
();
Properties
properties
=
PropertiesUtils
.
getProperties
();
//间隔时间
//
获取录音同步任务
间隔时间
String
interval
=
properties
.
getProperty
(
"interval"
);
String
interval
=
properties
.
getProperty
(
"interval"
);
SoundsMaxIdDao
soundsMaxIdDao
=
session
.
getMapper
(
SoundsMaxIdDao
.
class
);
SoundsMaxIdDao
soundsMaxIdDao
=
session
.
getMapper
(
SoundsMaxIdDao
.
class
);
//获取录音同步任务最后更新时间
SoundsMaxId
maxId
=
soundsMaxIdDao
.
getMaxId
();
SoundsMaxId
maxId
=
soundsMaxIdDao
.
getMaxId
();
String
updateTime
=
maxId
.
getUpdateDate
();
String
updateTime
=
maxId
.
getUpdateDate
();
Date
date
=
new
Date
();
Date
date
=
new
Date
();
log
.
info
(
"当前系统时间:{}"
,
date
);
log
.
info
(
"当前系统时间:{}"
,
date
);
FocSmsEmailRecord
focSmsEmailRecord
=
new
FocSmsEmailRecord
();
FocSmsEmailRecord
focSmsEmailRecord
=
new
FocSmsEmailRecord
();
focSmsEmailRecord
.
setCreateTime
(
date
);
focSmsEmailRecord
.
setCreateTime
(
date
);
//比较时间,如果相差20分钟没有执行
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
LocalDateTime
ldt
=
LocalDateTime
.
parse
(
updateTime
,
df
);
LocalDateTime
ldt
=
LocalDateTime
.
parse
(
updateTime
,
df
);
if
(
DateUtils
.
until
(
ldt
)
>
Long
.
parseLong
(
interval
)){
//获取录音同步任务最后一次更新时间后的通话成功的记录
//2019年10月5日14:38:07 zt
List
<
SoundInfo
>
list
=
soundsMaxIdDao
.
getInfo
(
updateTime
);
SoundInfo
soundInfo
=
soundsMaxIdDao
.
getInfoByUpdateTime
(
updateTime
);
//比较时间,如果相差20分钟没有执行
if
(
soundInfo
!=
null
){
if
(
DateUtils
.
until
(
ldt
)
>
Long
.
parseLong
(
interval
))
{
log
.
info
(
"更新时间与最新时间间隔大于20分钟,有通话记录start_time:{}"
,
soundInfo
.
getBeginTime
());
//判断通话记录,如果没有,则说明间隔时间内,未同步到录音记录,正常
}
else
{
if
(
CollectionUtils
.
isEmpty
(
list
))
{
log
.
info
(
"更新时间异常,与最新时间间隔大于20分钟,updateTime:{}"
,
updateTime
);
log
.
info
(
"最新同步时间20分钟内未查询到成功通话记录"
);
focSmsEmailRecord
.
setDescription
(
"更新时间异常,与最新时间间隔大于20分钟,updateTime为"
+
updateTime
);
focSmsEmailRecord
.
setDescription
(
"最新同步时间20分钟内未查询到成功通话记录"
);
focSmsEmailRecord
.
setMonitorState
((
short
)
1
);
focSmsEmailRecord
.
setMonitorState
((
short
)
0
);
soundsMaxIdDao
.
insertFocRecord
(
focSmsEmailRecord
);
session
.
commit
();
return
false
;
}
else
{
//说明录音定时任务未正常执行,异常
log
.
info
(
"更新时间异常,与最新时间间隔大于20分钟且有成功通话记录,updateTime:{}"
,
updateTime
);
focSmsEmailRecord
.
setDescription
(
"更新时间异常,与最新时间间隔大于20分钟且有成功通话记录,updateTime为"
+
updateTime
);
focSmsEmailRecord
.
setMonitorState
((
short
)
1
);
soundsMaxIdDao
.
insertFocRecord
(
focSmsEmailRecord
);
soundsMaxIdDao
.
insertFocRecord
(
focSmsEmailRecord
);
session
.
commit
();
session
.
commit
();
return
true
;
return
true
;
}
}
}
}
List
<
SoundInfo
>
list
=
soundsMaxIdDao
.
getInfo
(
updateTime
);
//录音任务正常同步,监测数据是否有录音文件下载地址,如果没有,说明录音功能异常
if
(
CollectionUtils
.
isEmpty
(
list
)){
for
(
SoundInfo
soundInfo
:
list
)
{
log
.
info
(
"查询不到记录"
);
focSmsEmailRecord
.
setDescription
(
"查询不到记录"
);
focSmsEmailRecord
.
setMonitorState
((
short
)
0
);
soundsMaxIdDao
.
insertFocRecord
(
focSmsEmailRecord
);
session
.
commit
();
return
false
;
}
for
(
SoundInfo
soundInfo
:
list
){
//成功且没有url的
//成功且没有url的
if
(
StringUtils
.
isEmpty
(
soundInfo
.
getDownloadUrl
()
)
){
if
(
StringUtils
.
isEmpty
(
soundInfo
.
getDownloadUrl
()))
{
log
.
info
(
"{}该条记录无url:{}"
,
date
,
soundInfo
.
toString
());
System
.
out
.
println
(
soundInfo
.
getBeginTime
());
log
.
info
(
"{}该条记录无url:{}"
,
date
,
soundInfo
.
toString
());
focSmsEmailRecord
.
setDescription
(
"该条记录无url"
+
soundInfo
.
toString
());
focSmsEmailRecord
.
setDescription
(
"该条记录无url"
+
soundInfo
.
toString
());
focSmsEmailRecord
.
setMonitorState
((
short
)
1
);
focSmsEmailRecord
.
setMonitorState
((
short
)
1
);
soundsMaxIdDao
.
insertFocRecord
(
focSmsEmailRecord
);
soundsMaxIdDao
.
insertFocRecord
(
focSmsEmailRecord
);
session
.
commit
();
session
.
commit
();
return
true
;
return
true
;
}
}
}
}
log
.
info
(
"全部成功"
);
log
.
info
(
"全部成功"
);
focSmsEmailRecord
.
setDescription
(
"全部成功"
);
focSmsEmailRecord
.
setDescription
(
"全部成功"
);
focSmsEmailRecord
.
setMonitorState
((
short
)
0
);
focSmsEmailRecord
.
setMonitorState
((
short
)
0
);
soundsMaxIdDao
.
insertFocRecord
(
focSmsEmailRecord
);
soundsMaxIdDao
.
insertFocRecord
(
focSmsEmailRecord
);
session
.
commit
();
session
.
commit
();
return
false
;
return
false
;
}
}
public
static
void
sendEmailAndSms
(
String
aicc
,
String
aicp
,
String
resultCode
,
String
mobile
)
{
public
static
void
sendEmailAndSms
(
String
aicc
,
String
aicp
,
String
resultCode
,
String
mobile
)
{
SoundsMaxIdDao
soundsMaxIdDao
=
session
.
getMapper
(
SoundsMaxIdDao
.
class
);
SoundsMaxIdDao
soundsMaxIdDao
=
session
.
getMapper
(
SoundsMaxIdDao
.
class
);
AccessInfo
accessInfo
=
new
AccessInfo
();
AccessInfo
accessInfo
=
new
AccessInfo
();
accessInfo
.
setAicc
(
aicc
);
accessInfo
.
setAicc
(
aicc
);
...
@@ -128,42 +129,42 @@ public class SoundMonitorService {
...
@@ -128,42 +129,42 @@ public class SoundMonitorService {
FocSmsEmailRecord
focSmsEmailRecord
=
soundsMaxIdDao
.
selectLatestOne
();
FocSmsEmailRecord
focSmsEmailRecord
=
soundsMaxIdDao
.
selectLatestOne
();
Date
currentTime
=
focSmsEmailRecord
.
getCreateTime
();
Date
currentTime
=
focSmsEmailRecord
.
getCreateTime
();
boolean
smsFlag
=
checkSmsFlag
(
focSendSmsRecord
,
currentTime
);
boolean
smsFlag
=
checkSmsFlag
(
focSendSmsRecord
,
currentTime
);
if
(
smsFlag
){
if
(
smsFlag
)
{
//发送短信
//发送短信
String
smsResult
=
Sms
.
sendSms
(
accessInfo
,
mobile
,
"预警:智能首航录音记录显示异常,请处理。"
);
String
smsResult
=
Sms
.
sendSms
(
accessInfo
,
mobile
,
"预警:智能首航录音记录显示异常,请处理。"
);
SmsResult
rootEntity
=
JSON
.
parseObject
(
smsResult
,
SmsResult
.
class
);
SmsResult
rootEntity
=
JSON
.
parseObject
(
smsResult
,
SmsResult
.
class
);
if
(
rootEntity
.
getResult
().
getResultCode
().
equals
(
resultCode
))
{
if
(
rootEntity
.
getResult
().
getResultCode
().
equals
(
resultCode
))
{
log
.
info
(
"短信发送成功,Time:{},result:{}"
,
now
,
smsResult
);
log
.
info
(
"短信发送成功,Time:{},result:{}"
,
now
,
smsResult
);
focSmsEmailRecord
.
setSmsSendTime
(
date
);
focSmsEmailRecord
.
setSmsSendTime
(
date
);
focSmsEmailRecord
.
setSmsSendStatus
((
short
)
1
);
focSmsEmailRecord
.
setSmsSendStatus
((
short
)
1
);
focSmsEmailRecord
.
setSmsErrorLog
(
smsResult
);
focSmsEmailRecord
.
setSmsErrorLog
(
smsResult
);
soundsMaxIdDao
.
updateSms
(
focSmsEmailRecord
);
soundsMaxIdDao
.
updateSms
(
focSmsEmailRecord
);
session
.
commit
();
session
.
commit
();
}
else
{
}
else
{
log
.
info
(
"短信发送失败,Time:{},result:{}"
,
now
,
smsResult
);
log
.
info
(
"短信发送失败,Time:{},result:{}"
,
now
,
smsResult
);
focSmsEmailRecord
.
setSmsSendStatus
((
short
)
0
);
focSmsEmailRecord
.
setSmsSendStatus
((
short
)
0
);
focSmsEmailRecord
.
setSmsErrorLog
(
smsResult
);
focSmsEmailRecord
.
setSmsErrorLog
(
smsResult
);
soundsMaxIdDao
.
updateSms
(
focSmsEmailRecord
);
soundsMaxIdDao
.
updateSms
(
focSmsEmailRecord
);
session
.
commit
();
session
.
commit
();
}
}
}
}
boolean
emailFlag
=
checkEmailFlag
(
focSendEmailRecord
,
currentTime
);
boolean
emailFlag
=
checkEmailFlag
(
focSendEmailRecord
,
currentTime
);
if
(
emailFlag
){
if
(
emailFlag
)
{
//发送邮件
//发送邮件
String
emailResult
=
Email
.
sendEmail
(
"录音记录预警"
,
"智能首航录音记录显示异常,请处理。"
);
String
emailResult
=
Email
.
sendEmail
(
"录音记录预警"
,
"智能首航录音记录显示异常,请处理。"
);
EmailResult
emailResult1
=
JSON
.
parseObject
(
emailResult
,
EmailResult
.
class
);
EmailResult
emailResult1
=
JSON
.
parseObject
(
emailResult
,
EmailResult
.
class
);
if
(
emailResult1
.
getResult
().
getResultCode
().
equals
(
resultCode
)){
if
(
emailResult1
.
getResult
().
getResultCode
().
equals
(
resultCode
))
{
log
.
info
(
"邮件发送成功,Time:{},result:{}"
,
now
,
emailResult
);
log
.
info
(
"邮件发送成功,Time:{},result:{}"
,
now
,
emailResult
);
focSmsEmailRecord
.
setEmailSendTime
(
date
);
focSmsEmailRecord
.
setEmailSendTime
(
date
);
focSmsEmailRecord
.
setEmailSendStatus
((
short
)
1
);
focSmsEmailRecord
.
setEmailSendStatus
((
short
)
1
);
focSmsEmailRecord
.
setEmailErrorLog
(
emailResult
);
focSmsEmailRecord
.
setEmailErrorLog
(
emailResult
);
soundsMaxIdDao
.
updateEmail
(
focSmsEmailRecord
);
soundsMaxIdDao
.
updateEmail
(
focSmsEmailRecord
);
session
.
commit
();
session
.
commit
();
}
else
{
}
else
{
log
.
info
(
"邮件发送失败,Time:{},result:{}"
,
now
,
emailResult
);
log
.
info
(
"邮件发送失败,Time:{},result:{}"
,
now
,
emailResult
);
focSmsEmailRecord
.
setEmailSendStatus
((
short
)
0
);
focSmsEmailRecord
.
setEmailSendStatus
((
short
)
0
);
focSmsEmailRecord
.
setEmailErrorLog
(
emailResult
);
focSmsEmailRecord
.
setEmailErrorLog
(
emailResult
);
soundsMaxIdDao
.
updateEmail
(
focSmsEmailRecord
);
soundsMaxIdDao
.
updateEmail
(
focSmsEmailRecord
);
session
.
commit
();
session
.
commit
();
...
@@ -173,15 +174,15 @@ public class SoundMonitorService {
...
@@ -173,15 +174,15 @@ public class SoundMonitorService {
private
static
boolean
checkEmailFlag
(
FocSmsEmailRecord
focSendEmailRecord
,
Date
currentTime
)
{
private
static
boolean
checkEmailFlag
(
FocSmsEmailRecord
focSendEmailRecord
,
Date
currentTime
)
{
Date
emailSendTime
=
focSendEmailRecord
.
getEmailSendTime
();
Date
emailSendTime
=
focSendEmailRecord
.
getEmailSendTime
();
if
(
emailSendTime
==
null
){
if
(
emailSendTime
==
null
)
{
return
true
;
return
true
;
}
else
{
}
else
{
//判断是否超过了一小时
//判断是否超过了一小时
long
emailSecond
=
(
currentTime
.
getTime
()
-
emailSendTime
.
getTime
())/
1000
;
long
emailSecond
=
(
currentTime
.
getTime
()
-
emailSendTime
.
getTime
())
/
1000
;
log
.
info
(
"邮件距上次发送已经过了{}秒"
,
emailSecond
);
log
.
info
(
"邮件距上次发送已经过了{}秒"
,
emailSecond
);
if
(
emailSecond
/
3600
>=
1
)
{
if
(
emailSecond
/
3600
>=
1
)
{
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
}
}
}
}
...
@@ -189,15 +190,15 @@ public class SoundMonitorService {
...
@@ -189,15 +190,15 @@ public class SoundMonitorService {
private
static
boolean
checkSmsFlag
(
FocSmsEmailRecord
focSendSmsRecord
,
Date
currentTime
)
{
private
static
boolean
checkSmsFlag
(
FocSmsEmailRecord
focSendSmsRecord
,
Date
currentTime
)
{
Date
smsSendTime
=
focSendSmsRecord
.
getSmsSendTime
();
Date
smsSendTime
=
focSendSmsRecord
.
getSmsSendTime
();
if
(
smsSendTime
==
null
){
if
(
smsSendTime
==
null
)
{
return
true
;
return
true
;
}
else
{
}
else
{
//判断是否超过了一小时
//判断是否超过了一小时
long
second
=
(
currentTime
.
getTime
()
-
smsSendTime
.
getTime
())
/
1000
;
long
second
=
(
currentTime
.
getTime
()
-
smsSendTime
.
getTime
())
/
1000
;
log
.
info
(
"短信距上次发送已经过了{}秒"
,
second
);
log
.
info
(
"短信距上次发送已经过了{}秒"
,
second
);
if
(
second
/
3600
>=
1
)
{
if
(
second
/
3600
>=
1
)
{
return
true
;
return
true
;
}
else
{
}
else
{
return
false
;
return
false
;
}
}
}
}
...
...
src/main/resources/mapper/SoundsMaxIdMapper.xml
View file @
95690c91
...
@@ -28,11 +28,7 @@
...
@@ -28,11 +28,7 @@
LEFT JOIN foc_sound_phones ap ON ac.id = ap.record_id
LEFT JOIN foc_sound_phones ap ON ac.id = ap.record_id
WHERE
WHERE
ac.end_status = 'SUCCESS'
ac.end_status = 'SUCCESS'
AND ac.start_time
<
= #{date}
AND ac.start_time
>
= #{date}
AND (
ac.end_time
<
#{date}
OR ac.end_time IS NULL
)
ORDER BY
ORDER BY
beginTime DESC
beginTime DESC
LIMIT 20
LIMIT 20
...
...
src/main/resources/mybatis-config.xml
View file @
95690c91
...
@@ -47,22 +47,12 @@
...
@@ -47,22 +47,12 @@
<dataSource
type=
"POOLED"
>
<dataSource
type=
"POOLED"
>
<property
name=
"driver"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"driver"
value=
"com.mysql.jdbc.Driver"
/>
<property
name=
"url"
value=
"jdbc:mysql://106.75.97.50:3306/jd_foc?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8"
/>
<property
name=
"url"
value=
"jdbc:mysql://106.75.97.50:3306/jd_foc?serverTimezone=CTT&useUnicode=true&characterEncoding=utf-8"
/>
<!--<property name="url" value="jdbc:mysql://mysql_server:3306/foc?
useUnicode=true&characterEncoding=utf-8"/>-->
<!-- <property name="url" value="jdbc:mysql://mysql_server:3306/foc?serverTimezone=CTT&
useUnicode=true&characterEncoding=utf-8"/>-->
<property
name=
"username"
value=
"focuser"
/>
<property
name=
"username"
value=
"focuser"
/>
<property
name=
"password"
value=
"FOC@2016"
/>
<property
name=
"password"
value=
"FOC@2016"
/>
</dataSource>
</dataSource>
</environment>
</environment>
<!--<environment id="prod">-->
<!--<transactionManager type="JDBC"/>-->
<!--<!– 配置数据库连接信息 –>-->
<!--<dataSource type="POOLED">-->
<!--<property name="driver" value="com.mysql.jdbc.Driver"/>-->
<!--<property name="url" value="jdbc:mysql://sms.db.com:3306/sms"/>-->
<!--<property name="username" value="sms_develop"/>-->
<!--<property name="password" value="Develop2018!@#"/>-->
<!--</dataSource>-->
<!--</environment>-->
</environments>
</environments>
...
...
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