|
@@ -59,6 +59,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.function.Predicate;
|
|
|
+import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -125,6 +126,11 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
*/
|
|
|
private static final String FILE_ADDR_FREFIX = "http://";
|
|
|
|
|
|
+ /**
|
|
|
+ * 风机编号正则
|
|
|
+ */
|
|
|
+ private static final String ENGINE_CODE_PATTEN = IdPrefixEnum.WIND_EILL_NUMBER.getCode() + "\\d{3," + IdGeneratorUtil.DEC_INIT_LENGTH + "}";
|
|
|
+
|
|
|
|
|
|
private static ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
@@ -574,7 +580,11 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
fileAddr = fileAddr.replace(replaceStr, AnalysisConstants.PATH_SEPARATOR);
|
|
|
}
|
|
|
//删除文件后缀名
|
|
|
- return fileAddr.substring(0, fileAddr.lastIndexOf('.'));
|
|
|
+ fileAddr = fileAddr.substring(0, fileAddr.lastIndexOf('.'));
|
|
|
+ //中文名字不一样机型编号一样
|
|
|
+ Matcher matcher = Pattern.compile(ENGINE_CODE_PATTEN).matcher(fileAddr);
|
|
|
+ String engineCode = matcher.find() ? matcher.group() : "";
|
|
|
+ return StringUtils.isNotBlank(engineCode) ? engineCode : fileAddr;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -589,8 +599,7 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
}
|
|
|
|
|
|
private static boolean retainEngineCodeFile(String fileAddr){
|
|
|
- String patternRule = IdPrefixEnum.WIND_EILL_NUMBER.getCode() + "\\d{3," + IdGeneratorUtil.DEC_INIT_LENGTH + "}";
|
|
|
- Pattern pattern = Pattern.compile(patternRule);
|
|
|
+ Pattern pattern = Pattern.compile(ENGINE_CODE_PATTEN);
|
|
|
String fileName = fileAddr.substring(fileAddr.lastIndexOf(AnalysisConstants.PATH_SEPARATOR) + 1);
|
|
|
return pattern.matcher(fileName).find();
|
|
|
}
|
|
@@ -921,6 +930,9 @@ public class AnalysisServiceImpl implements AnalysisService {
|
|
|
// list.add("123.html");
|
|
|
// list = list.stream().filter(item -> !item.endsWith(".png")).collect(Collectors.toList());
|
|
|
// System.out.println(list);
|
|
|
+ Matcher matcher = Pattern.compile(ENGINE_CODE_PATTEN).matcher("1231231231/12312/WEM00001");
|
|
|
+ String result = matcher.find() ? matcher.group() : "";
|
|
|
+ System.out.println(result);
|
|
|
}
|
|
|
|
|
|
}
|