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