Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hzjtpushService
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
wangjinjing
hzjtpushService
Commits
a29ac058
Commit
a29ac058
authored
Apr 25, 2024
by
wangjinjing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
浅黄发布版本
parent
f03f4acb
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
385 additions
and
527 deletions
+385
-527
src/main/java/com/hzjt/config/ScheduleTaskConfig.java
src/main/java/com/hzjt/config/ScheduleTaskConfig.java
+38
-28
src/main/java/com/hzjt/controller/AlarmController.java
src/main/java/com/hzjt/controller/AlarmController.java
+11
-16
src/main/java/com/hzjt/controller/EventWriteController.java
src/main/java/com/hzjt/controller/EventWriteController.java
+28
-19
src/main/java/com/hzjt/controller/RouterController.java
src/main/java/com/hzjt/controller/RouterController.java
+9
-17
src/main/java/com/hzjt/controller/TraffController.java
src/main/java/com/hzjt/controller/TraffController.java
+33
-97
src/main/java/com/hzjt/controller/TraffdevicewriteresultController.java
...com/hzjt/controller/TraffdevicewriteresultController.java
+11
-12
src/main/java/com/hzjt/domain/TransferResult.java
src/main/java/com/hzjt/domain/TransferResult.java
+16
-16
src/main/java/com/hzjt/handler/FileTransferManager.java
src/main/java/com/hzjt/handler/FileTransferManager.java
+147
-162
src/main/java/com/hzjt/mapper/TraffAlarmRecordMapper.java
src/main/java/com/hzjt/mapper/TraffAlarmRecordMapper.java
+5
-0
src/main/java/com/hzjt/redis/Receiver.java
src/main/java/com/hzjt/redis/Receiver.java
+45
-126
src/main/java/com/hzjt/service/TraffalarmrecordService.java
src/main/java/com/hzjt/service/TraffalarmrecordService.java
+3
-1
src/main/java/com/hzjt/util/FTPUtil.java
src/main/java/com/hzjt/util/FTPUtil.java
+33
-33
src/main/resources/mapper/Traffalarmrecord.xml
src/main/resources/mapper/Traffalarmrecord.xml
+6
-0
No files found.
src/main/java/com/hzjt/config/ScheduleTaskConfig.java
View file @
a29ac058
package
com
.
hzjt
.
config
;
import
cn.hutool.json.JSONUtil
;
import
com.hzjt.domain.*
;
import
com.hzjt.handler.FileTransferManager
;
import
com.hzjt.handler.WebSocket
;
import
com.hzjt.mapper.SbtdspsrMapper
;
import
com.hzjt.mapper.TraffAlarmRecordMapper
;
import
com.hzjt.service.FtpService
;
import
com.hzjt.service.TraffFlowService
;
import
com.hzjt.service.TraffalarmrecordService
;
import
com.hzjt.util.DateUtils
;
import
com.hzjt.util.JsonUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
...
...
@@ -20,13 +26,16 @@ import org.springframework.web.client.RestTemplate;
import
javax.annotation.Resource
;
import
java.net.URI
;
import
java.util.Calendar
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.TimeUnit
;
@Slf4j
//
@Configuration
@Configuration
@EnableScheduling
public
class
ScheduleTaskConfig
{
@Autowired
...
...
@@ -36,40 +45,41 @@ public class ScheduleTaskConfig {
TraffalarmrecordService
traffalarmrecordService
;
@Autowired
private
RestTemplate
restTemplate
;
@Autowired
FtpService
ftpService
;
// @Scheduled(cron = "0 */1 * * * ?")//每天凌晨2点执行
private
void
statis
()
{
// //取帧
// HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
// RTSPFrame result = restTemplate.getForObject(rtspformUrl, RTSPFrame.class);
// if(result.getRet()==0)
// {
// //获取成功
//
// result.getUrl();
//
//
//
// }
//查询监控是否存在
//查询rtsp 多线程进行图片抽取,并记录表中,ftp 上传到服务器,路径返回表中
@Resource
TraffAlarmRecordMapper
traffAlarmRecordMapper
;
@Scheduled
(
cron
=
"0 0/50 * * * ?"
)
//间隔50分钟
private
void
statis
()
{
// 查询30分钟之前的所有没有上传成功的事件进行二次上传
List
<
Traffalarmrecord
>
list
=
traffalarmrecordService
.
selectFailRecord
();
if
(
list
.
size
()>
0
)
{
Ftp
ftp
=
this
.
ftpService
.
reloadFtp
();
for
(
Traffalarmrecord
traffAlarmRecord
:
list
)
{
String
basepath
=
traffAlarmRecord
.
getFdid
()
+
(
traffAlarmRecord
.
getChannelid
()
<
10
?
"0"
+
traffAlarmRecord
.
getChannelid
()
:
traffAlarmRecord
.
getChannelid
())
+
"/"
+
DateUtils
.
formatCurrDayNoSign
();
Map
<
String
,
Object
>
transferRecordMap
=
new
HashMap
();
FileTransferManager
.
fetchUrlsFromRecord
(
traffAlarmRecord
,
transferRecordMap
);
FileTransferManager
fileTransferManager
=
new
FileTransferManager
();
try
{
fileTransferManager
.
transferFile
(
transferRecordMap
,
ftp
,
basepath
,
this
.
traffAlarmRecordMapper
);
}
catch
(
Exception
e
)
{
log
.
error
(
"alarmevent error :{}"
,
e
.
toString
());
}
traffAlarmRecord
.
setPushdesc
(
"success"
);
traffAlarmRecord
.
setPushstatus
(
0
);
this
.
traffAlarmRecordMapper
.
updatePushEvent
(
traffAlarmRecord
);
}
}
}
// @Scheduled(cron = "0 */1 * * * ?")//每一个月执行一次
// @Scheduled(cron = "0 */1 * * * ?")//每一个月执行一次
private
void
reconnectWebsocket
()
{
final
Calendar
c
=
Calendar
.
getInstance
();
...
...
src/main/java/com/hzjt/controller/AlarmController.java
View file @
a29ac058
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package
com
.
hzjt
.
controller
;
...
...
@@ -10,7 +14,6 @@ import com.hzjt.domain.ResponseEnum;
import
com.hzjt.domain.Result
;
import
com.hzjt.domain.Sbtdspsr
;
import
com.hzjt.domain.Traffalarmrecord
;
import
com.hzjt.domain.TransferResult
;
import
com.hzjt.handler.FileTransferManager
;
import
com.hzjt.handler.WebSocket
;
import
com.hzjt.mapper.SbtdspsrMapper
;
...
...
@@ -27,6 +30,7 @@ import java.util.HashMap;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
javax.annotation.Resource
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -35,8 +39,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
javax.annotation.Resource
;
@RestController
public
class
AlarmController
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
TraffController
.
class
);
...
...
@@ -51,8 +53,7 @@ public class AlarmController {
@Resource
SbtdspsrMapper
sbtdspsrMapper
;
public
AlarmController
(
)
{
public
AlarmController
()
{
}
@PostMapping
({
"/sendAlarmEvents"
})
...
...
@@ -110,34 +111,28 @@ public class AlarmController {
map
.
put
(
"type"
,
"alarm"
);
traffAlarmRecord_init
.
setEventid
(
"66211"
+
UUIDUtils
.
createuuid
());
this
.
traffAlarmRecordMapper
.
inserTraffAlarmRecord
(
traffAlarmRecord_init
);
map
.
put
(
"data"
,
alarm
);
map
.
put
(
"recordid"
,
traffAlarmRecord_init
.
getRecordid
());
this
.
webSocket
.
GroupSending
(
JsonUtil
.
beanToString
(
map
));
try
{
Traffalarmrecord
traffAlarmRecord
=
JSONUtil
.
toBean
(
JsonUtil
.
beanToString
(
traffAlarmRecord_init
),
Traffalarmrecord
.
class
);
Traffalarmrecord
traffAlarmRecord
=
(
Traffalarmrecord
)
JSONUtil
.
toBean
(
JsonUtil
.
beanToString
(
traffAlarmRecord_init
),
Traffalarmrecord
.
class
);
String
basepath
=
traffAlarmRecord
.
getFdid
()
+
(
traffAlarmRecord
.
getChannelid
()
<
10
?
"0"
+
traffAlarmRecord
.
getChannelid
()
:
traffAlarmRecord
.
getChannelid
())
+
"/"
+
DateUtils
.
formatCurrDayNoSign
();
Map
<
String
,
Object
>
transferRecordMap
=
new
HashMap
();
FileTransferManager
.
fetchUrlsFromRecord
(
traffAlarmRecord
,
transferRecordMap
);
Ftp
ftp
=
this
.
ftpService
.
reloadFtp
();
List
<
TransferResult
>
results
=
FileTransferManager
.
transferFileIncludVideo
(
transferRecordMap
,
ftp
,
basepath
);
FileTransferManager
fileTransferManager
=
new
FileTransferManager
();
fileTransferManager
.
traffAlarmRecordUrlUpdate
(
results
,
traffAlarmRecordMapper
);
log
.
info
(
"traffAlarmRecord=={}"
,
traffAlarmRecord
.
getRecordid
());
// this.traffAlarmRecordMapper.updateTraffAlarmRecordUrl(recordBak);
FileTransferManager
fileTransferManager
=
new
FileTransferManager
();
fileTransferManager
.
transferFileIncludVideo
(
transferRecordMap
,
ftp
,
basepath
,
this
.
traffAlarmRecordMapper
);
traffAlarmRecord
.
setPushdesc
(
"success"
);
traffAlarmRecord
.
setPushstatus
(
0
);
this
.
traffAlarmRecordMapper
.
updatePushEvent
(
traffAlarmRecord
);
result
.
setSuccess
(
true
);
}
catch
(
Exception
var1
8
)
{
}
catch
(
Exception
var1
9
)
{
result
.
setSuccess
(
false
);
log
.
error
(
"alarmevent error :{}"
,
var1
8
.
toString
());
log
.
error
(
"alarmevent error :{}"
,
var1
9
.
toString
());
}
return
result
;
}
}
}
src/main/java/com/hzjt/controller/EventWriteController.java
View file @
a29ac058
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package
com
.
hzjt
.
controller
;
import
com.hzjt.domain.ResultObj
;
import
com.hzjt.domain.Traffalarmrecord
;
import
com.hzjt.domain.WriteResultObj
;
import
com.hzjt.service.EventWriteService
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.ArrayList
;
import
java.util.List
;
@RestController
public
class
EventWriteController
{
@Autowired
private
EventWriteService
eventWriteService
;
public
EventWriteController
()
{
}
@PostMapping
(
"/sendEvent"
)
public
ResultObj
sendEvent
(
Long
recordid
){
return
eventWriteService
.
sendEvent
(
recordid
);
@PostMapping
(
{
"/sendEvent"
}
)
public
ResultObj
sendEvent
(
Long
recordid
)
{
return
this
.
eventWriteService
.
sendEvent
(
recordid
);
}
@PostMapping
(
"/sendEvents"
)
public
List
<
WriteResultObj
>
sendEvents
(
@RequestParam
(
"recordid"
)
String
recordid
){
List
<
Long
>
longrecorid
=
new
ArrayList
<>();
for
(
String
id:
recordid
.
split
(
","
))
{
@PostMapping
({
"/sendEvents"
})
public
List
<
WriteResultObj
>
sendEvents
(
@RequestParam
(
"recordid"
)
String
recordid
)
{
List
<
Long
>
longrecorid
=
new
ArrayList
();
String
[]
var3
=
recordid
.
split
(
","
);
int
var4
=
var3
.
length
;
for
(
int
var5
=
0
;
var5
<
var4
;
++
var5
)
{
String
id
=
var3
[
var5
];
longrecorid
.
add
(
Long
.
valueOf
(
id
));
}
return
eventWriteService
.
sendEvents
(
longrecorid
);
return
this
.
eventWriteService
.
sendEvents
(
longrecorid
);
}
@GetMapping
(
"/sendEventsByids"
)
public
List
<
WriteResultObj
>
sendEventsByids
(){
List
<
Long
>
recordid
=
new
ArrayList
<>
();
recordid
.
add
(
Long
.
valueOf
(
93228
)
);
recordid
.
add
(
Long
.
valueOf
(
93834
)
);
return
eventWriteService
.
sendEvents
(
recordid
);
@GetMapping
(
{
"/sendEventsByids"
}
)
public
List
<
WriteResultObj
>
sendEventsByids
()
{
List
<
Long
>
recordid
=
new
ArrayList
();
recordid
.
add
(
93228L
);
recordid
.
add
(
93834L
);
return
this
.
eventWriteService
.
sendEvents
(
recordid
);
}
}
src/main/java/com/hzjt/controller/RouterController.java
View file @
a29ac058
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package
com
.
hzjt
.
controller
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.StringRedisTemplate
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.
*
;
import
org.springframework.web.bind.annotation.
GetMapping
;
/**
* 路由接口控制器
*
* @author tycoding
* @date 2019-06-13
*/
@Controller
public
class
RouterController
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
TraffController
.
class
);
@Autowired
private
StringRedisTemplate
redisTemplate
;
public
RouterController
()
{
}
/**
* 登陆页面
*
* @return
*/
@GetMapping
(
"/"
)
@GetMapping
({
"/"
})
public
String
index
()
{
return
"login"
;
}
}
src/main/java/com/hzjt/controller/TraffController.java
View file @
a29ac058
This diff is collapsed.
Click to expand it.
src/main/java/com/hzjt/controller/TraffdevicewriteresultController.java
View file @
a29ac058
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package
com
.
hzjt
.
controller
;
import
com.hzjt.domain.ResultObj
;
import
com.hzjt.service.TraffdevicewriteresultService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
java.lang.reflect.Array
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
@RestController
@RequestMapping
(
"/traffdevicewriteresult"
)
@RequestMapping
(
{
"/traffdevicewriteresult"
}
)
public
class
TraffdevicewriteresultController
{
@Autowired
private
TraffdevicewriteresultService
traffdevicewriteresultService
;
}
\ No newline at end of file
public
TraffdevicewriteresultController
()
{
}
}
src/main/java/com/hzjt/domain/TransferResult.java
View file @
a29ac058
package
com
.
hzjt
.
domain
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//
package
com
.
hzjt
.
domain
;
public
class
TransferResult
{
Long
recordid
;
String
pathvalue
;
String
urlfrom
;
String
imgpath
;
Long
recordid
;
String
pathvalue
;
String
urlfrom
;
String
imgpath
;
String
filename
;
Boolean
result
;
...
...
@@ -34,7 +34,7 @@ public class TransferResult {
}
public
String
getFilename
()
{
return
filename
;
return
this
.
filename
;
}
public
void
setFilename
(
String
filename
)
{
...
...
@@ -42,7 +42,7 @@ public class TransferResult {
}
public
Long
getRecordid
()
{
return
recordid
;
return
this
.
recordid
;
}
public
void
setRecordid
(
Long
recordid
)
{
...
...
@@ -50,7 +50,7 @@ public class TransferResult {
}
public
String
getPathvalue
()
{
return
pathvalue
;
return
this
.
pathvalue
;
}
public
void
setPathvalue
(
String
pathvalue
)
{
...
...
@@ -58,7 +58,7 @@ public class TransferResult {
}
public
String
getUrlfrom
()
{
return
urlfrom
;
return
this
.
urlfrom
;
}
public
void
setUrlfrom
(
String
urlfrom
)
{
...
...
@@ -66,7 +66,7 @@ public class TransferResult {
}
public
String
getImgpath
()
{
return
imgpath
;
return
this
.
imgpath
;
}
public
void
setImgpath
(
String
imgpath
)
{
...
...
@@ -74,10 +74,10 @@ public class TransferResult {
}
public
Boolean
getResult
()
{
return
result
;
return
this
.
result
;
}
public
void
setResult
(
Boolean
result
)
{
this
.
result
=
result
;
}
}
\ No newline at end of file
}
src/main/java/com/hzjt/handler/FileTransferManager.java
View file @
a29ac058
This diff is collapsed.
Click to expand it.
src/main/java/com/hzjt/mapper/TraffAlarmRecordMapper.java
View file @
a29ac058
...
...
@@ -8,6 +8,8 @@ import tk.mybatis.mapper.additional.dialect.oracle.InsertListMapper;
import
tk.mybatis.mapper.common.BaseMapper
;
import
tk.mybatis.mapper.common.ConditionMapper
;
import
java.util.List
;
@Mapper
public
interface
TraffAlarmRecordMapper
extends
BaseMapper
<
Traffalarmrecord
>,
ConditionMapper
<
Traffalarmrecord
>,
InsertListMapper
<
Traffalarmrecord
>
{
...
...
@@ -35,4 +37,7 @@ public interface TraffAlarmRecordMapper extends BaseMapper<Traffalarmrecord>, Co
String
seletmqttbh
(
@Param
(
"recordtype"
)
String
recordtype
);
Integer
updateState
(
MqttResult
result
);
List
<
Traffalarmrecord
>
selectFailRecord
();
}
\ No newline at end of file
src/main/java/com/hzjt/redis/Receiver.java
View file @
a29ac058
This diff is collapsed.
Click to expand it.
src/main/java/com/hzjt/service/TraffalarmrecordService.java
View file @
a29ac058
...
...
@@ -22,5 +22,7 @@ public class TraffalarmrecordService {
public
Integer
updateState
(
MqttResult
result
)
{
return
traffalarmrecordMapper
.
updateState
(
result
);
}
public
List
<
Traffalarmrecord
>
selectFailRecord
()
{
return
traffalarmrecordMapper
.
selectFailRecord
();
}
}
\ No newline at end of file
src/main/java/com/hzjt/util/FTPUtil.java
View file @
a29ac058
...
...
@@ -33,8 +33,8 @@ public class FTPUtil {
@PostConstruct
private
void
initHostMap
(){
if
(
ftpHost
==
null
){
log
.
error
(
"ftp
存储组未配置,请先配置
"
);
log
.
error
(
"ftp
存储组未配置,请先配置
"
);
log
.
error
(
"ftp
�洢��δ���ã���������"
);
log
.
error
(
"ftp
�洢��δ���ã���������"
);
return
;
}
...
...
@@ -57,7 +57,7 @@ public class FTPUtil {
return
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"FTP
下载图片出错
"
,
e
);
log
.
error
(
"FTP
����ͼƬ����"
,
e
);
}
finally
{
IOUtils
.
closeQuietly
(
toClient
);
IOUtils
.
closeQuietly
(
is
);
...
...
@@ -70,7 +70,7 @@ public class FTPUtil {
try
{
url
=
new
URL
(
path
);
}
catch
(
MalformedURLException
e
)
{
log
.
error
(
"FTP URL路
径错误
"
+
e
.
toString
());
log
.
error
(
"FTP URL·
������"
+
e
.
toString
());
}
byte
[]
buffer
=
null
;
try
(
InputStream
is
=
url
.
openStream
();
ByteArrayOutputStream
bos
=
new
ByteArrayOutputStream
(
1000
)){
...
...
@@ -82,13 +82,13 @@ public class FTPUtil {
buffer
=
bos
.
toByteArray
();
}
catch
(
Exception
e
)
{
log
.
error
(
"FTP
下载图片出错
"
,
e
);
log
.
error
(
"FTP
����ͼƬ����"
,
e
);
}
return
buffer
;
}
//ftp图片
上传,图片参数为base64封装的
String
//ftpͼƬ
�ϴ���ͼƬ����Ϊbase64��װ��String
public
static
boolean
uploadFile
(
Ftp
ftpUrl
,
String
path
,
String
filename
,
String
inputImg
)
{
boolean
flag
=
true
;
FTPClient
ftpClient
=
null
;
...
...
@@ -97,7 +97,7 @@ public class FTPUtil {
if
(
inputImg
==
null
)
{
return
false
;
}
//base64
解码
//base64
����
BASE64Decoder
decoder
=
new
BASE64Decoder
();
byte
[]
b_img
=
decoder
.
decodeBuffer
(
inputImg
);
input
=
new
ByteArrayInputStream
(
b_img
);
...
...
@@ -107,15 +107,15 @@ public class FTPUtil {
changeWorkingDirectory
(
ftpClient
,
path
);
flag
=
ftpClient
.
storeFile
(
filename
,
input
);
if
(
flag
)
{
// log.info("FTP
上传文件成功!
");
// log.info("FTP
�ϴ��ļ��ɹ���");
}
else
{
flag
=
false
;
log
.
info
(
"FTP
上传文件失败!
"
);
log
.
info
(
"FTP
�ϴ��ļ�ʧ�ܣ�"
);
}
}
}
catch
(
Exception
e
)
{
flag
=
false
;
log
.
error
(
"FTP
文件上传失败!
"
,
e
.
toString
());
log
.
error
(
"FTP
�ļ��ϴ�ʧ�ܣ�"
,
e
.
toString
());
}
finally
{
IOUtils
.
closeQuietly
(
input
);
closeConnect
(
ftpClient
);
...
...
@@ -132,20 +132,20 @@ public class FTPUtil {
changeWorkingDirectory
(
ftpClient
,
path
);
flag
=
ftpClient
.
storeFile
(
filename
,
input
);
if
(
flag
)
{
// log.info("FTP upload success
!
");
// log.info("FTP upload success
��"
);
}
else
{
log
.
info
(
"FTP upload fail
!
"
);
log
.
info
(
"FTP upload fail"
);
}
}
else
{
flag
=
false
;
// log.info("FTP server refused connection
!
");
// log.info("FTP server refused connection
��"
);
}
}
catch
(
IOException
e
)
{
flag
=
false
;
log
.
error
(
"FTP upload fail
!
"
,
e
);
log
.
error
(
"FTP upload fail
��"
,
e
);
}
catch
(
Exception
e
)
{
flag
=
false
;
log
.
error
(
"FTP upload fail
!
"
,
e
);
log
.
error
(
"FTP upload fail
��"
,
e
);
}
finally
{
IOUtils
.
closeQuietly
(
input
);
closeConnect
(
ftpClient
);
...
...
@@ -154,7 +154,7 @@ public class FTPUtil {
}
/*
*
得到配置文件中的FTP服务器地
址
*
�õ������ļ��е�FTP��������ַ
*/
public
static
String
getFtpUrl
(
Ftp
ftpUrl
)
{
StringBuffer
buffer
=
new
StringBuffer
();
...
...
@@ -179,13 +179,13 @@ public class FTPUtil {
* @param ftpUrl
* @return
* @throws Exception
* @description 删
除ftp上的文件
* @description ɾ
��ftp�ϵ��ļ�
* @author sunw
*/
public
static
boolean
deleteFileFromFtpUrl
(
String
ftpUrl
)
throws
Exception
{
boolean
flag
=
false
;
if
(
null
==
ftpUrl
||
StringUtils
.
isBlank
(
ftpUrl
))
{
throw
new
Exception
(
"ftpUrl
串为空
"
);
throw
new
Exception
(
"ftpUrl
����"
)
;
}
Map
<
String
,
String
>
result
=
getFtpInfoMapByFullPath
(
ftpUrl
);
String
ftpUser
=
result
.
get
(
"ftpUser"
);
...
...
@@ -197,7 +197,7 @@ public class FTPUtil {
Ftp
ftp
=
FTPUtil
.
getFtpUrlObj
(
ftpIp
,
ftpPort
,
ftpUser
,
ftpPassword
);
FTPClient
ftpClient
=
connectServer
(
ftp
);
if
(
null
==
ftpClient
)
{
throw
new
Exception
(
"ftp
登录失败
"
);
throw
new
Exception
(
"ftp
��¼ʧ�� "
);
}
else
{
String
fullPath
=
(
null
==
path
||
""
.
equals
(
path
.
trim
()))
?
fileName
:
(
path
+
"/"
+
fileName
);
try
{
...
...
@@ -215,12 +215,12 @@ public class FTPUtil {
* @param ftpUrlStr
* @return
* @throws Exception
* @author sunw 通
过图片路径
*
获得ftpuser,ftppassword,ftpip,ftpport,在fpt上的文件路径,文件
realname
* @author sunw ͨ
��ͼƬ·��
*
���ftpuser,ftppassword,ftpip,ftpport,��fpt�ϵ��ļ�·��,�ļ�realna
me
*/
private
static
Map
<
String
,
String
>
getFtpInfoMapByFullPath
(
String
ftpUrlStr
)
throws
Exception
{
if
(
null
==
ftpUrlStr
||
""
.
equals
(
ftpUrlStr
.
trim
()))
{
throw
new
Exception
(
"ftpstr
串为空
"
);
throw
new
Exception
(
"ftpstr
����"
)
;
}
ftpUrlStr
=
ftpUrlStr
.
replaceAll
(
"\\\\"
,
"/"
);
ftpUrlStr
=
changeUrlCharater
(
ftpUrlStr
);
...
...
@@ -232,7 +232,7 @@ public class FTPUtil {
String
ftpPassword
=
ftpUserAndPassword
[
1
];
String
ftpIp
=
ftpIpAndPort
[
0
];
String
ftpPort
=
ftpIpAndPort
.
length
>
1
?
ftpIpAndPort
[
1
]
:
""
;
String
fileName
=
array
[
array
.
length
-
1
];
//
获得文件名
String
fileName
=
array
[
array
.
length
-
1
];
//
������
Map
<
String
,
String
>
resultMap
=
new
HashMap
<
String
,
String
>();
resultMap
.
put
(
"ftpUser"
,
ftpUser
);
resultMap
.
put
(
"ftpPassword"
,
ftpPassword
);
...
...
@@ -257,7 +257,7 @@ public class FTPUtil {
boolean
flag
=
deleteFileFromFtpUrl
(
temp
);
System
.
out
.
println
(
flag
);
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"删
除文件失败
"
);
System
.
out
.
println
(
"ɾ
���ļ�ʧ��"
);
}
// String [] strSplit = temp.split("/");
// for(int i = 0 ; i < strSplit.length ; i++) {
...
...
@@ -272,7 +272,7 @@ public class FTPUtil {
}
/**
*
连接到服务器
*
���ӵ�������
*/
private
static
FTPClient
connectServer
(
Ftp
ftpUrl
)
{
FTPClient
ftpClient
=
null
;
...
...
@@ -292,18 +292,18 @@ public class FTPUtil {
if
(!
FTPReply
.
isPositiveCompletion
(
reply
))
{
ftpClient
.
disconnect
();
System
.
err
.
println
(
"FTP server refused connection."
);
log
.
info
(
"FTP
服务拒绝连接!
"
);
log
.
info
(
"FTP
����ܾ����ӣ�"
);
}
}
catch
(
SocketException
e
)
{
log
.
error
(
"
登录ftp服务器 "
+
ftpUrl
.
getFtpIp
()
+
" 失败,连接超时!
"
,
e
);
log
.
error
(
"
��¼ftp������ "
+
ftpUrl
.
getFtpIp
()
+
" ʧ��,���ӳ�ʱ��"
,
e
);
}
catch
(
IOException
e
)
{
log
.
error
(
"
登录ftp服务器 "
+
ftpUrl
.
getFtpIp
()
+
" 失败,FTP服务器无法打开!
"
,
e
);
log
.
error
(
"
��¼ftp������ "
+
ftpUrl
.
getFtpIp
()
+
" ʧ�ܣ�FTP����������"
,
e
);
}
return
ftpClient
;
}
/**
*
关闭连接
*
�ر�����
*/
private
static
void
closeConnect
(
FTPClient
ftpClient
)
{
try
{
...
...
@@ -314,12 +314,12 @@ public class FTPUtil {
ftpClient
.
disconnect
();
}
}
catch
(
Exception
e
)
{
log
.
error
(
"
关闭ftp连接失败
"
,
e
);
log
.
error
(
"
�ر�ftp����ʧ��"
,
e
);
}
}
/**
*
进入到服务器的某个目录下
*
���뵽��������ij��Ŀ¼��
*
* @param directory
*/
...
...
@@ -336,12 +336,12 @@ public class FTPUtil {
ftpClient
.
changeWorkingDirectory
(
subPath
);
}
}
catch
(
IOException
ioe
)
{
log
.
error
(
"
改变ftp工作路径失败
"
,
ioe
);
log
.
error
(
"
�ı�ftp����·��ʧ��"
,
io
e
);
}
}
/**
* 转
码[ISO-8859-1 -> GBK] 不同的平台需要不同的转码
* ת
��[ISO-8859-1 -> GBK] ��ͬ��ƽ̨��Ҫ��ͬ��ת��
*
* @param obj
* @return ""
...
...
src/main/resources/mapper/Traffalarmrecord.xml
View file @
a29ac058
...
...
@@ -192,4 +192,10 @@
confirmUser=#{confirmUser},confirmTime=#{confirmTime}
where eventid=#{eventid}
</update>
<select
id=
"selectFailRecord"
resultType=
"com.hzjt.domain.Traffalarmrecord"
>
select a.* from TRAFFALARMRECORD a
where recordtime
<![CDATA[ <= ]]>
SYSDATE - NUMTODSINTERVAL(30, 'MINUTE') and recordtime > ADD_MONTHS(SYSDATE, -2)
and img1path is null
</select>
</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