Commit 39cc95e8 by zzrdark

1.日志上传文件上传

parent 07ddf46d
...@@ -55,6 +55,7 @@ CREATE TABLE `device_log` ( ...@@ -55,6 +55,7 @@ CREATE TABLE `device_log` (
`logfile_url` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '日志文件存放路径', `logfile_url` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL COMMENT '日志文件存放路径',
`logfile_size` bigint(20) DEFAULT NULL COMMENT '日志文件大小', `logfile_size` bigint(20) DEFAULT NULL COMMENT '日志文件大小',
`logfile_status` int(11) DEFAULT NULL COMMENT '日志文件上传状态,-1,失败,0上传中,1完成', `logfile_status` int(11) DEFAULT NULL COMMENT '日志文件上传状态,-1,失败,0上传中,1完成',
`log_accept_id` varchar (255) DEFAULT NULL COMMENT '移动端日志标识符',
PRIMARY KEY (`log_id`) USING BTREE PRIMARY KEY (`log_id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '测试上传的日志表' ROW_FORMAT = Dynamic; ) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci COMMENT = '测试上传的日志表' ROW_FORMAT = Dynamic;
......
...@@ -52,6 +52,11 @@ public class DeviceLogEntity implements Serializable { ...@@ -52,6 +52,11 @@ public class DeviceLogEntity implements Serializable {
* 复现步骤 * 复现步骤
*/ */
private String repetitionSteps; private String repetitionSteps;
/**
* 复现概率
*/
private Integer repetitionProbability;
/** /**
* 日志文件存放路径 * 日志文件存放路径
*/ */
...@@ -65,4 +70,8 @@ public class DeviceLogEntity implements Serializable { ...@@ -65,4 +70,8 @@ public class DeviceLogEntity implements Serializable {
*/ */
private Integer logfileStatus; private Integer logfileStatus;
/**
* 移动端日志文件标识符
*/
private String logAcceptId;
} }
...@@ -24,14 +24,17 @@ public class DeviceLogmediaEntity implements Serializable { ...@@ -24,14 +24,17 @@ public class DeviceLogmediaEntity implements Serializable {
*/ */
@TableId @TableId
private Long logmediaId; private Long logmediaId;
/** /**
* 音频路径 * 音频路径
*/ */
private String locationUrl; private String locationUrl;
/** /**
* *
*/ */
private Long logId; private Long logId;
/** /**
* 格式 * 格式
*/ */
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
<result property="logfileUrl" column="logfile_url"/> <result property="logfileUrl" column="logfile_url"/>
<result property="logfileSize" column="logfile_size"/> <result property="logfileSize" column="logfile_size"/>
<result property="logfileStatus" column="logfile_status"/> <result property="logfileStatus" column="logfile_status"/>
<result property="repetitionProbability" column="repetition_probability"/>
<result property="logAcceptId" column="log_accept_id"/>
</resultMap> </resultMap>
......
...@@ -54,6 +54,11 @@ public class DeviceLogDto { ...@@ -54,6 +54,11 @@ public class DeviceLogDto {
private String repetitionSteps; private String repetitionSteps;
/** /**
* 复现概率
*/
private Integer repetitionProbability;
/**
* 日志文件存放路径 * 日志文件存放路径
*/ */
private String logfileUrl; private String logfileUrl;
...@@ -77,4 +82,9 @@ public class DeviceLogDto { ...@@ -77,4 +82,9 @@ public class DeviceLogDto {
* 产品系列号 * 产品系列号
*/ */
private String seriesNum; private String seriesNum;
/**
* 移动端日志文件标识符
*/
private String logAcceptId;
} }
package com.mx.cneeds.common.dto;
import lombok.Data;
import java.io.File;
/**
* @ClassName DeviceLogFileDto
* @Author zzrdark
* @Date 2020-04-07 16:08
* @Description TODO
**/
@Data
public class DeviceLogFileDto {
String imei;
/**
* 移动端日志唯一标识符
*/
String logAcceptId;
/**
* log日志文件
*/
File logFile;
}
package com.mx.cneeds.common.dto;
import lombok.Data;
import java.io.File;
import java.util.List;
/**
* @ClassName WechatDeviceLogVo
* @Author zzrdark
* @Date 2020-04-07 15:42
* @Description TODO
**/
@Data
public class WechatDeviceLogDto {
String imei;
/**
* 移动端日志唯一标识符
*/
String logAcceptId;
/**
* 视频 图片文件
*/
List<File> files;
/**
* bug名字
*/
String bugTitle;
/**
* 复现步骤
*/
String steps;
/**
* 复现概率
*/
Integer probability;
}
package com.mx.cneeds.common.vo;
import lombok.Data;
import java.io.File;
/**
* @ClassName DeviceLogFileDto
* @Author zzrdark
* @Date 2020-04-07 16:08
* @Description TODO
**/
@Data
public class DeviceLogFileVo {
String imei;
/**
* 移动端日志唯一标识符
*/
String logAcceptId;
}
package com.mx.cneeds.common.vo;
import lombok.Data;
import java.io.File;
import java.util.List;
/**
* @ClassName WechatDeviceLogVo
* @Author zzrdark
* @Date 2020-04-07 15:42
* @Description TODO
**/
@Data
public class WechatDeviceLogVo {
String imei;
/**
* 移动端日志唯一标识符
*/
String logAcceptId;
/**
* 视频 图片文件
*/
List<File> files;
/**
* bug名字
*/
String bugTitle;
/**
* 复现步骤
*/
String steps;
/**
* 复现概率
*/
Integer probability;
}
...@@ -12,4 +12,4 @@ eureka: ...@@ -12,4 +12,4 @@ eureka:
defaultZone: http://192.168.2.244:8761/eureka/ defaultZone: http://192.168.2.244:8761/eureka/
instance: instance:
prefer-ip-address: true prefer-ip-address: true
ip-address: 192.168.2.244 # ip-address: 192.168.2.244
\ No newline at end of file \ No newline at end of file
package com.mx.cneeds.server.datashow.client; package com.mx.cneeds.server.datashow.client;
import com.mx.cneeds.common.dto.DeviceLogFileDto;
import com.mx.cneeds.common.dto.PageDto; import com.mx.cneeds.common.dto.PageDto;
import com.mx.cneeds.common.dto.WechatDeviceLogDto;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
...@@ -25,4 +28,14 @@ public interface LogFileClient { ...@@ -25,4 +28,14 @@ public interface LogFileClient {
@PostMapping("/log/upload/delete") @PostMapping("/log/upload/delete")
void deleteLogFile(@RequestBody List<Long> ids); void deleteLogFile(@RequestBody List<Long> ids);
@PostMapping("/log/upload/finishLog")
void finishLog(@RequestBody Long logId);
@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
void wechatUploadLog(@RequestBody WechatDeviceLogDto dto);
@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
void uploadLogFile(@RequestBody DeviceLogFileDto dto);
} }
...@@ -3,10 +3,10 @@ package com.mx.cneeds.server.datashow.web.device; ...@@ -3,10 +3,10 @@ package com.mx.cneeds.server.datashow.web.device;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.mx.cneeds.common.converter.RequestParamterConverter; import com.mx.cneeds.common.converter.RequestParamterConverter;
import com.mx.cneeds.common.dto.DeviceInfoDto; import com.mx.cneeds.common.dto.*;
import com.mx.cneeds.common.dto.DeviceLogDto;
import com.mx.cneeds.common.dto.PageDto;
import com.mx.cneeds.common.result.R; import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.vo.DeviceLogFileVo;
import com.mx.cneeds.common.vo.WechatDeviceLogVo;
import com.mx.cneeds.server.datashow.client.DeviceClient; import com.mx.cneeds.server.datashow.client.DeviceClient;
import com.mx.cneeds.server.datashow.client.LogFileClient; import com.mx.cneeds.server.datashow.client.LogFileClient;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -18,7 +18,9 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -18,7 +18,9 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -33,7 +35,7 @@ import java.util.Set; ...@@ -33,7 +35,7 @@ import java.util.Set;
@RestController @RestController
@Slf4j @Slf4j
@RequestMapping("/remotelog") @RequestMapping("/remotelog")
public class LogFileController { public class LogController {
@Autowired @Autowired
private LogFileClient logFileClient; private LogFileClient logFileClient;
...@@ -73,6 +75,7 @@ public class LogFileController { ...@@ -73,6 +75,7 @@ public class LogFileController {
Gson gson = RequestParamterConverter.getGson(); Gson gson = RequestParamterConverter.getGson();
List<DeviceLogDto> deviceLogDtos = new ArrayList<>(); List<DeviceLogDto> deviceLogDtos = new ArrayList<>();
// LinkedHashMap 转换成List
for (Object deviceLogDto: pageDto.getList() ) { for (Object deviceLogDto: pageDto.getList() ) {
String deviceLogDtoStr = gson.toJson(deviceLogDto); String deviceLogDtoStr = gson.toJson(deviceLogDto);
DeviceLogDto dto = gson.fromJson(deviceLogDtoStr,DeviceLogDto.class); DeviceLogDto dto = gson.fromJson(deviceLogDtoStr,DeviceLogDto.class);
...@@ -84,16 +87,18 @@ public class LogFileController { ...@@ -84,16 +87,18 @@ public class LogFileController {
deviceSet.add(deviceLogDto.getDeviceId()); deviceSet.add(deviceLogDto.getDeviceId());
}); });
List<DeviceInfoDto> deviceInfoDtos = deviceClient.queryDeviceByIds(deviceSet); if (deviceLogDtos != null && deviceLogDtos.size() != 0){
List<DeviceInfoDto> deviceInfoDtos = deviceClient.queryDeviceByIds(deviceSet);
deviceLogDtos.forEach(deviceLogDto -> { deviceLogDtos.forEach(deviceLogDto -> {
deviceInfoDtos.forEach(deviceInfoDto -> { deviceInfoDtos.forEach(deviceInfoDto -> {
if (deviceLogDto.getDeviceId().equals(deviceInfoDto.getDeviceId()) ){ if (deviceLogDto.getDeviceId().equals(deviceInfoDto.getDeviceId()) ){
deviceLogDto.setSeriesNum(deviceInfoDto.getSeriesNum()); deviceLogDto.setSeriesNum(deviceInfoDto.getSeriesNum());
deviceLogDto.setDeviceVersion(deviceInfoDto.getDeviceVersion()); deviceLogDto.setDeviceVersion(deviceInfoDto.getDeviceVersion());
} }
});
}); });
}); }
pageDto.setList(deviceLogDtos); pageDto.setList(deviceLogDtos);
...@@ -105,4 +110,15 @@ public class LogFileController { ...@@ -105,4 +110,15 @@ public class LogFileController {
logFileClient.deleteLogFile(ids); logFileClient.deleteLogFile(ids);
return R.ok(); return R.ok();
} }
/**
* 处理完成日志
* @return
*/
@PostMapping("/logfile/finish")
public R finishLog(@RequestParam(value = "logId") Long logId){
logFileClient.finishLog(logId);
return R.ok();
}
} }
package com.mx.cneeds.server.datashow.web.device;
import com.google.gson.Gson;
import com.mx.cneeds.common.converter.RequestParamterConverter;
import com.mx.cneeds.common.dto.*;
import com.mx.cneeds.common.result.R;
import com.mx.cneeds.common.vo.DeviceLogFileVo;
import com.mx.cneeds.common.vo.WechatDeviceLogVo;
import com.mx.cneeds.server.datashow.client.DeviceClient;
import com.mx.cneeds.server.datashow.client.LogFileClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
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 java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* @ClassName LogFileController
* @Author zzrdark
* @Date 2020-04-01 15:14
* @Description TODO
**/
@Controller
@Slf4j
@RequestMapping("/logFile")
public class LogFlieController {
@Autowired
private LogFileClient logFileClient;
@PostMapping("/logfile/wechatDeviceLogUpload")
public R wechatUploadLog(WechatDeviceLogVo vo){
WechatDeviceLogDto dto = new WechatDeviceLogDto();
BeanUtils.copyProperties(vo, dto);
logFileClient.wechatUploadLog(dto);
return R.ok();
}
@PostMapping("/logfile/DeviceLogFileUpload")
public R uploadLogFile(DeviceLogFileVo vo, MultipartFile file){
DeviceLogFileDto dto = new DeviceLogFileDto();
BeanUtils.copyProperties(vo, dto);
logFileClient.uploadLogFile(dto);
return R.ok();
}
}
...@@ -50,7 +50,7 @@ eureka: ...@@ -50,7 +50,7 @@ eureka:
defaultZone: http://192.168.2.244:8761/eureka/ defaultZone: http://192.168.2.244:8761/eureka/
instance: instance:
prefer-ip-address: true prefer-ip-address: true
# ip-address: 192.168.2.244 ip-address: 192.168.2.244
mybatis-plus: mybatis-plus:
......
package com.mx.cneeds.server.logupload.filesystem;
import java.io.InputStream;
import java.io.OutputStream;
/**
* @ClassName FileTemplate
* @Author zzrdark
* @Date 2020-04-07 15:09
* @Description TODO
**/
public interface FileTemplate {
/**
* 存储文件
* @param pathName
* @param ops
* @return
*/
Boolean saveFile(String pathName, OutputStream ops);
/**
* 获取文件
* @param pathName
* @return
*/
InputStream getFile(String pathName);
}
...@@ -41,10 +41,14 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogDao, DeviceLogEnt ...@@ -41,10 +41,14 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogDao, DeviceLogEnt
this.removeByIds(Arrays.asList(deviceLogIds)); this.removeByIds(Arrays.asList(deviceLogIds));
} }
/**
* 设置状态
* @param logId
*/
@Override @Override
public void changeStatus(Long logId){ public void changeStatus(Long logId){
DeviceLogEntity deviceLogEntity = new DeviceLogEntity(); DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.setStatus(1); deviceLogEntity.setStatus(1);
getBaseMapper().update(deviceLogEntity, new UpdateWrapper<DeviceLogEntity>().eq("logId", logId)); getBaseMapper().update(deviceLogEntity, new UpdateWrapper<DeviceLogEntity>().eq("log_id", logId));
} }
} }
package com.mx.cneeds.server.logupload.web; package com.mx.cneeds.server.logupload.web;
import com.mx.cneeds.common.dto.DeviceLogDto; import com.mx.cneeds.common.dto.DeviceLogDto;
import com.mx.cneeds.common.dto.DeviceLogFileDto;
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.logupload.service.DeviceLogService; import com.mx.cneeds.server.logupload.service.DeviceLogService;
...@@ -29,22 +31,13 @@ public class LogUploadController { ...@@ -29,22 +31,13 @@ public class LogUploadController {
@RequestMapping("/addLogInfo") @RequestMapping("/addLogInfo")
public void wechatUploadLog( public void wechatUploadLog(WechatDeviceLogDto dto){
String imei,
String logId,
List<File> files,
String bugTitle,
String steps,
Integer probability){
} }
@RequestMapping("/addLogFile") @RequestMapping("/addLogFile")
public void uploadLogFile( public void uploadLogFile(DeviceLogFileDto dto){
String imei,
String logId,
File logFile ){
} }
...@@ -80,7 +73,7 @@ public class LogUploadController { ...@@ -80,7 +73,7 @@ public class LogUploadController {
} }
@RequestMapping("/finishLog") @RequestMapping("/finishLog")
public R finishLog(Long logId){ public R finishLog(@RequestBody Long logId){
deviceLogService.changeStatus(logId); deviceLogService.changeStatus(logId);
return R.ok(); return R.ok();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment