统一修改ruoyi->bms
This commit is contained in:
@@ -0,0 +1,144 @@
|
||||
package com.bms.price.util;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import com.bms.common.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* Parse Excel country cell with optional zone suffix, map labels to English abbreviations.
|
||||
*/
|
||||
public final class ZoneCodeAbbrevs
|
||||
{
|
||||
// fullwidth () and ASCII ()
|
||||
private static final Pattern ZONE_SUFFIX = Pattern.compile(
|
||||
"^(.+?)[\\(\\uFF08]([^\\)\\uFF09]+)[\\)\\uFF09]\\s*$");
|
||||
|
||||
private ZoneCodeAbbrevs()
|
||||
{
|
||||
}
|
||||
|
||||
public static final class CountryZoneParts
|
||||
{
|
||||
public final String countryName;
|
||||
public final String zoneLabel;
|
||||
|
||||
public CountryZoneParts(String countryName, String zoneLabel)
|
||||
{
|
||||
this.countryName = countryName;
|
||||
this.zoneLabel = zoneLabel;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Split country cell like Country(zoneLabel); no parenthesis -> zoneLabel null.
|
||||
*/
|
||||
public static CountryZoneParts splitCountryZone(String raw)
|
||||
{
|
||||
if (StringUtils.isEmpty(raw))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String n = raw.trim();
|
||||
int cut = n.length();
|
||||
int nl = n.indexOf('\n');
|
||||
if (nl >= 0 && nl < cut)
|
||||
{
|
||||
cut = nl;
|
||||
}
|
||||
int cr = n.indexOf('\r');
|
||||
if (cr >= 0 && cr < cut)
|
||||
{
|
||||
cut = cr;
|
||||
}
|
||||
n = n.substring(0, cut).trim();
|
||||
if (n.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Matcher m = ZONE_SUFFIX.matcher(n);
|
||||
if (m.matches())
|
||||
{
|
||||
String country = m.group(1).trim();
|
||||
String zone = m.group(2).trim();
|
||||
if (StringUtils.isEmpty(country))
|
||||
{
|
||||
return new CountryZoneParts(n, null);
|
||||
}
|
||||
return new CountryZoneParts(country, StringUtils.isEmpty(zone) ? null : zone);
|
||||
}
|
||||
return new CountryZoneParts(n, null);
|
||||
}
|
||||
|
||||
public static String toAbbrev(String raw)
|
||||
{
|
||||
if (StringUtils.isEmpty(raw))
|
||||
{
|
||||
return raw;
|
||||
}
|
||||
String key = raw.replace('\r', ' ').replace('\n', ' ').replaceAll("\\s+", " ").trim();
|
||||
switch (key)
|
||||
{
|
||||
case "1\u533a":
|
||||
return "Z1";
|
||||
case "2\u533a":
|
||||
return "Z2";
|
||||
case "3\u533a":
|
||||
return "Z3";
|
||||
case "4\u533a":
|
||||
return "Z4";
|
||||
case "5\u533a":
|
||||
return "Z5";
|
||||
case "Mondial Relay":
|
||||
return "MR";
|
||||
case "\u6c96\u7e04\u770c":
|
||||
return "OKN";
|
||||
case "\u5317\u7231\u5c14\u5170":
|
||||
return "NI";
|
||||
case "\u9ad8\u5730\u548c\u5c9b\u5c7f":
|
||||
return "HI";
|
||||
case "\u6d77\u5ce1\u7fa4\u5c9b(\u542b\u9521\u5229\u5c9b)":
|
||||
return "CI";
|
||||
case "\u9a6c\u6069\u5c9b":
|
||||
return "IM";
|
||||
case "Beckton":
|
||||
return "BEC";
|
||||
case "Bristol":
|
||||
return "BRS";
|
||||
case "Cambridge":
|
||||
return "CAM";
|
||||
case "Collier Wood":
|
||||
return "CW";
|
||||
case "Guernsey":
|
||||
return "GG";
|
||||
case "Isle of Man Bailiwick of Guernsey States of Jersey":
|
||||
return "IM_GG_JE";
|
||||
case "Lakeside":
|
||||
return "LKS";
|
||||
case "London Congestion Zone":
|
||||
return "LCZ";
|
||||
case "London Congestion Zone - Gemini":
|
||||
return "LCZ_GEM";
|
||||
case "London ULEZ - Wimbledon":
|
||||
return "ULEZ_WIM";
|
||||
case "Northern Ireland Isles of Scilly":
|
||||
return "NI_SCILLY";
|
||||
case "Old Kent Road Cargo Bikes":
|
||||
return "OKR_CB";
|
||||
case "Oxford":
|
||||
return "OXF";
|
||||
case "The Highlands Islands of Scotland":
|
||||
return "HIGHLANDS";
|
||||
default:
|
||||
if (key.matches("(?i)Z[1-9]\\d*"))
|
||||
{
|
||||
return key.toUpperCase(Locale.ROOT);
|
||||
}
|
||||
if (key.matches(".*[\\u4e00-\\u9fff].*"))
|
||||
{
|
||||
return key;
|
||||
}
|
||||
return key.replace(' ', '_').toUpperCase(Locale.ROOT).replaceAll("_+", "_");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user