Просмотр исходного кода

组织导入添加校验手机号有效性

luojing 5 лет назад
Родитель
Сommit
e83b27b561

+ 27 - 1
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/ActionInputAll.java

@@ -607,7 +607,9 @@ class ActionInputAll extends BaseAction {
 						}
 					}
 				}
-				
+				if(!validate){
+					continue;
+				}
 				Unit p = null;
 				p = emc.flag(o.getUnique(), Unit.class);
 				if (null != p) {
@@ -648,6 +650,11 @@ class ActionInputAll extends BaseAction {
 				validate = false;
 				continue;
 			}
+			if(!this.checkMobile(business, o.getMobile())){
+				this.setPersonMemo(workbook, configurator, o, "手机号码不符合指定规则.");
+				validate = false;
+				continue;
+			}
 			this.setPersonMemo(workbook, configurator, o, "校验通过.");
 			/*if(o.getAttributes().isEmpty()|| StringUtils.isEmpty(o.getAttributes().get("idNumber"))){
 				this.setPersonMemo(workbook, configurator, o, "身份证号不能为空.");
@@ -664,8 +671,17 @@ class ActionInputAll extends BaseAction {
 							validate = false;
 							continue;
 						}
+						if (StringUtils.isNotEmpty(o.getMobile()) && StringUtils.equals(o.getMobile(), item.getMobile())) {
+							this.setPersonMemo(workbook, configurator, o, "手机号码冲突,本次导入中不唯一."); 
+							validate = false;
+							continue;
+						}
 					}
 				}
+				
+				if(!validate){
+					continue;
+				}
 				Person p = null;
 				p = emc.flag(o.getUnique(), Person.class);
 				if (null != p) {
@@ -673,6 +689,16 @@ class ActionInputAll extends BaseAction {
 					validate = false;
 					continue;
 				}
+				
+				Person pc = null;
+				pc = emc.flag(o.getMobile(), Person.class);
+				if (null != pc) {
+					System.out.println("手机号码: " + o.getMobile() + " 与已经存在手机号码: " + pc.getMobile() + " 冲突.");
+					this.setPersonMemo(workbook, configurator, o, "手机号码: " + o.getMobile() + " 与已经存在手机号码: " + pc.getMobile() + " 冲突.");
+					validate = false;
+					continue;
+				}
+				
 				this.setPersonMemo(workbook, configurator, o, "校验通过.");
 			}
 		}

+ 12 - 0
o2server/x_organization_assemble_control/src/main/java/com/x/organization/assemble/control/jaxrs/inputperson/BaseAction.java

@@ -3,8 +3,12 @@ package com.x.organization.assemble.control.jaxrs.inputperson;
 import java.util.Arrays;
 import java.util.List;
 
+import org.apache.commons.lang3.StringUtils;
+
 import com.x.base.core.project.cache.ApplicationCache;
+import com.x.base.core.project.config.Config;
 import com.x.base.core.project.jaxrs.StandardJaxrsAction;
+import com.x.organization.assemble.control.Business;
 
 import net.sf.ehcache.Ehcache;
 
@@ -14,6 +18,14 @@ abstract class BaseAction extends StandardJaxrsAction {
 	protected static List<String> genderTypeMaleItems = Arrays.asList(new String[] { "m", "M", "男", "male" });
 
 	protected Ehcache cache = ApplicationCache.instance().getCache(CacheInputResult.class);
+	
+	protected boolean checkMobile(Business business, String mobile) throws Exception {
+		if (!Config.person().isMobile(mobile)) {
+			return false;
+		}else{
+			return true;
+		}
+	}
 
 	public static class CacheInputResult {