Browse Source

新增统一信用代码添加

anderx 3 years ago
parent
commit
fd876ebb09

+ 12 - 13
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -347,16 +347,15 @@
 		left join admin d on a.aid = d.id
 		where a.type = 1 and a.status =0 and a.source in (1,2,3)
 	<if test="role == 0">
-		and un.name
-		<if test="names == null">
-			is null
-		</if>
 		<if test="names !=null">
-		in <foreach close=")" collection="names" item="name" open="(" separator=",">
+			and un.name in
+		<foreach close=")" collection="names" item="name" open="(" separator=",">
 			#{name}
 		</foreach>
 		</if>
-
+		<if test="names ==null and orgCode==null">
+			is null
+		</if>
 	</if>
 	<if test="role == 1 and name != null">
 		and un.name like concat('%', #{name},'%')
@@ -403,14 +402,14 @@
 		</if>
 		where a.type = 1 and a.status =0 and a.source in (1,2,3)
 		<if test="role == 0">
-			and un.name
-			<if test="names == null">
-				is null
-			</if>
 			<if test="names !=null">
-				in <foreach close=")" collection="names" item="name" open="(" separator=",">
-				#{name}
-			</foreach>
+				and un.name in
+				<foreach close=")" collection="names" item="name" open="(" separator=",">
+					#{name}
+				</foreach>
+			</if>
+			<if test="names ==null and orgCode==null">
+				is null
 			</if>
 		</if>
 	<if test="role == 1 and name != null">

+ 18 - 4
src/main/java/com/goafanti/common/utils/StringUtils.java

@@ -5,17 +5,18 @@ import java.util.regex.Pattern;
 public class StringUtils extends org.apache.commons.lang3.StringUtils {
 	private static Pattern FRACTIONAL_NUMERIC = Pattern.compile("^[\\-+]?\\d+(\\.\\d+)?$");
 
+	private static Pattern CHINESE_CODE=Pattern.compile("[\u4e00-\u9fa5]");
 	public static boolean isFractionalNumeric(String val) {
 		return FRACTIONAL_NUMERIC.matcher(val).matches();
 	}
-	
+
 	public static boolean isNull(Object value) {
 		return value == null;
 	}
 
 	/**
 	 * * 判断一个对象是否非空
-	 * 
+	 *
 	 * @param object Object
 	 * @return true:非空 false:空
 	 */
@@ -27,7 +28,7 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
 
 	/**
 	 * * 判断一个对象数组是否为空
-	 * 
+	 *
 	 * @param objects 要判断的对象数组
 	 ** @return true:为空 false:非空
 	 */
@@ -35,5 +36,18 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
 		return isNull(objects) || (objects.length == 0);
 	}
 
-	
+	public static boolean isContainChinese(String str){
+		if (CHINESE_CODE.matcher(str).find()){
+			return true;
+		}
+		return false;
+	}
+
+
+	public static void main(String[] args) {
+		String str="132";
+		if (isContainChinese(str)) System.out.println("中文");
+		else System.out.println("非中文");
+	}
+
 }

+ 20 - 7
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -216,17 +216,32 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 			Integer pageSize) {
 		cli.setType(AFTConstants.USER_TYPE_ORGANIZATION);
 		Map<String, Object> params = disposeParams(cli);
+		String name=null;
+		String orgCode=null;
+		if (StringUtils.isContainChinese(cli.getName())){
+			name= cli.getName();
+		}else {
+			if (StringUtils.isBlank(cli.getName())){
+				return new Pagination<>();
+			}
+			orgCode= cli.getName();
+		}
 		if (TokenManager.hasRole(AFTConstants.SUPERADMIN)||TokenManager.hasRole(AFTConstants.APPROVAL_DECISION)) {
 			params.put("role", 1);
-			params.put("name", cli.getName());
+			if (name!=null)params.put("name",name);
+			else params.put("orgCode",orgCode);
 		} else {
 			//处理为空报错
 			params.put("role", 0);
-			String [] names =pushNames(cli.getName());
-			if (names.length>0){
-				params.put("names", names);
+			if (orgCode!=null) {
+				params.put("orgCode",orgCode);
 			}else {
-				return new Pagination<>();
+				String [] names =pushNames(name);
+				if (names.length>0){
+					params.put("names", names);
+				}else {
+					return new Pagination<>();
+				}
 			}
 		}
 		Pagination<CustomerListOut> p = (Pagination<CustomerListOut>) findPage("selectOrganizationCustomerList",
@@ -306,8 +321,6 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 			params.put("channel", cli.getChannel());
 		if (null != cli.getBusinessScope())
 			params.put("businessScope", cli.getBusinessScope());
-		if (null != cli.getOrgCode())
-			params.put("orgCode", cli.getOrgCode());
 		return params;
 	}