无人机大图
This commit is contained in:
@ -88,7 +88,7 @@ public class DroDroneBigPictureController extends BaseController {
|
|||||||
@RepeatSubmit()
|
@RepeatSubmit()
|
||||||
@PostMapping()
|
@PostMapping()
|
||||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody DroDroneBigPictureBo bo) {
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody DroDroneBigPictureBo bo) {
|
||||||
return toAjax(droDroneBigPictureService.insertByBo(bo));
|
return toAjax(droDroneBigPictureService.insertByBo(bo, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -50,10 +50,11 @@ public interface IDroDroneBigPictureService extends IService<DroDroneBigPicture>
|
|||||||
/**
|
/**
|
||||||
* 新增无人机大图信息
|
* 新增无人机大图信息
|
||||||
*
|
*
|
||||||
* @param bo 无人机大图信息
|
* @param bo 无人机大图信息
|
||||||
|
* @param isNew 是否创建新记录
|
||||||
* @return 是否新增成功
|
* @return 是否新增成功
|
||||||
*/
|
*/
|
||||||
Boolean insertByBo(DroDroneBigPictureBo bo);
|
Boolean insertByBo(DroDroneBigPictureBo bo, Boolean isNew);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改无人机大图信息
|
* 修改无人机大图信息
|
||||||
|
|||||||
@ -62,7 +62,8 @@ import java.util.stream.Collectors;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
@Service
|
@Service
|
||||||
public class DroDroneBigPictureServiceImpl extends ServiceImpl<DroDroneBigPictureMapper, DroDroneBigPicture>
|
public
|
||||||
|
class DroDroneBigPictureServiceImpl extends ServiceImpl<DroDroneBigPictureMapper, DroDroneBigPicture>
|
||||||
implements IDroDroneBigPictureService {
|
implements IDroDroneBigPictureService {
|
||||||
|
|
||||||
@Lazy
|
@Lazy
|
||||||
@ -218,21 +219,24 @@ public class DroDroneBigPictureServiceImpl extends ServiceImpl<DroDroneBigPictur
|
|||||||
/**
|
/**
|
||||||
* 新增无人机大图信息
|
* 新增无人机大图信息
|
||||||
*
|
*
|
||||||
* @param bo 无人机大图信息
|
* @param bo 无人机大图信息
|
||||||
|
* @param isNew 是否创建新记录
|
||||||
* @return 是否新增成功
|
* @return 是否新增成功
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean insertByBo(DroDroneBigPictureBo bo) {
|
public Boolean insertByBo(DroDroneBigPictureBo bo, Boolean isNew) {
|
||||||
DroDroneBigPicture add = MapstructUtils.convert(bo, DroDroneBigPicture.class);
|
DroDroneBigPicture add = MapstructUtils.convert(bo, DroDroneBigPicture.class);
|
||||||
if (add == null) {
|
if (add == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(add.getBigPic()) && StringUtils.isNotBlank(add.getTifFile())) {
|
if (isNew) {
|
||||||
add.setStatus("3");
|
if (StringUtils.isNotBlank(add.getBigPic()) && StringUtils.isNotBlank(add.getTifFile())) {
|
||||||
}
|
add.setStatus("3");
|
||||||
boolean save = this.save(add);
|
}
|
||||||
if (!save) {
|
boolean save = this.save(add);
|
||||||
throw new ServiceException("新增无人机大图信息失败");
|
if (!save) {
|
||||||
|
throw new ServiceException("新增无人机大图信息失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Long id = add.getId();
|
Long id = add.getId();
|
||||||
// 压缩图片
|
// 压缩图片
|
||||||
@ -268,6 +272,10 @@ public class DroDroneBigPictureServiceImpl extends ServiceImpl<DroDroneBigPictur
|
|||||||
this.updateById(update);
|
this.updateById(update);
|
||||||
}).exceptionally(ex -> {
|
}).exceptionally(ex -> {
|
||||||
log.error("无人机大图信息[{}]异步执行合成图片失败", add.getTaskName(), ex);
|
log.error("无人机大图信息[{}]异步执行合成图片失败", add.getTaskName(), ex);
|
||||||
|
DroDroneBigPicture update = new DroDroneBigPicture();
|
||||||
|
update.setId(id);
|
||||||
|
update.setStatus("4");
|
||||||
|
this.updateById(update);
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -413,6 +421,32 @@ public class DroDroneBigPictureServiceImpl extends ServiceImpl<DroDroneBigPictur
|
|||||||
throw new ServiceException("图片删除异常");
|
throw new ServiceException("图片删除异常");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (DroDroneBigPicture picture : list) {
|
||||||
|
String bigPic = picture.getBigPic();
|
||||||
|
if (StringUtils.isNotBlank(bigPic)) {
|
||||||
|
if (isLong(bigPic)) {
|
||||||
|
SysOssVo ossVo = ossService.getById(Long.parseLong(bigPic));
|
||||||
|
if (ossVo != null) {
|
||||||
|
ossService.deleteWithValidByIds(Collections.singleton(ossVo.getOssId()), false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
OssClient storage = OssFactory.instance();
|
||||||
|
storage.delete(bigPic);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String tifFile = picture.getTifFile();
|
||||||
|
if (StringUtils.isNotBlank(tifFile)) {
|
||||||
|
if (isLong(tifFile)) {
|
||||||
|
SysOssVo ossVo = ossService.getById(Long.parseLong(tifFile));
|
||||||
|
if (ossVo != null) {
|
||||||
|
ossService.deleteWithValidByIds(Collections.singleton(ossVo.getOssId()), false);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
OssClient storage = OssFactory.instance();
|
||||||
|
storage.delete(tifFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return this.removeBatchByIds(ids);
|
return this.removeBatchByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -637,24 +671,34 @@ public class DroDroneBigPictureServiceImpl extends ServiceImpl<DroDroneBigPictur
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new ServiceException("ZIP 文件保存失败");
|
throw new ServiceException("ZIP 文件保存失败");
|
||||||
}
|
}
|
||||||
|
// 保存数据
|
||||||
|
bo.setStatus("9");
|
||||||
|
DroDroneBigPicture picture = new DroDroneBigPicture();
|
||||||
|
BeanUtils.copyProperties(bo, picture);
|
||||||
|
boolean save = this.save(picture);
|
||||||
|
if (!save) {
|
||||||
|
throw new ServiceException("保存数据失败");
|
||||||
|
}
|
||||||
|
Long id = picture.getId();
|
||||||
// 异步解压
|
// 异步解压
|
||||||
self.unzipAsync(zipFile, tempDir)
|
self.unzipAsync(zipFile, tempDir)
|
||||||
.thenAccept(result -> {
|
.thenAccept(result -> {
|
||||||
String fileStr = result.stream()
|
String fileStr = result.stream()
|
||||||
.map(String::valueOf)
|
.map(String::valueOf)
|
||||||
.collect(Collectors.joining(","));
|
.collect(Collectors.joining(","));
|
||||||
|
bo.setId(id);
|
||||||
bo.setSmallPic(fileStr);
|
bo.setSmallPic(fileStr);
|
||||||
this.insertByBo(bo);
|
this.insertByBo(bo, false);
|
||||||
})
|
})
|
||||||
.exceptionally(ex -> {
|
.exceptionally(ex -> {
|
||||||
// 统一处理解压失败(包括 ZipUtil 等异常)
|
// 统一处理解压失败(包括 ZipUtil 等异常)
|
||||||
log.error("压缩包处理失败: {}", ex.getMessage(), ex);
|
log.error("压缩包处理失败: {}", ex.getMessage(), ex);
|
||||||
// 保存数据
|
// 保存数据
|
||||||
DroDroneBigPicture picture = new DroDroneBigPicture();
|
DroDroneBigPicture update = new DroDroneBigPicture();
|
||||||
BeanUtils.copyProperties(bo, picture);
|
update.setId(id);
|
||||||
picture.setStatus("8");
|
update.setStatus("8");
|
||||||
picture.setRemark(ex.getMessage());
|
update.setRemark(ex.getMessage());
|
||||||
this.save(picture);
|
this.updateById(picture);
|
||||||
return null;
|
return null;
|
||||||
}).whenComplete((r, ex) -> {
|
}).whenComplete((r, ex) -> {
|
||||||
// 不管成功失败,都删除临时文件
|
// 不管成功失败,都删除临时文件
|
||||||
|
|||||||
Reference in New Issue
Block a user