fix: 优化游向逻辑
This commit is contained in:
parent
2e2c91f679
commit
8ce31d9c80
@ -1227,8 +1227,9 @@ public class FishDraftDataController {
|
||||
if (data.getDirection() == null || data.getDirection().isEmpty()) {
|
||||
addWarning(warnings, "direction");
|
||||
} else {
|
||||
String direction = fishImportService.resolveDirection(data.getDirection().trim(), importRow);
|
||||
if (direction == null) {
|
||||
String direction = fishImportService.resolveDirection(data.getStnm(),data.getDirection().trim(), importRow);
|
||||
if (direction == null||importRow.getWarnings().contains("direction")) {
|
||||
data.setDirection(direction);
|
||||
addWarning(warnings, "direction");
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ public interface IFishImportService {
|
||||
String resolveBaseCode(String code,String baseName);
|
||||
String resolveRiverCode(String code,String riverName);
|
||||
String resolveHbrvcdCode(String code,String riverName);
|
||||
String resolveDirection(String direction, FishImportResult.FishImportRow importRow);
|
||||
String resolveDirection(String stnm,String direction, FishImportResult.FishImportRow importRow);
|
||||
|
||||
String resolveIsfs(String value, FishImportResult.FishImportRow importRow);
|
||||
|
||||
|
||||
@ -342,12 +342,16 @@ public class FishImportServiceImpl implements IFishImportService {
|
||||
FishImportResult.FishImportRow importRow = new FishImportResult.FishImportRow(rowIndex);
|
||||
FishDraftData data = new FishDraftData();
|
||||
data.setId(UUID.randomUUID().toString());
|
||||
|
||||
String stnm=null;
|
||||
for (Map.Entry<Integer, String> entry : columnIndexMap.entrySet()) {
|
||||
Integer columnIndex = entry.getKey();
|
||||
String fieldName = entry.getValue();
|
||||
Cell cell = row.getCell(columnIndex);
|
||||
String cellValue = getCellStringValue(cell);
|
||||
|
||||
if("stnm".equals(fieldName)){
|
||||
stnm=cellValue;
|
||||
}
|
||||
try {
|
||||
switch (fieldName) {
|
||||
case "stationName":
|
||||
@ -509,7 +513,7 @@ public class FishImportServiceImpl implements IFishImportService {
|
||||
importRow.getWarnings().add(fieldName);
|
||||
data.setDirection(cellValue.trim());
|
||||
} else {
|
||||
String direction = resolveDirection(cellValue.trim(), importRow);
|
||||
String direction = resolveDirection(stnm,cellValue.trim(), importRow);
|
||||
data.setDirection(direction);
|
||||
}
|
||||
break;
|
||||
@ -1372,25 +1376,104 @@ public class FishImportServiceImpl implements IFishImportService {
|
||||
return facilityName;
|
||||
}
|
||||
|
||||
public String resolveDirection(String direction, FishImportResult.FishImportRow importRow) {
|
||||
|
||||
public String resolveDirection(String stnm, String direction, FishImportResult.FishImportRow importRow) {
|
||||
if (direction == null) {
|
||||
return null;
|
||||
}
|
||||
String lowerName = direction.toLowerCase().trim();
|
||||
|
||||
if (lowerName.contains("上行") && lowerName.contains("折返")) {
|
||||
// 独立判断四种方向类型(按优先级从高到低)
|
||||
boolean isUpReturn = lowerName.contains("上行") && lowerName.contains("折返");
|
||||
boolean isDownReturn = lowerName.contains("下行") && lowerName.contains("折返");
|
||||
boolean isUp = lowerName.contains("上行") && !isUpReturn; // 排除上行折返
|
||||
boolean isDown = lowerName.contains("下行") && !isDownReturn; // 排除下行折返
|
||||
|
||||
// 判断 direction 是否为字典编码
|
||||
boolean isDictCode = "0".equals(direction) || "1".equals(direction) ||
|
||||
"2".equals(direction) || "3".equals(direction);
|
||||
|
||||
// 如果 direction 本身是字典编码(0/1/2/3),直接识别
|
||||
if ("0".equals(direction)) {
|
||||
isUp = true;
|
||||
isUpReturn = false;
|
||||
} else if ("1".equals(direction)) {
|
||||
isDown = true;
|
||||
isDownReturn = false;
|
||||
} else if ("2".equals(direction)) {
|
||||
isUpReturn = true;
|
||||
isUp = false;
|
||||
} else if ("3".equals(direction)) {
|
||||
isDownReturn = true;
|
||||
isDown = false;
|
||||
}
|
||||
|
||||
// 根据设施名称校验方向(仅当 stnm 不为 null 时)
|
||||
if (StrUtil.isNotBlank(stnm)) {
|
||||
String facilityName = stnm.toLowerCase().trim();
|
||||
// 设施名称包含"上行"时,只允许上行或上行折返
|
||||
if (facilityName.contains("上行") && !isUp && !isUpReturn) {
|
||||
importRow.getWarnings().add("direction");
|
||||
// 如果是字典编码,返回对应的中文;否则返回原始数据
|
||||
return isDictCode ? getDirectionChinese(direction) : direction;
|
||||
}
|
||||
// 设施名称包含"下行"时,只允许下行或下行折返
|
||||
if (facilityName.contains("下行") && !isDown && !isDownReturn) {
|
||||
importRow.getWarnings().add("direction");
|
||||
// 如果是字典编码,返回对应的中文;否则返回原始数据
|
||||
return isDictCode ? getDirectionChinese(direction) : direction;
|
||||
}
|
||||
}
|
||||
|
||||
// 返回对应的字典编码
|
||||
if (isUpReturn) {
|
||||
return "2";
|
||||
} else if (lowerName.contains("下行") && lowerName.contains("折返")) {
|
||||
} else if (isDownReturn) {
|
||||
return "3";
|
||||
} else if (lowerName.contains("上行")) {
|
||||
} else if (isUp) {
|
||||
return "0";
|
||||
} else if (lowerName.contains("下行")) {
|
||||
} else if (isDown) {
|
||||
return "1";
|
||||
}
|
||||
|
||||
// 未匹配任何方向
|
||||
importRow.getWarnings().add("direction");
|
||||
return direction;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典编码返回对应的中文描述
|
||||
*/
|
||||
private String getDirectionChinese(String dictCode) {
|
||||
if ("0".equals(dictCode)) {
|
||||
return "上行";
|
||||
} else if ("1".equals(dictCode)) {
|
||||
return "下行";
|
||||
} else if ("2".equals(dictCode)) {
|
||||
return "上行折返";
|
||||
} else if ("3".equals(dictCode)) {
|
||||
return "下行折返";
|
||||
}
|
||||
return dictCode;
|
||||
}
|
||||
// public String resolveDirection(String stnm,String direction, FishImportResult.FishImportRow importRow) {
|
||||
// if (direction == null) {
|
||||
// return null;
|
||||
// }
|
||||
// String lowerName = direction.toLowerCase().trim();
|
||||
// if (lowerName.contains("上行") && lowerName.contains("折返")) {
|
||||
// return "2";
|
||||
// } else if (lowerName.contains("下行") && lowerName.contains("折返")) {
|
||||
// return "3";
|
||||
// } else if (lowerName.contains("上行")) {
|
||||
// return "0";
|
||||
// } else if (lowerName.contains("下行")) {
|
||||
// return "1";
|
||||
// }
|
||||
// importRow.getWarnings().add("direction");
|
||||
// return direction;
|
||||
// }
|
||||
|
||||
public String resolveIsfs(String value, FishImportResult.FishImportRow importRow) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
|
||||
@ -74,8 +74,10 @@ public class AdminAuthServiceImpl implements IAdminAuthService {
|
||||
|
||||
@Override
|
||||
public boolean isCurrentManagedAdmin() {
|
||||
// SysUser sysUser = userMapper.selectById(SecurityUtils.getUserId());
|
||||
String maxLevel = userMapper.getMaxLevel(SecurityUtils.getUserId());
|
||||
boolean adminRole = "1".equals(maxLevel);
|
||||
return adminRole||isManagedAdminUsername(SecurityUtils.getCurrentUsername());
|
||||
String currentUsername = SecurityUtils.getCurrentUsername();
|
||||
return adminRole||isManagedAdminUsername(currentUsername);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user