修改代码字符编码
This commit is contained in:
+3
-3
@@ -28,7 +28,7 @@ public class ContactController {
|
||||
private SmsService smsService;
|
||||
private static List<String> NOTICE_MOBILES = new ArrayList<String>();
|
||||
static {
|
||||
NOTICE_MOBILES.add("13916992399"); // 蒋
|
||||
NOTICE_MOBILES.add("13916992399"); // 蒋
|
||||
|
||||
}
|
||||
public Object indexAction(BaseModel model){
|
||||
@@ -53,14 +53,14 @@ public class ContactController {
|
||||
contact.setSource("FangJia China");
|
||||
customerConsultService.save(contact);
|
||||
data.put("success", Boolean.TRUE);
|
||||
String smsContent ="【房价网】FangJia China收到留言:\n " + "联系人:" + contact.getName() + " \n邮箱:" + contact.getEmail() + " \n联系电话:" +contact.getPhone()+"\n";
|
||||
String smsContent ="【房价网】FangJia China收到留言:\n " + "联系人:" + contact.getName() + " \n邮箱:" + contact.getEmail() + " \n联系电话:" +contact.getPhone()+"\n";
|
||||
try {
|
||||
for(String mobile:NOTICE_MOBILES){
|
||||
smsService.send(mobile, smsContent);
|
||||
}
|
||||
} catch (SmsException e) {
|
||||
e.printStackTrace();
|
||||
logger.error("房价网留言短信发送失败:", smsContent);
|
||||
logger.error("房价网留言短信发送失败:", smsContent);
|
||||
}
|
||||
return jsonModel;
|
||||
}
|
||||
|
||||
+28
-28
@@ -124,33 +124,33 @@ public class Controller {
|
||||
}
|
||||
|
||||
int avgPrice;
|
||||
if (StringUtils.isBlank(name)) {// 没找到当前小区
|
||||
if (StringUtils.isBlank(name)) {// 没找到当前小区
|
||||
avgPrice = districtStatService.findLatestDistrictAvgPrice(city,
|
||||
null, null, null);
|
||||
data.put("msg", "在" + city + "未匹配到该住宅小区!" + city + "市小区均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
data.put("msg", "在" + city + "未匹配到该住宅小区!" + city + "市小区均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
return model;
|
||||
}
|
||||
if (keywords.equals(name) || keywords.equals(address)
|
||||
|| isAlias(keywords, alias)) {// 关键字精确匹配到地址或小区
|
||||
|| isAlias(keywords, alias)) {// 关键字精确匹配到地址或小区
|
||||
avgPrice = districtStatService.findLatestDistrictAvgPrice(city,
|
||||
region, null, name);// 根据小区信息查询价格
|
||||
region, null, name);// 根据小区信息查询价格
|
||||
if (avgPrice == 0 && alias != null && !alias.isEmpty()) {
|
||||
for (String alia : alias) {
|
||||
avgPrice = districtStatService.findLatestDistrictAvgPrice(
|
||||
city, region, null, alia);// 根据小区信息查询价格
|
||||
city, region, null, alia);// 根据小区信息查询价格
|
||||
if (avgPrice != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (avgPrice != 0) {// 查到小区价格
|
||||
data.put("msg", "均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
if (avgPrice != 0) {// 查到小区价格
|
||||
data.put("msg", "均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
return model;
|
||||
}
|
||||
avgPrice = districtStatService.findLatestDistrictAvgPrice(city,
|
||||
region, null, name, 1000);// 查找该小区一公里以内小区的均价
|
||||
region, null, name, 1000);// 查找该小区一公里以内小区的均价
|
||||
if (avgPrice != 0) {
|
||||
data.put("msg", "暂无该小区均价,该小区周边楼盘均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
data.put("msg", "暂无该小区均价,该小区周边楼盘均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
return model;
|
||||
}
|
||||
if (StringUtils.isBlank(block)) {
|
||||
@@ -160,35 +160,35 @@ public class Controller {
|
||||
block = districts.get(0).getBlock();
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(region) && StringUtils.isNotBlank(block)) {// 查询板块均价
|
||||
if (StringUtils.isNotBlank(region) && StringUtils.isNotBlank(block)) {// 查询板块均价
|
||||
avgPrice = districtStatService.findLatestDistrictAvgPrice(city,
|
||||
region, block, null);// 查询板块价格
|
||||
region, block, null);// 查询板块价格
|
||||
}
|
||||
if (avgPrice != 0) {
|
||||
data.put("msg", "暂无该小区均价,所在板块(" + block + ")的均价为:<em>" + avgPrice + "</em>元/㎡");
|
||||
data.put("msg", "暂无该小区均价,所在板块(" + block + ")的均价为:<em>" + avgPrice + "</em>元/㎡");
|
||||
return model;
|
||||
}
|
||||
if (StringUtils.isNotBlank(region)) {
|
||||
avgPrice = districtStatService.findLatestDistrictAvgPrice(city,
|
||||
region, null, null);// 查询区域价格
|
||||
region, null, null);// 查询区域价格
|
||||
}
|
||||
if (avgPrice != 0) {
|
||||
data.put("msg", "暂无该小区均价,所在区域(" + region + ")的均价为:<em>"
|
||||
+ avgPrice + "</em>元/㎡");
|
||||
data.put("msg", "暂无该小区均价,所在区域(" + region + ")的均价为:<em>"
|
||||
+ avgPrice + "</em>元/㎡");
|
||||
return model;
|
||||
}
|
||||
avgPrice = districtStatService.findLatestDistrictAvgPrice(city,
|
||||
null, null, null);
|
||||
data.put("msg", "暂无该小区均价," + city + "市小区均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
data.put("msg", "暂无该小区均价," + city + "市小区均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
|
||||
} else {
|
||||
avgPrice = districtStatService.findLatestDistrictAvgPrice(city,
|
||||
region, null, name);// 根据小区信息查询价格
|
||||
region, null, name);// 根据小区信息查询价格
|
||||
if (avgPrice != 0) {
|
||||
data.put("msg", "您要找的是不是\"<em>" + name + "\"</em>,均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
data.put("msg", "您要找的是不是\"<em>" + name + "\"</em>,均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
return model;
|
||||
}
|
||||
List<District> districts = districtService.findByKey(city, region, name, "district");// 查出别名
|
||||
List<District> districts = districtService.findByKey(city, region, name, "district");// 查出别名
|
||||
if (!districts.isEmpty()) {
|
||||
block = districts.get(0).getBlock();
|
||||
alias = districts.get(0).getAlias();
|
||||
@@ -196,19 +196,19 @@ public class Controller {
|
||||
if (alias != null && !alias.isEmpty()) {
|
||||
for (String alia : alias) {
|
||||
avgPrice = districtStatService.findLatestDistrictAvgPrice(
|
||||
city, region, null, alia);// 根据小区信息查询价格
|
||||
city, region, null, alia);// 根据小区信息查询价格
|
||||
if (avgPrice != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (avgPrice != 0) {
|
||||
data.put("msg", "您要找的是不是\"<em>" + name + "\"</em>,均价:<em>"
|
||||
+ avgPrice + "</em>元/㎡");
|
||||
data.put("msg", "您要找的是不是\"<em>" + name + "\"</em>,均价:<em>"
|
||||
+ avgPrice + "</em>元/㎡");
|
||||
return model;
|
||||
}
|
||||
avgPrice = districtStatService.findLatestDistrictAvgPrice(city, null, null, null);
|
||||
data.put("msg", "在" + city + "未匹配到该住宅小区!" + city + "市小区均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
data.put("msg", "在" + city + "未匹配到该住宅小区!" + city + "市小区均价:<em>" + avgPrice + "</em>元/㎡");
|
||||
}
|
||||
|
||||
return model;
|
||||
@@ -288,9 +288,9 @@ public class Controller {
|
||||
}
|
||||
String houseNum = evaluation.getHouseNum() == null ? "xxx" : evaluation.getHouseNum().toString();
|
||||
if (StringUtils.isNotBlank(d.getAddress())) {
|
||||
address = d.getAddress() + " " + houseNum + "号***室";
|
||||
address = d.getAddress() + " " + houseNum + "号***室";
|
||||
} else {
|
||||
address = d.getName() + " " + houseNum + "号***室";
|
||||
address = d.getName() + " " + houseNum + "号***室";
|
||||
}
|
||||
eva.put("address", address);
|
||||
eva.put("id", evaluation.getId());
|
||||
@@ -343,7 +343,7 @@ public class Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* 小区搜索的自动完成功能(调用goojia-auto实现)
|
||||
* 小区搜索的自动完成功能(调用goojia-auto实现)
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
@@ -365,7 +365,7 @@ public class Controller {
|
||||
return model;
|
||||
}
|
||||
|
||||
// 将汉字转换为全拼
|
||||
// 将汉字转换为全拼
|
||||
public String getPingYin(String src) {
|
||||
char[] t1 = src.toCharArray();
|
||||
String[] t2 = new String[t1.length];
|
||||
@@ -377,7 +377,7 @@ public class Controller {
|
||||
int t0 = t1.length;
|
||||
try {
|
||||
for (int i = 0; i < t0; i++) {
|
||||
// 判断是否为汉字字符
|
||||
// 判断是否为汉字字符
|
||||
if (java.lang.Character.toString(t1[i]).matches(
|
||||
"[\\u4E00-\\u9FA5]+")) {
|
||||
t2 = PinyinHelper.toHanyuPinyinStringArray(t1[i], t3);
|
||||
|
||||
+20
-20
@@ -17,7 +17,7 @@ public class CosineSimilarAlgorithm {
|
||||
if (doc1.trim().length() > 0 && doc2.trim().length() > 0) {
|
||||
Map<Integer, int[]> AlgorithmMap = new HashMap<Integer, int[]>();
|
||||
|
||||
//将两个字符串中的中文字符以及出现的总数封装到,AlgorithmMap中
|
||||
//将两个字符串中的中文字符以及出现的总数封装到,AlgorithmMap中
|
||||
for (int i = 0; i < doc1.length(); i++) {
|
||||
char d1 = doc1.charAt(i);
|
||||
if(isHanZi(d1)){
|
||||
@@ -76,26 +76,26 @@ public class CosineSimilarAlgorithm {
|
||||
}
|
||||
|
||||
public static boolean isHanZi(char ch) {
|
||||
// 判断是否汉字
|
||||
// 判断是否汉字
|
||||
return (ch >= 0x4E00 && ch <= 0x9FA5);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据输入的Unicode字符,获取它的GB2312编码或者ascii编码,
|
||||
* 根据输入的Unicode字符,获取它的GB2312编码或者ascii编码,
|
||||
*
|
||||
* @param ch
|
||||
* 输入的GB2312中文字符或者ASCII字符(128个)
|
||||
* @return ch在GB2312中的位置,-1表示该字符不认识
|
||||
* 输入的GB2312中文字符或者ASCII字符(128个)
|
||||
* @return ch在GB2312中的位置,-1表示该字符不认识
|
||||
*/
|
||||
public static short getGB2312Id(char ch) {
|
||||
try {
|
||||
byte[] buffer = Character.toString(ch).getBytes("GB2312");
|
||||
if (buffer.length != 2) {
|
||||
// 正常情况下buffer应该是两个字节,否则说明ch不属于GB2312编码,故返回'?',此时说明不认识该字符
|
||||
// 正常情况下buffer应该是两个字节,否则说明ch不属于GB2312编码,故返回'?',此时说明不认识该字符
|
||||
return -1;
|
||||
}
|
||||
int b0 = (int) (buffer[0] & 0x0FF) - 161; // 编码从A1开始,因此减去0xA1=161
|
||||
int b1 = (int) (buffer[1] & 0x0FF) - 161; // 第一个字符和最后一个字符没有汉字,因此每个区只收16*6-2=94个汉字
|
||||
int b0 = (int) (buffer[0] & 0x0FF) - 161; // 编码从A1开始,因此减去0xA1=161
|
||||
int b1 = (int) (buffer[1] & 0x0FF) - 161; // 第一个字符和最后一个字符没有汉字,因此每个区只收16*6-2=94个汉字
|
||||
return (short) (b0 * 94 + b1);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
@@ -107,14 +107,14 @@ public class CosineSimilarAlgorithm {
|
||||
|
||||
|
||||
private static int compare(String str, String target) {
|
||||
int[][] d; // 矩阵
|
||||
int[][] d; // 矩阵
|
||||
int n = str.length();
|
||||
int m = target.length();
|
||||
int i; // 遍历str的
|
||||
int j; // 遍历target的
|
||||
char ch1; // str的
|
||||
char ch2; // target的
|
||||
int temp; // 记录相同字符,在某个矩阵位置值的增量,不是0就是1
|
||||
int i; // 遍历str的
|
||||
int j; // 遍历target的
|
||||
char ch1; // str的
|
||||
char ch2; // target的
|
||||
int temp; // 记录相同字符,在某个矩阵位置值的增量,不是0就是1
|
||||
if (n == 0) {
|
||||
return m;
|
||||
}
|
||||
@@ -122,16 +122,16 @@ public class CosineSimilarAlgorithm {
|
||||
return n;
|
||||
}
|
||||
d = new int[n + 1][m + 1];
|
||||
for (i = 0; i <= n; i++) { // 初始化第一列
|
||||
for (i = 0; i <= n; i++) { // 初始化第一列
|
||||
d[i][0] = i;
|
||||
}
|
||||
|
||||
for (j = 0; j <= m; j++) { // 初始化第一行
|
||||
for (j = 0; j <= m; j++) { // 初始化第一行
|
||||
d[0][j] = j;
|
||||
}
|
||||
for (i = 1; i <= n; i++) { // 遍历str
|
||||
for (i = 1; i <= n; i++) { // 遍历str
|
||||
ch1 = str.charAt(i - 1);
|
||||
// 去匹配target
|
||||
// 去匹配target
|
||||
for (j = 1; j <= m; j++) {
|
||||
ch2 = target.charAt(j - 1);
|
||||
if (ch1 == ch2) {
|
||||
@@ -139,7 +139,7 @@ public class CosineSimilarAlgorithm {
|
||||
} else {
|
||||
temp = 1;
|
||||
}
|
||||
// 左边+1,上边+1, 左上角+temp取最小
|
||||
// 左边+1,上边+1, 左上角+temp取最小
|
||||
d[i][j] = min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + temp);
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ public class CosineSimilarAlgorithm {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取两字符串的相似度
|
||||
* 获取两字符串的相似度
|
||||
*
|
||||
* @param str
|
||||
* @param target
|
||||
|
||||
Reference in New Issue
Block a user