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
300885c3
Commit
300885c3
authored
Sep 25, 2019
by
zt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
50e73237
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
125 additions
and
11 deletions
+125
-11
DbCheckBlackIpTask.java
src/main/java/com/foc/DbCheckBlackIpTask.java
+28
-0
BlackIpDao.java
src/main/java/com/foc/dao/BlackIpDao.java
+26
-0
CheckBlackIpService.java
src/main/java/com/foc/service/CheckBlackIpService.java
+57
-0
SoundMonitorService.java
src/main/java/com/foc/service/SoundMonitorService.java
+1
-11
BlackIpMapper.xml
src/main/resources/mapper/BlackIpMapper.xml
+13
-0
No files found.
src/main/java/com/foc/DbCheckBlackIpTask.java
0 → 100644
View file @
300885c3
package
com
.
foc
;
import
com.foc.service.CheckBlackIpService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
/**
* @Author: lisu
* @Date: 2019/4/29 15:35
* @Description: 安科录音同步任务及数据源监控
* 1.查看定时任务最后同步时间
* 2.查看是否有录音文件记录
* 3.查看安科数据库最后一条数据
*/
public
class
DbCheckBlackIpTask
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
DbCheckBlackIpTask
.
class
);
public
static
void
main
(
String
[]
args
)
{
CheckBlackIpService
.
init
();
CheckBlackIpService
.
checkBlackIp
();
log
.
info
(
"检查黑名单结束"
);
}
}
src/main/java/com/foc/dao/BlackIpDao.java
0 → 100644
View file @
300885c3
package
com
.
foc
.
dao
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* @Author: lisu
* @Date: 2019/4/29 16:23
* @Description: java类作用描述
*/
public
interface
BlackIpDao
{
/**
* 查询IP锁列表
*
* @return
*/
List
<
String
>
getBlackIpList
();
/**
* 删除ip锁
*
* @param blackIp
*/
void
deleteBlackIp
(
@Param
(
"blackIp"
)
String
blackIp
);
}
src/main/java/com/foc/service/CheckBlackIpService.java
0 → 100644
View file @
300885c3
package
com
.
foc
.
service
;
import
com.foc.dao.BlackIpDao
;
import
com.foc.dao.SoundsMaxIdDao
;
import
org.apache.ibatis.io.Resources
;
import
org.apache.ibatis.session.SqlSession
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.session.SqlSessionFactoryBuilder
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.util.CollectionUtils
;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.util.List
;
/**
* @author zangtao
* @create 2019 - 09 -25 18:10
*/
public
class
CheckBlackIpService
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
CheckBlackIpService
.
class
);
private
static
Reader
reader
;
private
static
SqlSessionFactory
sqlSessionFactory
;
private
static
SqlSession
session
;
public
static
void
init
()
{
try
{
reader
=
Resources
.
getResourceAsReader
(
"mybatis-config.xml"
);
sqlSessionFactory
=
new
SqlSessionFactoryBuilder
().
build
(
reader
);
session
=
sqlSessionFactory
.
openSession
();
}
catch
(
IOException
e
)
{
log
.
error
(
"连接数据库异常"
);
e
.
printStackTrace
();
}
}
public
static
void
checkBlackIp
()
{
//检查ip锁数据库
BlackIpDao
blackIpDao
=
session
.
getMapper
(
BlackIpDao
.
class
);
List
<
String
>
blackIpList
=
blackIpDao
.
getBlackIpList
();
if
(!
CollectionUtils
.
isEmpty
(
blackIpList
)){
blackIpList
.
forEach
(
(
blackIp
)
->{
blackIpDao
.
deleteBlackIp
(
blackIp
);
log
.
info
(
"删除的ip地址有:{}"
,
blackIp
);
});
session
.
commit
();
}
}
}
src/main/java/com/foc/service/SoundMonitorService.java
View file @
300885c3
...
...
@@ -15,7 +15,6 @@ import org.slf4j.LoggerFactory;
import
java.io.IOException
;
import
java.io.Reader
;
import
java.text.SimpleDateFormat
;
import
java.time.Instant
;
import
java.time.LocalDateTime
;
import
java.time.format.DateTimeFormatter
;
...
...
@@ -58,17 +57,9 @@ public class SoundMonitorService {
*/
public
static
boolean
test
()
{
Properties
properties
=
PropertiesUtils
.
getProperties
();
//间隔时间
String
interval
=
properties
.
getProperty
(
"interval"
);
SoundsMaxIdDao
soundsMaxIdDao
=
session
.
getMapper
(
SoundsMaxIdDao
.
class
);
//检查ip锁数据库
List
<
String
>
blackIpList
=
soundsMaxIdDao
.
getBlackIpList
();
if
(
blackIpList
!=
null
){
blackIpList
.
forEach
(
(
blackIp
)
->{
soundsMaxIdDao
.
deleteBlackIp
(
blackIp
);
log
.
info
(
"删除的ip地址有:{}"
,
blackIp
);
session
.
commit
();
});
}
SoundsMaxId
maxId
=
soundsMaxIdDao
.
getMaxId
();
String
updateTime
=
maxId
.
getUpdateDate
();
Date
date
=
new
Date
();
...
...
@@ -122,7 +113,6 @@ public class SoundMonitorService {
//当前时间
Instant
now
=
Instant
.
now
().
plusMillis
(
TimeUnit
.
HOURS
.
toMillis
(
8
));
Date
date
=
new
Date
();
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
//判断是否要发送短信 间隔一小时
FocSmsEmailRecord
focSendSmsRecord
=
soundsMaxIdDao
.
selectFocSendSmsRecord
();
FocSmsEmailRecord
focSendEmailRecord
=
soundsMaxIdDao
.
selectFocSendEmailRecord
();
...
...
src/main/resources/mapper/BlackIpMapper.xml
0 → 100644
View file @
300885c3
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.foc.dao.BlackIpDao"
>
<select
id=
"getBlackIpList"
resultType=
"string"
>
select black_ip from sys_login_blacklist where black_ip like '10.%'
</select>
<delete
id=
"deleteBlackIp"
>
delete from sys_login_blacklist where black_ip = #{blackIp}
</delete>
</mapper>
\ 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