Commit c070b6b0 by zzrdark

1.add日志上传模块

parent 39cc95e8
...@@ -18,8 +18,14 @@ public class DeviceLogFileDto { ...@@ -18,8 +18,14 @@ public class DeviceLogFileDto {
* 移动端日志唯一标识符 * 移动端日志唯一标识符
*/ */
String logAcceptId; String logAcceptId;
/**
*
*/
String logfileUrl;
/** /**
* log日志文件 * 设备Id
*/ */
File logFile; Long deviceId;
} }
...@@ -24,9 +24,9 @@ public class WechatDeviceLogDto { ...@@ -24,9 +24,9 @@ public class WechatDeviceLogDto {
String logAcceptId; String logAcceptId;
/** /**
* 视频 图片文件 * 视频 图片文件路径
*/ */
List<File> files; List<String> locationUrls;
/** /**
* bug名字 * bug名字
...@@ -43,4 +43,10 @@ public class WechatDeviceLogDto { ...@@ -43,4 +43,10 @@ public class WechatDeviceLogDto {
*/ */
Integer probability; Integer probability;
/**
* 设备ID
*/
Long deviceId;
} }
...@@ -24,9 +24,9 @@ public class WechatDeviceLogVo { ...@@ -24,9 +24,9 @@ public class WechatDeviceLogVo {
String logAcceptId; String logAcceptId;
/** /**
* 视频 图片文件 * 视频 图片文件路径
*/ */
List<File> files; List<String> locationUrls;
/** /**
* bug名字 * bug名字
......
...@@ -40,9 +40,6 @@ public interface DeviceClient { ...@@ -40,9 +40,6 @@ public interface DeviceClient {
void deleteSeries(@RequestBody List<Long> ids); void deleteSeries(@RequestBody List<Long> ids);
@PostMapping("device/info/list") @PostMapping("device/info/list")
PageDto deviceList(@RequestParam Integer page, PageDto deviceList(@RequestParam Integer page,
@RequestParam("limit") Integer pageSize, @RequestParam("limit") Integer pageSize,
......
...@@ -32,10 +32,10 @@ public interface LogFileClient { ...@@ -32,10 +32,10 @@ public interface LogFileClient {
@PostMapping("/log/upload/finishLog") @PostMapping("/log/upload/finishLog")
void finishLog(@RequestBody Long logId); void finishLog(@RequestBody Long logId);
@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "/log/upload/wechatUploadLog")
void wechatUploadLog(@RequestBody WechatDeviceLogDto dto); void wechatUploadLog(@RequestBody WechatDeviceLogDto dto);
@PostMapping(value = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @PostMapping(value = "/log/upload/uploadLogFile")
void uploadLogFile(@RequestBody DeviceLogFileDto dto); void uploadLogFile(@RequestBody DeviceLogFileDto dto);
} }
...@@ -19,6 +19,9 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -19,6 +19,9 @@ 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 org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
...@@ -38,19 +41,31 @@ public class LogFlieController { ...@@ -38,19 +41,31 @@ public class LogFlieController {
@Autowired @Autowired
private LogFileClient logFileClient; private LogFileClient logFileClient;
@Autowired
private DeviceClient deviceClient;
@PostMapping("/logfile/wechatDeviceLogUpload") @PostMapping("/logfile/wechatDeviceLogUpload")
public R wechatUploadLog(WechatDeviceLogVo vo){ public R wechatUploadLog(WechatDeviceLogVo vo, MultipartFile[] file){
WechatDeviceLogDto dto = new WechatDeviceLogDto(); WechatDeviceLogDto dto = new WechatDeviceLogDto();
BeanUtils.copyProperties(vo, dto); BeanUtils.copyProperties(vo, dto);
// 把图片存入oos 返回路径
// dto.setLogfileUrl()
DeviceInfoDto deviceInfoDto = deviceClient.queryDeviceByImei(dto.getImei());
dto.setDeviceId(deviceInfoDto.getDeviceId());
logFileClient.wechatUploadLog(dto); logFileClient.wechatUploadLog(dto);
return R.ok(); return R.ok();
} }
@PostMapping("/logfile/DeviceLogFileUpload") @PostMapping("/logfile/DeviceLogFileUpload")
public R uploadLogFile(DeviceLogFileVo vo, MultipartFile file){ 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 返回路径
// dto.setLogfileUrl()
DeviceInfoDto deviceInfoDto = deviceClient.queryDeviceByImei(dto.getImei());
dto.setDeviceId(deviceInfoDto.getDeviceId());
logFileClient.uploadLogFile(dto); logFileClient.uploadLogFile(dto);
return R.ok(); return R.ok();
} }
......
...@@ -14,4 +14,10 @@ public interface DeviceLogService extends IService<DeviceLogEntity> { ...@@ -14,4 +14,10 @@ public interface DeviceLogService extends IService<DeviceLogEntity> {
void deleteBatch(Long[] deviceLogIds); void deleteBatch(Long[] deviceLogIds);
void changeStatus(Long logId); void changeStatus(Long logId);
void wechatUploadLog(DeviceLogEntity deviceLogEntity);
void deviceUploadLogFile(DeviceLogEntity deviceLogEntity);
DeviceLogEntity queryOneBylogAcceptId(String logAcceptId);
} }
\ No newline at end of file
...@@ -9,6 +9,7 @@ import com.mx.cneeds.common.pager.Query; ...@@ -9,6 +9,7 @@ import com.mx.cneeds.common.pager.Query;
import com.mx.cneeds.server.dao.DeviceLogDao; import com.mx.cneeds.server.dao.DeviceLogDao;
import com.mx.cneeds.server.entity.DeviceLogEntity; import com.mx.cneeds.server.entity.DeviceLogEntity;
import com.mx.cneeds.server.logupload.service.DeviceLogService; import com.mx.cneeds.server.logupload.service.DeviceLogService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -51,4 +52,34 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogDao, DeviceLogEnt ...@@ -51,4 +52,34 @@ public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogDao, DeviceLogEnt
deviceLogEntity.setStatus(1); deviceLogEntity.setStatus(1);
getBaseMapper().update(deviceLogEntity, new UpdateWrapper<DeviceLogEntity>().eq("log_id", logId)); getBaseMapper().update(deviceLogEntity, new UpdateWrapper<DeviceLogEntity>().eq("log_id", logId));
} }
@Override
public void wechatUploadLog(DeviceLogEntity deviceLogEntity){
DeviceLogEntity logEntity = queryOneBylogAcceptId(deviceLogEntity.getLogAcceptId());
if(logEntity != null){
getBaseMapper().update(deviceLogEntity,
new UpdateWrapper<DeviceLogEntity>()
.eq("log_accept_id", deviceLogEntity.getLogAcceptId()));
}else {
getBaseMapper().insert(deviceLogEntity);
}
}
@Override
public void deviceUploadLogFile(DeviceLogEntity deviceLogEntity){
DeviceLogEntity logEntity = queryOneBylogAcceptId(deviceLogEntity.getLogAcceptId());
if(logEntity != null){
getBaseMapper().update(deviceLogEntity,
new UpdateWrapper<DeviceLogEntity>()
.eq("log_accept_id", deviceLogEntity.getLogAcceptId()));
}else {
getBaseMapper().insert(deviceLogEntity);
}
}
@Override
public DeviceLogEntity queryOneBylogAcceptId(String logAcceptId){
return getBaseMapper().selectOne(new QueryWrapper<DeviceLogEntity>()
.eq("log_accept_id",logAcceptId));
}
} }
...@@ -5,6 +5,7 @@ import com.mx.cneeds.common.dto.DeviceLogFileDto; ...@@ -5,6 +5,7 @@ import com.mx.cneeds.common.dto.DeviceLogFileDto;
import com.mx.cneeds.common.dto.WechatDeviceLogDto; 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.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,15 +31,28 @@ public class LogUploadController { ...@@ -30,15 +31,28 @@ public class LogUploadController {
private DeviceLogService deviceLogService; private DeviceLogService deviceLogService;
@RequestMapping("/addLogInfo") @RequestMapping("/wechatUploadLog")
public void wechatUploadLog(WechatDeviceLogDto dto){ public void wechatUploadLog(WechatDeviceLogDto dto){
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
}
deviceLogEntity.setLogAcceptId(dto.getLogAcceptId());
deviceLogEntity.setDeviceId(dto.getDeviceId());
deviceLogEntity.setLogName(dto.getBugTitle());
deviceLogEntity.setRepetitionProbability(dto.getProbability());
deviceLogEntity.setRepetitionSteps(dto.getSteps());
deviceLogService.wechatUploadLog(deviceLogEntity);
}
@RequestMapping("/addLogFile")
public void uploadLogFile(DeviceLogFileDto dto){
@RequestMapping("/uploadLogFile")
public void uploadLogFile(@RequestBody DeviceLogFileDto dto){
DeviceLogEntity deviceLogEntity = new DeviceLogEntity();
deviceLogEntity.setDeviceId(dto.getDeviceId());
deviceLogEntity.setLogfileUrl(dto.getLogfileUrl());
deviceLogEntity.setLogAcceptId(dto.getLogAcceptId());
deviceLogService.deviceUploadLogFile(deviceLogEntity);
} }
/** /**
......
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