销售线索乱码
This commit is contained in:
@@ -1805,6 +1805,16 @@ public class DataUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isChineseChar(String c) {
|
||||
if (StringUtils.isNotBlank(c)) {
|
||||
String temp = String.valueOf(c);
|
||||
Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5]+");
|
||||
Matcher matcher = pattern.matcher(temp);
|
||||
return matcher.matches();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(getFirstChar("文裕花园"));
|
||||
System.out.println(getFirstChar("文怡花园"));
|
||||
|
||||
+31
-1
@@ -1,5 +1,9 @@
|
||||
package com.fangjia.coresite.controllers;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -7,6 +11,7 @@ import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.fangjia.core.util.DataUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import com.fangjia.coresite.model.JsonModel;
|
||||
@@ -37,7 +42,7 @@ public class SaleLeadsController {
|
||||
}
|
||||
|
||||
public Object doAddAction(SaleLeadsModel model, HttpServletRequest req,
|
||||
HttpServletResponse res) {
|
||||
HttpServletResponse res) throws UnsupportedEncodingException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
|
||||
|
||||
model.setViewType("redirect");
|
||||
String refUrl = model.getBackUrl();
|
||||
@@ -122,6 +127,8 @@ public class SaleLeadsController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
saleLeads = converValue(saleLeads);
|
||||
saleLeadsService.save(saleLeads);
|
||||
|
||||
if(StringUtils.isNotBlank(saleLeads.getBusiness()) && saleLeads.getBusiness().contains("_")){
|
||||
@@ -162,6 +169,29 @@ public class SaleLeadsController {
|
||||
model.setViewParam("location", url);
|
||||
return model;
|
||||
}
|
||||
|
||||
private SaleLeads converValue(SaleLeads saleLeads) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, UnsupportedEncodingException {
|
||||
//
|
||||
Field[] fields = saleLeads.getClass().getDeclaredFields();
|
||||
for(Field s : fields){
|
||||
String name = s.getName();
|
||||
String type = s.getGenericType().toString();
|
||||
if(type.contains("java.lang.String")){
|
||||
String fildName = name.substring(0,1).toUpperCase()+name.substring(1);
|
||||
Method m = saleLeads.getClass().getMethod("get"+fildName);
|
||||
String value = (String)m.invoke(saleLeads);
|
||||
if(StringUtils.isNotBlank(value)){
|
||||
if(!DataUtil.isChineseChar(value)){
|
||||
String newValue = new String(value.getBytes("ISO8859-1"), "UTF-8");
|
||||
m = saleLeads.getClass().getMethod("set"+fildName,String.class);
|
||||
m.invoke(saleLeads, newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return saleLeads;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public Object addDownInfoAction(SaleLeadsModel model, HttpServletRequest req,
|
||||
|
||||
Reference in New Issue
Block a user