📄 cityutil.java
字号:
package com.intohotel.util;
import java.util.Iterator;
import java.util.Map;
import com.intohotel.entity.AirCityDetail;
import com.intohotel.entity.City;
import com.intohotel.service.ICityService;
public class CityUtil {
private ICityService cityService;
public void setCityService(ICityService cityService) {
this.cityService = cityService;
}
@SuppressWarnings("unchecked")
public String getCityName(String cityCode){
String cityName = CityMap.getCityName(cityCode);
if(StringUtil.isEmpty(cityName) && StringUtil.isNotEmpty(cityCode))
{
try {
Iterator<Object> it = cityService.find("from City as obj where obj.cityCode='"+cityCode+"'").iterator();
if(it.hasNext())
{
cityName = ((City)it.next()).getCityName();
// CityThreeCodeMap.addCityName(threeCode, cityName);
}
if(StringUtil.isNotEmpty(cityName))
{
CityMap.addCity(cityCode,cityName);
}
} catch (Exception e) {
e.printStackTrace();
return cityCode;
}
}
return cityName ;
}
@SuppressWarnings("unchecked")
public String getProvinceName(String provinceCode){
String provinceName = provinceCode;//CityThreeCodeMap.getCityName(threeCode);
if(StringUtil.isNotEmpty(provinceCode))
{
try {
Iterator<Object> it = cityService.find("from Province as obj where obj.provinceCode='"+provinceCode+"'").iterator();
if(it.hasNext())
{
provinceName = ((AirCityDetail)it.next()).getReplace();
// CityThreeCodeMap.addCityName(threeCode, cityName);
}
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
return provinceName ;
}
@SuppressWarnings("unchecked")
public String getCountryName(String countryCode){
String countryName = countryCode;//CityThreeCodeMap.getCityName(threeCode);
if(StringUtil.isNotEmpty(countryCode))
{
try {
Iterator<Object> it = cityService.find("from Country as obj where obj.countryCode='"+countryCode+"'").iterator();
if(it.hasNext())
{
countryName = ((AirCityDetail)it.next()).getReplace();
// CityThreeCodeMap.addCityName(threeCode, cityName);
}
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
return countryName ;
}
/**
* 过滤酒店名称关键字
* @param keyWord
* @return
*/
public static String filterHotelNameKeyWord(String keyWord)
{
String wholeWord = keyWord ;
if(StringUtil.isEmpty(wholeWord) || wholeWord.length() <=2)
{
return keyWord ;
}
int index = -1 ;
String cityName = "";
Map<String,String> cityMap = CityMap.getCityMap();
for(Map.Entry<String, String> entry : cityMap.entrySet()){
cityName = entry.getValue();
index = wholeWord.indexOf(cityName+"市");
if(index >= 0)
{
if(StringUtil.isNotEmpty(wholeWord.replaceAll(cityName+"市", "")))
wholeWord = wholeWord.replaceAll(cityName+"市", "");
break ;
}
index = wholeWord.indexOf(cityName);
if(index >= 0)
{
if(StringUtil.isNotEmpty(wholeWord.replaceAll(cityName, "")))
wholeWord = wholeWord.replaceAll(cityName, "");
break ;
}
}
index = wholeWord.indexOf("宾馆");
if(index > 0){
if(StringUtil.isNotEmpty(wholeWord.replaceAll("宾馆", "")))
return wholeWord.replaceAll("宾馆", "");
}
index = wholeWord.indexOf("国际大酒店");
if(index > 0){
if(StringUtil.isNotEmpty(wholeWord.replaceAll("国际大酒店", "")))
return wholeWord.replaceAll("国际大酒店", "");
}
index = wholeWord.indexOf("国际酒店");
if(index > 0){
if(StringUtil.isNotEmpty(wholeWord.replaceAll("国际酒店", "")))
return wholeWord.replaceAll("国际酒店", "");
}
index = wholeWord.indexOf("大酒店");
if(index > 0){
if(StringUtil.isNotEmpty(wholeWord.replaceAll("大酒店", "")))
return wholeWord.replaceAll("大酒店", "");
}
index = wholeWord.indexOf("酒店");
if(index > 0){
if(StringUtil.isNotEmpty(wholeWord.replaceAll("酒店", "")))
return wholeWord.replaceAll("酒店", "");
}
index = wholeWord.indexOf("连锁");
if(index > 0){
if(StringUtil.isNotEmpty(wholeWord.replaceAll("连锁", "")))
return wholeWord.replaceAll("连锁", "");
}
index = wholeWord.indexOf("旅店");
if(index > 0){
if(StringUtil.isNotEmpty(wholeWord.replaceAll("旅店", "")))
return wholeWord.replaceAll("旅店", "");
}
return wholeWord ;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -