Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cneeds-server
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
zhangzr
cneeds-server
Commits
2e87fffd
Commit
2e87fffd
authored
Apr 23, 2020
by
zzrdark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.add device log oos
parent
87ce018e
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
89 additions
and
31 deletions
+89
-31
LogFlieController.java
.../cneeds/server/datashow/web/device/LogFlieController.java
+16
-18
WechatController.java
...x/cneeds/server/datashow/web/wechat/WechatController.java
+8
-7
application.yml
cneeds-server-datashow/src/main/resources/application.yml
+1
-1
DeviceLogMediaService.java
...needs/server/logupload/service/DeviceLogMediaService.java
+10
-0
DeviceLogService.java
.../mx/cneeds/server/logupload/service/DeviceLogService.java
+1
-1
DeviceLogMediaServiceImpl.java
...ver/logupload/service/impl/DeviceLogMediaServiceImpl.java
+35
-0
DeviceLogServiceImpl.java
...s/server/logupload/service/impl/DeviceLogServiceImpl.java
+8
-1
LogUploadController.java
...m/mx/cneeds/server/logupload/web/LogUploadController.java
+9
-2
application.yml
cneeds-server-logupload/src/main/resources/application.yml
+1
-1
No files found.
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/web/device/LogFlieController.java
View file @
2e87fffd
...
@@ -15,10 +15,7 @@ import org.apache.commons.lang.StringUtils;
...
@@ -15,10 +15,7 @@ import org.apache.commons.lang.StringUtils;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
java.io.File
;
import
java.io.File
;
...
@@ -48,13 +45,20 @@ public class LogFlieController {
...
@@ -48,13 +45,20 @@ public class LogFlieController {
private
HdfsTemplate
hdfsTemplate
;
private
HdfsTemplate
hdfsTemplate
;
@PostMapping
(
"/logfile/wechatDeviceLogUpload"
)
@PostMapping
(
"/logfile/wechatDeviceLogUpload"
)
public
R
wechatUploadLog
(
WechatDeviceLogVo
vo
,
MultipartFile
[]
file
){
@ResponseBody
public
R
wechatUploadLog
(
WechatDeviceLogVo
vo
,
MultipartFile
[]
file
)
throws
IOException
{
WechatDeviceLogDto
dto
=
new
WechatDeviceLogDto
();
WechatDeviceLogDto
dto
=
new
WechatDeviceLogDto
();
BeanUtils
.
copyProperties
(
vo
,
dto
);
BeanUtils
.
copyProperties
(
vo
,
dto
);
// 把图片存入oos 返回路径
List
<
String
>
listUrl
=
new
ArrayList
<>();
// dto.setLogfileUrl()
for
(
MultipartFile
f
:
file
){
// 把图片存入 oos 返回路径
StringBuffer
dir
=
new
StringBuffer
(
FilePath
.
LogFilePath
);
dir
.
append
(
vo
.
getLogAcceptId
());
hdfsTemplate
.
saveFile
(
dir
.
toString
(),
f
.
getOriginalFilename
(),
f
.
getInputStream
(),
f
.
getSize
(),
(
short
)
2
);
listUrl
.
add
(
dir
.
toString
()+
"/"
+
f
.
getOriginalFilename
());
}
dto
.
setLocationUrls
(
listUrl
);
DeviceInfoDto
deviceInfoDto
=
deviceClient
.
queryDeviceByImei
(
dto
.
getImei
());
DeviceInfoDto
deviceInfoDto
=
deviceClient
.
queryDeviceByImei
(
dto
.
getImei
());
dto
.
setDeviceId
(
deviceInfoDto
.
getDeviceId
());
dto
.
setDeviceId
(
deviceInfoDto
.
getDeviceId
());
logFileClient
.
wechatUploadLog
(
dto
);
logFileClient
.
wechatUploadLog
(
dto
);
...
@@ -62,24 +66,18 @@ public class LogFlieController {
...
@@ -62,24 +66,18 @@ public class LogFlieController {
}
}
@PostMapping
(
"/logfile/DeviceLogFileUpload"
)
@PostMapping
(
"/logfile/DeviceLogFileUpload"
)
@ResponseBody
public
R
uploadLogFile
(
DeviceLogFileVo
vo
,
MultipartFile
file
)
throws
IOException
{
public
R
uploadLogFile
(
DeviceLogFileVo
vo
,
MultipartFile
file
)
throws
IOException
{
DeviceLogFileDto
dto
=
new
DeviceLogFileDto
();
DeviceLogFileDto
dto
=
new
DeviceLogFileDto
();
BeanUtils
.
copyProperties
(
vo
,
dto
);
BeanUtils
.
copyProperties
(
vo
,
dto
);
// 把图片存入oos 返回路径
// 把图片存入oos 返回路径
// dto.setLogfileUrl()
StringBuffer
dir
=
new
StringBuffer
(
FilePath
.
LogFilePath
);
StringBuffer
dir
=
new
StringBuffer
(
FilePath
.
LogFilePath
);
dir
.
append
(
vo
.
getLogAcceptId
());
hdfsTemplate
.
saveFile
(
dir
.
toString
(),
file
.
getOriginalFilename
(),
file
.
getInputStream
(),
file
.
getSize
(),
(
short
)
2
);
dto
.
setLogfileUrl
(
dir
.
toString
()+
"/"
+
file
.
getOriginalFilename
());
// 1. 读取系统时间
Calendar
calendar
=
Calendar
.
getInstance
();
Date
time
=
calendar
.
getTime
();
// 2. 格式化系统时间
SimpleDateFormat
format
=
new
SimpleDateFormat
(
"yyyy-MM-dd-HH-mm-ss"
);
String
fileName
=
format
.
format
(
time
);
dir
.
append
(
fileName
);
hdfsTemplate
.
saveFile
(
dir
.
toString
(),
file
.
getName
(),
file
.
getInputStream
(),
file
.
getSize
(),
(
short
)
2
);
DeviceInfoDto
deviceInfoDto
=
deviceClient
.
queryDeviceByImei
(
dto
.
getImei
());
DeviceInfoDto
deviceInfoDto
=
deviceClient
.
queryDeviceByImei
(
dto
.
getImei
());
dto
.
setDeviceId
(
deviceInfoDto
.
getDeviceId
());
dto
.
setDeviceId
(
deviceInfoDto
.
getDeviceId
());
logFileClient
.
uploadLogFile
(
dto
);
logFileClient
.
uploadLogFile
(
dto
);
...
...
cneeds-server-datashow/src/main/java/com/mx/cneeds/server/datashow/web/wechat/WechatController.java
View file @
2e87fffd
...
@@ -50,13 +50,13 @@ public class WechatController {
...
@@ -50,13 +50,13 @@ public class WechatController {
httpServletRequest
.
getServerName
()
+
":"
+
httpServletRequest
.
getServerName
()
+
":"
+
httpServletRequest
.
getServerPort
()+
httpServletRequest
.
getServerPort
()+
"/wechat/wechatDownload/"
+
fileName
+
"/"
"/wechat/wechatDownload/"
+
fileName
+
"/"
+
file
.
getOriginalFilename
();
+
file
.
get
Size
()+
"/"
+
file
.
get
OriginalFilename
();
return
R
.
ok
().
put
(
"data"
,
sufUrl
);
return
R
.
ok
().
put
(
"data"
,
sufUrl
);
}
}
@RequestMapping
(
"/wechatDownload/{dir}/{fileName}"
)
@RequestMapping
(
"/wechatDownload/{dir}/{file
Size}/{file
Name}"
)
public
void
download
(
@PathVariable
(
"dir"
)
String
dir
,
@PathVariable
(
"fileName"
)
String
fileName
,
public
void
download
(
@PathVariable
(
"dir"
)
String
dir
,
@PathVariable
(
"fileName"
)
String
fileName
,
HttpServletResponse
response
)
throws
IOException
{
@PathVariable
(
"fileSize"
)
String
fileSize
,
HttpServletResponse
response
)
throws
IOException
{
StringBuffer
dirPath
=
new
StringBuffer
(
FilePath
.
wechatFilePath
);
StringBuffer
dirPath
=
new
StringBuffer
(
FilePath
.
wechatFilePath
);
dirPath
.
append
(
dir
);
dirPath
.
append
(
dir
);
InputStream
inputStream
=
hdfsTemplate
.
openFile
(
dirPath
.
toString
(),
fileName
);
InputStream
inputStream
=
hdfsTemplate
.
openFile
(
dirPath
.
toString
(),
fileName
);
...
@@ -68,11 +68,12 @@ public class WechatController {
...
@@ -68,11 +68,12 @@ public class WechatController {
byte
[]
bytes
=
new
byte
[
1024
];
byte
[]
bytes
=
new
byte
[
1024
];
long
total
=
Long
.
valueOf
(
fileSize
);
int
i
=
0
;
while
(
total
>
0
)
{
while
((
i
=
inputStream
.
read
(
bytes
))
!=
-
1
)
{
inputStream
.
read
(
bytes
);
outputStream
.
write
(
bytes
,
0
,
i
);
outputStream
.
write
(
bytes
,
0
,
total
>
1024
?
1024
:
(
int
)
total
);
outputStream
.
flush
();
outputStream
.
flush
();
total
-=
1024
;
}
}
outputStream
.
close
();
outputStream
.
close
();
...
...
cneeds-server-datashow/src/main/resources/application.yml
View file @
2e87fffd
spring
:
spring
:
profiles
:
profiles
:
active
:
prod
active
:
dev
application
:
application
:
name
:
cneeds-server-datashow
name
:
cneeds-server-datashow
server
:
server
:
...
...
cneeds-server-logupload/src/main/java/com/mx/cneeds/server/logupload/service/DeviceLogMediaService.java
0 → 100644
View file @
2e87fffd
package
com
.
mx
.
cneeds
.
server
.
logupload
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.mx.cneeds.server.entity.DeviceLogmediaEntity
;
import
java.util.List
;
public
interface
DeviceLogMediaService
extends
IService
<
DeviceLogmediaEntity
>
{
void
savewechatMedia
(
Long
logId
,
List
<
String
>
urls
);
}
cneeds-server-logupload/src/main/java/com/mx/cneeds/server/logupload/service/DeviceLogService.java
View file @
2e87fffd
...
@@ -15,7 +15,7 @@ public interface DeviceLogService extends IService<DeviceLogEntity> {
...
@@ -15,7 +15,7 @@ public interface DeviceLogService extends IService<DeviceLogEntity> {
void
changeStatus
(
Long
logId
);
void
changeStatus
(
Long
logId
);
void
wechatUploadLog
(
DeviceLogEntity
deviceLogEntity
);
Long
wechatUploadLog
(
DeviceLogEntity
deviceLogEntity
);
void
deviceUploadLogFile
(
DeviceLogEntity
deviceLogEntity
);
void
deviceUploadLogFile
(
DeviceLogEntity
deviceLogEntity
);
...
...
cneeds-server-logupload/src/main/java/com/mx/cneeds/server/logupload/service/impl/DeviceLogMediaServiceImpl.java
0 → 100644
View file @
2e87fffd
package
com
.
mx
.
cneeds
.
server
.
logupload
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.mx.cneeds.server.dao.DeviceLogmediaDao
;
import
com.mx.cneeds.server.entity.DeviceLogEntity
;
import
com.mx.cneeds.server.entity.DeviceLogmediaEntity
;
import
com.mx.cneeds.server.logupload.service.DeviceLogMediaService
;
import
org.springframework.stereotype.Service
;
import
java.util.LinkedList
;
import
java.util.List
;
/**
* @ClassName DeviceLogMediaServiceImpl
* @Author zzrdark
* @Date 2020-04-23 17:19
* @Description TODO
**/
@Service
public
class
DeviceLogMediaServiceImpl
extends
ServiceImpl
<
DeviceLogmediaDao
,
DeviceLogmediaEntity
>
implements
DeviceLogMediaService
{
@Override
public
void
savewechatMedia
(
Long
logId
,
List
<
String
>
urls
){
List
<
DeviceLogmediaEntity
>
deviceLogmediaEntities
=
new
LinkedList
<
DeviceLogmediaEntity
>();
for
(
String
url:
urls
){
DeviceLogmediaEntity
deviceLogmediaEntity
=
new
DeviceLogmediaEntity
();
deviceLogmediaEntity
.
setLocationUrl
(
url
);
deviceLogmediaEntity
.
setLogId
(
logId
);
deviceLogmediaEntity
.
setType
(
url
.
substring
(
url
.
indexOf
(
"."
)));
deviceLogmediaEntities
.
add
(
deviceLogmediaEntity
);
}
saveBatch
(
deviceLogmediaEntities
);
}
}
cneeds-server-logupload/src/main/java/com/mx/cneeds/server/logupload/service/impl/DeviceLogServiceImpl.java
View file @
2e87fffd
...
@@ -14,6 +14,8 @@ import org.springframework.stereotype.Service;
...
@@ -14,6 +14,8 @@ import org.springframework.stereotype.Service;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.LinkedList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
/**
/**
...
@@ -54,7 +56,7 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogDao, DeviceLogEnt
...
@@ -54,7 +56,7 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogDao, DeviceLogEnt
}
}
@Override
@Override
public
void
wechatUploadLog
(
DeviceLogEntity
deviceLogEntity
){
public
Long
wechatUploadLog
(
DeviceLogEntity
deviceLogEntity
){
DeviceLogEntity
logEntity
=
queryOneBylogAcceptId
(
deviceLogEntity
.
getLogAcceptId
());
DeviceLogEntity
logEntity
=
queryOneBylogAcceptId
(
deviceLogEntity
.
getLogAcceptId
());
if
(
logEntity
!=
null
){
if
(
logEntity
!=
null
){
getBaseMapper
().
update
(
deviceLogEntity
,
getBaseMapper
().
update
(
deviceLogEntity
,
...
@@ -62,9 +64,14 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogDao, DeviceLogEnt
...
@@ -62,9 +64,14 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogDao, DeviceLogEnt
.
eq
(
"log_accept_id"
,
deviceLogEntity
.
getLogAcceptId
()));
.
eq
(
"log_accept_id"
,
deviceLogEntity
.
getLogAcceptId
()));
}
else
{
}
else
{
getBaseMapper
().
insert
(
deviceLogEntity
);
getBaseMapper
().
insert
(
deviceLogEntity
);
logEntity
=
queryOneBylogAcceptId
(
deviceLogEntity
.
getLogAcceptId
());
}
}
return
logEntity
.
getLogId
();
}
}
@Override
@Override
public
void
deviceUploadLogFile
(
DeviceLogEntity
deviceLogEntity
){
public
void
deviceUploadLogFile
(
DeviceLogEntity
deviceLogEntity
){
DeviceLogEntity
logEntity
=
queryOneBylogAcceptId
(
deviceLogEntity
.
getLogAcceptId
());
DeviceLogEntity
logEntity
=
queryOneBylogAcceptId
(
deviceLogEntity
.
getLogAcceptId
());
...
...
cneeds-server-logupload/src/main/java/com/mx/cneeds/server/logupload/web/LogUploadController.java
View file @
2e87fffd
...
@@ -6,6 +6,7 @@ import com.mx.cneeds.common.dto.WechatDeviceLogDto;
...
@@ -6,6 +6,7 @@ import com.mx.cneeds.common.dto.WechatDeviceLogDto;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.common.pager.PageUtils
;
import
com.mx.cneeds.common.result.R
;
import
com.mx.cneeds.common.result.R
;
import
com.mx.cneeds.server.entity.DeviceLogEntity
;
import
com.mx.cneeds.server.entity.DeviceLogEntity
;
import
com.mx.cneeds.server.logupload.service.DeviceLogMediaService
;
import
com.mx.cneeds.server.logupload.service.DeviceLogService
;
import
com.mx.cneeds.server.logupload.service.DeviceLogService
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -30,9 +31,12 @@ public class LogUploadController {
...
@@ -30,9 +31,12 @@ public class LogUploadController {
@Autowired
@Autowired
private
DeviceLogService
deviceLogService
;
private
DeviceLogService
deviceLogService
;
@Autowired
private
DeviceLogMediaService
deviceLogMediaService
;
@RequestMapping
(
"/wechatUploadLog"
)
@RequestMapping
(
"/wechatUploadLog"
)
public
void
wechatUploadLog
(
WechatDeviceLogDto
dto
){
public
void
wechatUploadLog
(
@RequestBody
WechatDeviceLogDto
dto
){
DeviceLogEntity
deviceLogEntity
=
new
DeviceLogEntity
();
DeviceLogEntity
deviceLogEntity
=
new
DeviceLogEntity
();
...
@@ -41,8 +45,11 @@ public class LogUploadController {
...
@@ -41,8 +45,11 @@ public class LogUploadController {
deviceLogEntity
.
setLogName
(
dto
.
getBugTitle
());
deviceLogEntity
.
setLogName
(
dto
.
getBugTitle
());
deviceLogEntity
.
setRepetitionProbability
(
dto
.
getProbability
());
deviceLogEntity
.
setRepetitionProbability
(
dto
.
getProbability
());
deviceLogEntity
.
setRepetitionSteps
(
dto
.
getSteps
());
deviceLogEntity
.
setRepetitionSteps
(
dto
.
getSteps
());
deviceLogService
.
wechatUploadLog
(
deviceLogEntity
);
Long
logId
=
deviceLogService
.
wechatUploadLog
(
deviceLogEntity
);
if
(
dto
.
getLocationUrls
()!=
null
&&
dto
.
getLocationUrls
().
size
()
!=
0
){
deviceLogMediaService
.
savewechatMedia
(
logId
,
dto
.
getLocationUrls
());
}
}
}
...
...
cneeds-server-logupload/src/main/resources/application.yml
View file @
2e87fffd
spring
:
spring
:
profiles
:
profiles
:
active
:
prod
active
:
dev
application
:
application
:
name
:
cneeds-server-logupload
name
:
cneeds-server-logupload
...
...
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