fix: 优化过鱼数据导入判断
This commit is contained in:
parent
688c142e65
commit
8eea3cbb74
@ -59,7 +59,6 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
|
|
||||||
private static final Map<String, String> FISH_DICT_CACHE = new LinkedHashMap<>();
|
private static final Map<String, String> FISH_DICT_CACHE = new LinkedHashMap<>();
|
||||||
private static final Map<String, String> FPSS_BH_CACHE = new LinkedHashMap<>();
|
private static final Map<String, String> FPSS_BH_CACHE = new LinkedHashMap<>();
|
||||||
private static final Map<String, String> DIRECTION_DICT_CACHE = new LinkedHashMap<>();
|
|
||||||
private static final Map<String, String> ISFS_DICT_CACHE = new LinkedHashMap<>();
|
private static final Map<String, String> ISFS_DICT_CACHE = new LinkedHashMap<>();
|
||||||
|
|
||||||
private static final String DICT_CODE_FISH = "FISH_TYPE";
|
private static final String DICT_CODE_FISH = "FISH_TYPE";
|
||||||
@ -94,7 +93,7 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
EXCEL_COLUMN_INDEX_MAPPING.put(0, "baseName");
|
EXCEL_COLUMN_INDEX_MAPPING.put(0, "baseName");
|
||||||
EXCEL_COLUMN_INDEX_MAPPING.put(1, "stationName");
|
EXCEL_COLUMN_INDEX_MAPPING.put(1, "stationName");
|
||||||
EXCEL_COLUMN_INDEX_MAPPING.put(2, "fpname");
|
EXCEL_COLUMN_INDEX_MAPPING.put(2, "fpname");
|
||||||
EXCEL_COLUMN_INDEX_MAPPING.put(3, "tm");
|
EXCEL_COLUMN_INDEX_MAPPING.put(3, "strdt");
|
||||||
EXCEL_COLUMN_INDEX_MAPPING.put(4, "ftp");
|
EXCEL_COLUMN_INDEX_MAPPING.put(4, "ftp");
|
||||||
EXCEL_COLUMN_INDEX_MAPPING.put(5, "isfs");
|
EXCEL_COLUMN_INDEX_MAPPING.put(5, "isfs");
|
||||||
EXCEL_COLUMN_INDEX_MAPPING.put(6, "direction");
|
EXCEL_COLUMN_INDEX_MAPPING.put(6, "direction");
|
||||||
@ -184,7 +183,8 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
switch (fieldName) {
|
switch (fieldName) {
|
||||||
case "stationName":
|
case "stationName":
|
||||||
if (!StringUtils.hasText(cellValue)) {
|
if (!StringUtils.hasText(cellValue)) {
|
||||||
missingRequiredFields.add("电站名称");
|
importRow.getWarnings().add(fieldName);
|
||||||
|
data.setEngName(cellValue.trim());
|
||||||
} else {
|
} else {
|
||||||
String stcd = resolveStationCode(cellValue.trim());
|
String stcd = resolveStationCode(cellValue.trim());
|
||||||
if (stcd == null) {
|
if (stcd == null) {
|
||||||
@ -197,7 +197,9 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
break;
|
break;
|
||||||
case "baseName":
|
case "baseName":
|
||||||
if (!StringUtils.hasText(cellValue)) {
|
if (!StringUtils.hasText(cellValue)) {
|
||||||
missingRequiredFields.add("水电基地");
|
importRow.getWarnings().add(fieldName);
|
||||||
|
data.setBaseId(cellValue.trim());
|
||||||
|
data.setBaseName(cellValue.trim());
|
||||||
} else {
|
} else {
|
||||||
String baseId = resolveBaseCode(cellValue.trim());
|
String baseId = resolveBaseCode(cellValue.trim());
|
||||||
if (baseId == null) {
|
if (baseId == null) {
|
||||||
@ -215,6 +217,7 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
String rvcd = resolveRiverCode(cellValue.trim());
|
String rvcd = resolveRiverCode(cellValue.trim());
|
||||||
if (rvcd == null) {
|
if (rvcd == null) {
|
||||||
importRow.getWarnings().add(fieldName);
|
importRow.getWarnings().add(fieldName);
|
||||||
|
data.setRvcd(cellValue);
|
||||||
} else {
|
} else {
|
||||||
data.setRvcd(rvcd);
|
data.setRvcd(rvcd);
|
||||||
}
|
}
|
||||||
@ -222,18 +225,20 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
break;
|
break;
|
||||||
case "tm":
|
case "tm":
|
||||||
if (!StringUtils.hasText(cellValue)) {
|
if (!StringUtils.hasText(cellValue)) {
|
||||||
missingRequiredFields.add("过鱼时间");
|
importRow.getWarnings().add(fieldName);
|
||||||
} else {
|
} else {
|
||||||
Date tm = parseDate(cellValue);
|
Date tm = parseDate(cellValue);
|
||||||
if (tm == null) {
|
if (tm == null) {
|
||||||
importRow.getWarnings().add("过鱼时间格式错误: " + cellValue);
|
importRow.getWarnings().add(fieldName);
|
||||||
}
|
}
|
||||||
data.setTm(tm);
|
data.setTm(tm);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "ftp":
|
case "ftp":
|
||||||
if (!StringUtils.hasText(cellValue)) {
|
if (!StringUtils.hasText(cellValue)) {
|
||||||
missingRequiredFields.add("鱼种类");
|
importRow.getWarnings().add(fieldName);
|
||||||
|
data.setFtp(cellValue.trim());
|
||||||
|
data.setFtpName(cellValue.trim());
|
||||||
} else {
|
} else {
|
||||||
String stcd = resolveFishDictCode(cellValue.trim());
|
String stcd = resolveFishDictCode(cellValue.trim());
|
||||||
if (stcd == null) {
|
if (stcd == null) {
|
||||||
@ -251,7 +256,8 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
break;
|
break;
|
||||||
case "fcnt":
|
case "fcnt":
|
||||||
if (!StringUtils.hasText(cellValue)) {
|
if (!StringUtils.hasText(cellValue)) {
|
||||||
missingRequiredFields.add("过鱼数量");
|
importRow.getWarnings().add(fieldName);
|
||||||
|
data.setFcnt(parseInteger(cellValue));
|
||||||
} else {
|
} else {
|
||||||
Integer fcnt = parseInteger(cellValue);
|
Integer fcnt = parseInteger(cellValue);
|
||||||
if (fcnt == null) {
|
if (fcnt == null) {
|
||||||
@ -265,14 +271,23 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
data.setFwet(cellValue.trim());
|
data.setFwet(cellValue.trim());
|
||||||
break;
|
break;
|
||||||
case "strdt":
|
case "strdt":
|
||||||
data.setStrdt(parseDate(cellValue));
|
if (!StringUtils.hasText(cellValue)) {
|
||||||
|
importRow.getWarnings().add(fieldName);
|
||||||
|
} else {
|
||||||
|
Date strdt = parseDate(cellValue);
|
||||||
|
if (strdt == null) {
|
||||||
|
importRow.getWarnings().add(fieldName);
|
||||||
|
}
|
||||||
|
data.setStrdt(strdt);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case "enddt":
|
case "enddt":
|
||||||
data.setEnddt(parseDate(cellValue));
|
data.setEnddt(parseDate(cellValue));
|
||||||
break;
|
break;
|
||||||
case "direction":
|
case "direction":
|
||||||
if (!StringUtils.hasText(cellValue)) {
|
if (!StringUtils.hasText(cellValue)) {
|
||||||
missingRequiredFields.add("游向");
|
importRow.getWarnings().add(fieldName);
|
||||||
|
data.setDirection(cellValue.trim());
|
||||||
} else {
|
} else {
|
||||||
String direction = resolveDirection(cellValue.trim(), importRow);
|
String direction = resolveDirection(cellValue.trim(), importRow);
|
||||||
data.setDirection(direction);
|
data.setDirection(direction);
|
||||||
@ -507,28 +522,16 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
}
|
}
|
||||||
String lowerName = direction.toLowerCase().trim();
|
String lowerName = direction.toLowerCase().trim();
|
||||||
|
|
||||||
if (!DIRECTION_DICT_CACHE.isEmpty()) {
|
|
||||||
if (DIRECTION_DICT_CACHE.containsKey(lowerName)) {
|
|
||||||
return DIRECTION_DICT_CACHE.get(lowerName);
|
|
||||||
}
|
|
||||||
for (Map.Entry<String, String> entry : DIRECTION_DICT_CACHE.entrySet()) {
|
|
||||||
if (entry.getKey().contains(lowerName) || lowerName.contains(entry.getKey())) {
|
|
||||||
return entry.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lowerName.contains("上行") && lowerName.contains("折返")) {
|
if (lowerName.contains("上行") && lowerName.contains("折返")) {
|
||||||
return "上行折返";
|
return "03";
|
||||||
} else if (lowerName.contains("下行") && lowerName.contains("折返")) {
|
} else if (lowerName.contains("下行") && lowerName.contains("折返")) {
|
||||||
return "下行折返";
|
return "04";
|
||||||
} else if (lowerName.contains("上行")) {
|
} else if (lowerName.contains("上行")) {
|
||||||
return "上行";
|
return "01";
|
||||||
} else if (lowerName.contains("下行")) {
|
} else if (lowerName.contains("下行")) {
|
||||||
return "下行";
|
return "02";
|
||||||
}
|
}
|
||||||
|
importRow.getWarnings().add("direction");
|
||||||
importRow.getWarnings().add("无法识别的游向: " + direction + ",请手动选择");
|
|
||||||
return direction;
|
return direction;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -537,25 +540,12 @@ public class FishImportServiceImpl implements IFishImportService {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
String lowerName = value.toLowerCase().trim();
|
String lowerName = value.toLowerCase().trim();
|
||||||
|
if (lowerName.equals("是")) {
|
||||||
if (!ISFS_DICT_CACHE.isEmpty()) {
|
return "1";
|
||||||
if (ISFS_DICT_CACHE.containsKey(lowerName)) {
|
} else if (lowerName.equals("否") ) {
|
||||||
return ISFS_DICT_CACHE.get(lowerName);
|
return "0";
|
||||||
}
|
}
|
||||||
for (Map.Entry<String, String> entry : ISFS_DICT_CACHE.entrySet()) {
|
importRow.getWarnings().add("isfs");
|
||||||
if (entry.getKey().contains(lowerName) || lowerName.contains(entry.getKey())) {
|
|
||||||
return entry.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lowerName.equals("1") || lowerName.equals("是") || lowerName.equals("yes") || lowerName.equals("true")) {
|
|
||||||
return "是";
|
|
||||||
} else if (lowerName.equals("0") || lowerName.equals("否") || lowerName.equals("no") || lowerName.equals("false")) {
|
|
||||||
return "否";
|
|
||||||
}
|
|
||||||
|
|
||||||
importRow.getWarnings().add("无法识别的【是否鱼苗】值: " + value + ",将默认设置为【否】");
|
|
||||||
return "否";
|
return "否";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user