fix bug
This commit is contained in:
+10
-10
@@ -53,13 +53,13 @@ public class PortTerminalExcel implements Serializable {
|
||||
@ExcelIgnore
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty("*编码")
|
||||
@ExcelProperty("编码")
|
||||
private String code;
|
||||
|
||||
@ExcelProperty("*港口/码头名称")
|
||||
@ExcelProperty("港口/码头名称")
|
||||
private String name;
|
||||
|
||||
@ExcelProperty("*类型")
|
||||
@ExcelProperty("类型")
|
||||
private String category;
|
||||
|
||||
@ExcelProperty("上级港口")
|
||||
@@ -68,13 +68,13 @@ public class PortTerminalExcel implements Serializable {
|
||||
@ExcelProperty("上级港口编码")
|
||||
private String parentCode;
|
||||
|
||||
@ExcelProperty("*国家")
|
||||
@ExcelProperty("国家")
|
||||
private String country;
|
||||
|
||||
@ExcelProperty("*城市")
|
||||
@ExcelProperty("城市")
|
||||
private String city;
|
||||
|
||||
@ExcelProperty("*区县")
|
||||
@ExcelProperty("区县")
|
||||
private String districtName;
|
||||
|
||||
@ExcelProperty("行政区划编码")
|
||||
@@ -83,18 +83,18 @@ public class PortTerminalExcel implements Serializable {
|
||||
@ExcelProperty("详细地址")
|
||||
private String detailAddress;
|
||||
|
||||
@ExcelProperty("*经度")
|
||||
@ExcelProperty("经度")
|
||||
@NumberFormat("0.000000")
|
||||
private BigDecimal longitude;
|
||||
|
||||
@ExcelProperty("*纬度")
|
||||
@ExcelProperty("纬度")
|
||||
@NumberFormat("0.000000")
|
||||
private BigDecimal latitude;
|
||||
|
||||
@ExcelIgnore
|
||||
@ExcelProperty("数据来源")
|
||||
private String dataSource;
|
||||
|
||||
@ExcelIgnore
|
||||
@ExcelProperty("启停状态")
|
||||
private String statusName;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
|
||||
+4
-4
@@ -142,7 +142,7 @@ public class AirportMasterServiceImpl extends BaseServiceImpl<AirportMasterMappe
|
||||
normalizeImportAirportMaster(airportMaster);
|
||||
List<String> validationErrors = validateImportAirportMaster(airportMaster, iataCodeCountMap, icaoCodeCountMap);
|
||||
if (Func.isNotEmpty(validationErrors)) {
|
||||
excel.setErrorMessage(formatImportErrorMessage(index + 2, validationErrors));
|
||||
excel.setErrorMessage(formatImportErrorMessage(validationErrors));
|
||||
errorList.add(excel);
|
||||
continue;
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public class AirportMasterServiceImpl extends BaseServiceImpl<AirportMasterMappe
|
||||
airportMasterList.add(airportMaster);
|
||||
} catch (Exception exception) {
|
||||
String message = exception instanceof ServiceException ? exception.getMessage() : "导入失败";
|
||||
excel.setErrorMessage(formatImportErrorMessage(index + 2, List.of(message)));
|
||||
excel.setErrorMessage(formatImportErrorMessage(List.of(message)));
|
||||
errorList.add(excel);
|
||||
}
|
||||
}
|
||||
@@ -295,8 +295,8 @@ public class AirportMasterServiceImpl extends BaseServiceImpl<AirportMasterMappe
|
||||
}
|
||||
}
|
||||
|
||||
private String formatImportErrorMessage(int rowNumber, List<String> validationErrors) {
|
||||
StringBuilder errorMessage = new StringBuilder("第").append(rowNumber).append("行:");
|
||||
private String formatImportErrorMessage(List<String> validationErrors) {
|
||||
StringBuilder errorMessage = new StringBuilder();
|
||||
for (int index = 0; index < validationErrors.size(); index++) {
|
||||
if (index > 0) {
|
||||
errorMessage.append(System.lineSeparator());
|
||||
|
||||
+1
-1
@@ -149,7 +149,7 @@ public class CargoTypeServiceImpl extends BaseServiceImpl<CargoTypeMapper, Cargo
|
||||
} catch (Exception exception) {
|
||||
String message = exception instanceof ServiceException ? exception.getMessage() : "导入失败";
|
||||
excel.setErrorMessage(message);
|
||||
failureList.add(toImportFailureExcel(excel, "第" + (index + 2) + "行:" + message));
|
||||
failureList.add(toImportFailureExcel(excel, message));
|
||||
}
|
||||
}
|
||||
return failureList;
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class FeeItemServiceImpl extends BaseServiceImpl<FeeItemMapper, FeeItem>
|
||||
save(feeItem);
|
||||
} catch (Exception exception) {
|
||||
String message = exception instanceof ServiceException ? exception.getMessage() : "导入失败";
|
||||
failureList.add(toImportFailureExcel(excel, "第" + (index + 2) + "行:" + message));
|
||||
failureList.add(toImportFailureExcel(excel, message));
|
||||
}
|
||||
}
|
||||
return failureList;
|
||||
|
||||
+4
-4
@@ -149,7 +149,7 @@ public class PortTerminalServiceImpl extends BaseServiceImpl<PortTerminalMapper,
|
||||
normalizeImportPortTerminal(portTerminal);
|
||||
List<String> validationErrors = validateImportPortTerminal(portTerminal, codeCountMap);
|
||||
if (Func.isNotEmpty(validationErrors)) {
|
||||
excel.setErrorMessage(formatImportErrorMessage(index + 2, validationErrors));
|
||||
excel.setErrorMessage(formatImportErrorMessage(validationErrors));
|
||||
errorList.add(excel);
|
||||
continue;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public class PortTerminalServiceImpl extends BaseServiceImpl<PortTerminalMapper,
|
||||
portTerminalList.add(portTerminal);
|
||||
} catch (Exception exception) {
|
||||
String message = exception instanceof ServiceException ? exception.getMessage() : "导入失败";
|
||||
excel.setErrorMessage(formatImportErrorMessage(index + 2, List.of(message)));
|
||||
excel.setErrorMessage(formatImportErrorMessage(List.of(message)));
|
||||
errorList.add(excel);
|
||||
}
|
||||
}
|
||||
@@ -175,8 +175,8 @@ public class PortTerminalServiceImpl extends BaseServiceImpl<PortTerminalMapper,
|
||||
return errorList;
|
||||
}
|
||||
|
||||
private String formatImportErrorMessage(int rowNumber, List<String> validationErrors) {
|
||||
StringBuilder errorMessage = new StringBuilder("第").append(rowNumber).append("行:");
|
||||
private String formatImportErrorMessage(List<String> validationErrors) {
|
||||
StringBuilder errorMessage = new StringBuilder();
|
||||
for (int index = 0; index < validationErrors.size(); index++) {
|
||||
if (index > 0) {
|
||||
errorMessage.append(System.lineSeparator());
|
||||
|
||||
+4
-4
@@ -148,7 +148,7 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
normalizeImportRailwayStation(railwayStation);
|
||||
validationErrors.addAll(validateImportRailwayStation(railwayStation, tmisCodeCountMap, telegraphCodeCountMap));
|
||||
if (Func.isNotEmpty(validationErrors)) {
|
||||
excel.setErrorMessage(formatImportErrorMessage(index + 2, validationErrors));
|
||||
excel.setErrorMessage(formatImportErrorMessage(validationErrors));
|
||||
errorList.add(excel);
|
||||
continue;
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
railwayStationList.add(railwayStation);
|
||||
} catch (Exception exception) {
|
||||
String message = exception instanceof ServiceException ? exception.getMessage() : "导入失败";
|
||||
excel.setErrorMessage(formatImportErrorMessage(index + 2, List.of(message)));
|
||||
excel.setErrorMessage(formatImportErrorMessage(List.of(message)));
|
||||
errorList.add(excel);
|
||||
}
|
||||
}
|
||||
@@ -312,8 +312,8 @@ public class RailwayStationServiceImpl extends BaseServiceImpl<RailwayStationMap
|
||||
}
|
||||
}
|
||||
|
||||
private String formatImportErrorMessage(int rowNumber, List<String> validationErrors) {
|
||||
StringBuilder errorMessage = new StringBuilder("第").append(rowNumber).append("行:");
|
||||
private String formatImportErrorMessage(List<String> validationErrors) {
|
||||
StringBuilder errorMessage = new StringBuilder();
|
||||
for (int index = 0; index < validationErrors.size(); index++) {
|
||||
if (index > 0) {
|
||||
errorMessage.append(System.lineSeparator());
|
||||
|
||||
+17
-5
@@ -106,7 +106,11 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
region.setVillageCode(code);
|
||||
region.setVillageName(name);
|
||||
}
|
||||
return StringUtil.isNotBlank(region.getOriginalCode()) ? this.updateById(region) : this.save(region);
|
||||
boolean result = StringUtil.isNotBlank(region.getOriginalCode()) ? this.updateById(region) : this.save(region);
|
||||
if (result) {
|
||||
clearLazyTree();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void validateUniqueCode(Region region) {
|
||||
@@ -130,7 +134,11 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
if (cnt > 0L) {
|
||||
throw new ServiceException("请先删除子节点!");
|
||||
}
|
||||
return removeById(id);
|
||||
boolean result = removeById(id);
|
||||
if (result) {
|
||||
clearLazyTree();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -140,7 +148,7 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> lazyTree(String parentCode, Map<String, Object> param) {
|
||||
return baseMapper.lazyTree(parentCode, param);
|
||||
return getLazyTree(parentCode, param, () -> baseMapper.lazyTree(parentCode, param));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,20 +157,24 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
|
||||
throw new ServiceException("导入数据不能为空");
|
||||
}
|
||||
List<RegionExcel> errorList = new ArrayList<>();
|
||||
boolean cacheChanged = false;
|
||||
for (int index = 0; index < data.size(); index++) {
|
||||
RegionExcel excel = data.get(index);
|
||||
try {
|
||||
Region region = BeanUtil.copyProperties(excel, Region.class);
|
||||
if (Boolean.TRUE.equals(isCovered)) {
|
||||
this.saveOrUpdate(region);
|
||||
cacheChanged = this.saveOrUpdate(region) || cacheChanged;
|
||||
} else {
|
||||
this.save(region);
|
||||
cacheChanged = this.save(region) || cacheChanged;
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
excel.setErrorMessage(exception.getMessage());
|
||||
errorList.add(excel);
|
||||
}
|
||||
}
|
||||
if (cacheChanged) {
|
||||
clearLazyTree();
|
||||
}
|
||||
return errorList;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user