|
@@ -128,8 +128,9 @@ public class FileServiceImpl implements FileService {
|
|
|
if (!Files.exists(filePath)) {
|
|
|
Asserts.fail("该文件不存在");
|
|
|
}
|
|
|
- int count = filePath.getNameCount();
|
|
|
- if (count < 4) {
|
|
|
+ int powerPathCount = UploadConfig.getPowerPathCount();
|
|
|
+ int relativeCount = filePath.getNameCount() - powerPathCount;
|
|
|
+ if (relativeCount < 2) {
|
|
|
return true;
|
|
|
}
|
|
|
if (Files.isDirectory(filePath)) {
|
|
@@ -150,27 +151,30 @@ public class FileServiceImpl implements FileService {
|
|
|
Files.delete(filePath);
|
|
|
}
|
|
|
|
|
|
- if (count > 4) {
|
|
|
- String dirType = filePath.getName(4).toString();
|
|
|
+ if (relativeCount > 2) {
|
|
|
+ String dirType = filePath.getName(powerPathCount + 2).toString();
|
|
|
if (!dirType.equals(DirectoryEnum.TOWER_PIC.getName()) && !dirType.equals(DirectoryEnum.EARTH_WIRE_HARD_PIC.getName()) && !dirType.equals(DirectoryEnum.TEAM_CHECK_PIC.getName())) {
|
|
|
return true;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- String lineNameStr = filePath.getName(3).toString();
|
|
|
+ String provinceStr = filePath.getName(powerPathCount).toString();
|
|
|
+ String lineNameStr = filePath.getName(powerPathCount + 1).toString();
|
|
|
QueryWrapper<BLine> lineQueryWrapper = new QueryWrapper<>();
|
|
|
- lineQueryWrapper.lambda().eq(BLine::getName, lineNameStr);
|
|
|
+ lineQueryWrapper.lambda().eq(BLine::getProvince, provinceStr).eq(BLine::getName, lineNameStr);
|
|
|
BLine line = lineMapper.selectOne(lineQueryWrapper);
|
|
|
|
|
|
- QueryWrapper<BTower> towerQueryWrapper = new QueryWrapper<>();
|
|
|
- towerQueryWrapper.lambda().eq(BTower::getLineId, line.getId());
|
|
|
+ if (line != null) {
|
|
|
+ QueryWrapper<BTower> towerQueryWrapper = new QueryWrapper<>();
|
|
|
+ towerQueryWrapper.lambda().eq(BTower::getLineId, line.getId());
|
|
|
|
|
|
- if (count == 4) {
|
|
|
- lineMapper.deleteById(line.getId());
|
|
|
- towerMapper.delete(towerQueryWrapper);
|
|
|
- } else {
|
|
|
- List<BTower> towerList = towerMapper.selectList(towerQueryWrapper);
|
|
|
- towerService.setHasFile(towerList);
|
|
|
+ if (relativeCount == 2) {
|
|
|
+ lineMapper.deleteById(line.getId());
|
|
|
+ towerMapper.delete(towerQueryWrapper);
|
|
|
+ } else {
|
|
|
+ List<BTower> towerList = towerMapper.selectList(towerQueryWrapper);
|
|
|
+ towerService.setHasFile(towerList);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 后续清楚缓存处理
|