Browse Source

企业信息录入数据重复提示信息调整

liao-sea 9 months ago
parent
commit
483ab349dc

+ 38 - 69
src/main/java/com/hz/employmentsite/services/impl/companyService/CompanyServiceImpl.java

@@ -11,6 +11,7 @@ import com.hz.employmentsite.services.service.companyService.CompanyService;
 import com.hz.employmentsite.services.service.companyService.FirmService;
 import com.hz.employmentsite.services.service.companyService.IndustryService;
 import com.hz.employmentsite.services.service.system.DictionaryService;
+import com.hz.employmentsite.util.RegexUtils;
 import com.hz.employmentsite.util.StringUtils;
 import com.hz.employmentsite.vo.companyService.AppCompanyPostVo;
 import com.hz.employmentsite.vo.companyService.CompanyVo;
@@ -32,6 +33,9 @@ public class CompanyServiceImpl implements CompanyService {
     @Autowired
     private StringUtils stringUtils;
 
+    @Autowired
+    private RegexUtils regexUtils;
+
     @Autowired
     private DictionaryService dictionaryService;
 
@@ -101,7 +105,7 @@ public class CompanyServiceImpl implements CompanyService {
         return pcCompanyMapper.selectByExample(exp);
     }
 
-    private int ifHadRepeatData(CompanyVo data){
+    private Integer ifHadRepeatData(CompanyVo data){
         var result = 0;
         PcCompanyExample companyExp1 = new PcCompanyExample();
         companyExp1.or().andCompanyNameEqualTo(data.getCompanyName()).andCompanyIDNotEqualTo(data.getCompanyID());
@@ -111,6 +115,34 @@ public class CompanyServiceImpl implements CompanyService {
         var ifRepeatCode = pcCompanyMapper.selectByExample(companyExp2).size()>0;
         result += ifRepeatName? 1:0;
         result += ifRepeatCode? 2:0;
+        if(result > 0) {
+            PcCompanyExample companyExp =  new PcCompanyExample();
+            switch (result){
+                case 1:
+                    companyExp.or().andCompanyNameEqualTo(data.getCompanyName());
+                    break;
+                case 2:
+                    companyExp.or().andCompanyCodeEqualTo(data.getCompanyCode());
+                    break;
+                case 3:
+                    companyExp.or().andCompanyNameEqualTo(data.getCompanyName()).andCompanyCodeEqualTo(data.getCompanyCode());
+                    break;
+            }
+            var repeatData = pcCompanyMapper.selectByExample(companyExp).stream().findFirst().orElse(null);
+            if( repeatData != null){
+                PcSiteUserExample siteUserExp = new PcSiteUserExample();
+                siteUserExp.or().andUserIDEqualTo(repeatData.getCreateUserID());
+                var createSiteUserInfo= pcSiteUserMapper.selectByExample(siteUserExp).stream().findFirst().orElse(null);
+                if( createSiteUserInfo!=null){
+                    PcSiteExample siteExp = new PcSiteExample();
+                    siteExp.or().andSiteIDEqualTo(createSiteUserInfo.getSiteID());
+                    var curSiteInfo= pcSiteMapper.selectByExample(siteExp).stream().findFirst().orElse(null);
+                    if( curSiteInfo != null){
+                        throw new  BaseException("1004","该企业已被"+curSiteInfo.getSiteName()+",工号"+createSiteUserInfo.getUserNo()+"录入!");
+                    }
+                }
+            }
+        }
         return result;
     }
 
@@ -125,17 +157,8 @@ public class CompanyServiceImpl implements CompanyService {
             cro.andCompanyIDEqualTo(data.getCompanyID());
             dbData = pcCompanyMapper.selectByExampleWithBLOBs(exp).stream().findFirst().orElse(null);
         }
-        var repeatResult = ifHadRepeatData(data);
-        switch (repeatResult){
-            default:
-            case 0:
-                break;
-            case 1:
-                throw new  BaseException("1004","企业名称已存在!");
-            case 2:
-                throw new  BaseException("1004","统一社会信用代码已存在!");
-            case 3:
-                throw new  BaseException("1004","信用代码、企业名称重复!");
+        if(ifHadRepeatData(data)>0) {
+            throw new  BaseException("1004","该企业已被录入!");
         }
         if (dbData == null) {
             exp = new PcCompanyExample();
@@ -265,60 +288,6 @@ public class CompanyServiceImpl implements CompanyService {
         return data;
     }
 
-    //验证统一信用代码/工商注册号是否合法
-    private boolean companyCodeIsValid(String companyCode) {
-        if (companyCode.length() != 18 && companyCode.length() != 15) {
-            return false;
-        }
-        // 正则表达式验证身份证格式
-        String code_Regex = "^[0-9A-Z]+$";
-        String gsCode_Regex = "^\\d{15}$";
-        if (companyCode.length() == 18) {
-            if(!companyCode.matches(code_Regex)){
-                return false;
-            }else{
-                String aCode;
-                Integer aCodeValue,i;
-                Integer total = 0;
-                int[] weightedFactors = {1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28};
-                String str = "0123456789ABCDEFGHJKLMNPQRTUWXY";
-                for(i = 0 ; i < companyCode.length() - 1; i++) {
-                    aCode =  companyCode.substring(i, i + 1);
-                    aCodeValue = str.indexOf(aCode);
-                    total += aCodeValue * weightedFactors[i];
-                }
-                Integer logicCheckCode = 31 - total % 31;
-                if (logicCheckCode == 31) {
-                    logicCheckCode = 0;
-                }
-                String Str = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,T,U,W,X,Y";
-                String[] Array_Str = Str.split(",");
-                String correctCodeStr = Array_Str[logicCheckCode];
-                String currentCodeStr = companyCode.substring(17, 18);
-                if (!correctCodeStr.equals(currentCodeStr)) {
-                    return false;
-                }
-            }
-        }else{
-            if(!companyCode.matches(gsCode_Regex)){
-                return false;
-            }
-        }
-        return true;
-    }
-
-    //验证联系电话(包括座机号码)是否合法
-    private boolean companyMobileIsValid(String mobile) {
-        String mobile_Regex = "^1[3|4|5|6|7|8|9]\\d{9}$";
-        String landline_Reg = "[0-9-()()]{7,18}";
-        return mobile.matches(mobile_Regex)||mobile.matches(landline_Reg);
-    }
-
-    //验证企业邮箱是否有效
-    private boolean companyEmailIsValid(String email){
-        String email_Regex = "^[a-z0-9]+([._\\\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$";
-        return email.matches(email_Regex);
-    }
 
     @Override
     public List<CompanyVo> importCompany(List<CompanyVo> dataList, String userID) {
@@ -398,7 +367,7 @@ public class CompanyServiceImpl implements CompanyService {
             if (stringUtils.IsNullOrEmpty(item.companyCode))
                 errorInfo += "请填写统一信用代码!";
             else{
-                if(!companyCodeIsValid(item.companyCode)){
+                if(!regexUtils.theCodeIsValid(item.companyCode)){
                     errorInfo +="输入的统一信用代码无效";
                 }
             }
@@ -424,7 +393,7 @@ public class CompanyServiceImpl implements CompanyService {
             if (stringUtils.IsNullOrEmpty(item.userMobile))
                 errorInfo += "请填写企业联系电话!";
             else{
-                if(!companyMobileIsValid(item.userMobile)){
+                if(!regexUtils.theMobileIsValid(item.userMobile,true)){
                     errorInfo += "企业联系电话不合法!";
                 }
             }
@@ -469,7 +438,7 @@ public class CompanyServiceImpl implements CompanyService {
 
             if (!stringUtils.IsNullOrEmpty(item.companyEmail))
             {
-                if(!companyEmailIsValid(item.companyEmail)){
+                if(!regexUtils.theEmailIsValid(item.companyEmail)){
                     errorInfo +="企业邮箱不合法!";
                 }
             }

+ 6 - 9
src/main/java/com/hz/employmentsite/services/impl/companyService/PostServiceImpl.java

@@ -10,6 +10,7 @@ import com.hz.employmentsite.mapper.cquery.RecommendMgtCQuery;
 import com.hz.employmentsite.model.*;
 import com.hz.employmentsite.services.service.companyService.PostService;
 import com.hz.employmentsite.services.service.system.DictionaryService;
+import com.hz.employmentsite.util.RegexUtils;
 import com.hz.employmentsite.util.StringUtils;
 import com.hz.employmentsite.vo.companyService.PostVo;
 import com.hz.employmentsite.vo.companyService.RecommendPostVo;
@@ -17,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
-import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
 @Service("PostService")
@@ -29,6 +29,9 @@ public class PostServiceImpl implements PostService {
     @Autowired
     private StringUtils stringUtils;
 
+    @Autowired
+    private RegexUtils regexUtils;
+
     @Autowired
     private PcPostMapper pcPostMapper;
 
@@ -56,15 +59,9 @@ public class PostServiceImpl implements PostService {
     @Autowired
     private LabelCQuery labelCQuery;
 
-    @Autowired
-    private RecommendMgtCQuery recommendMgtCQuery;
-
     @Autowired
     private PcWorkcategoryMapper pcWorkcategoryMapper;
 
-    private final String MOBILE_REGEX = "0?(13|14|15|16|18|17|19)[0-9]{9}";
-    private final String LONG_MOBILE_REGEX = "[0-9-()()]{7,18}";
-    private final String EMAIL_REGEX = "^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+\\.){1,63}[a-z0-9]+$";
 
     @Override
     public PageInfo<PostVo> getList(Integer page, Integer rows, List<String> postIDList,
@@ -510,13 +507,13 @@ public class PostServiceImpl implements PostService {
             }
 
             if (!stringUtils.IsNullOrEmpty(item.getContactMobile())) {
-                if (!Pattern.matches(MOBILE_REGEX, item.contactMobile) && !Pattern.matches(LONG_MOBILE_REGEX, item.contactMobile)) {
+                if (!regexUtils.theMobileIsValid( item.contactMobile,true)) {
                     errorInfo += "输入的联系人电话格式不正确";
                 }
             }
 
             if (!stringUtils.IsNullOrEmpty(item.getCompanyEmail())) {
-                if (!Pattern.matches(EMAIL_REGEX, item.contactEmail)) {
+                if (!regexUtils.theEmailIsValid(item.contactEmail)) {
                     errorInfo += "输入的邮箱格式不正确";
                 }
             }

+ 0 - 5
src/main/java/com/hz/employmentsite/services/impl/jobUserManager/JobHuntServiceImpl.java

@@ -254,8 +254,6 @@ public class JobHuntServiceImpl implements JobHuntService {
                 if (item.jobUserID == null)
                     errorInfo += "求职人员不存在!";
             }
-//            if (stringUtils.IsNullOrEmpty(item.workName))
-//                errorInfo += "请填写工种名称!";
 
             if (stringUtils.IsNullOrEmpty(item.jobHuntTypeStr))
                 errorInfo += "请填写求职类型!";
@@ -294,9 +292,6 @@ public class JobHuntServiceImpl implements JobHuntService {
             if (stringUtils.IsNullOrEmpty(String.valueOf(item.workYear)) || item.workYear.equals(0))
                 errorInfo += "请填写工作年限!";
 
-            /*if (stringUtils.IsNullOrEmpty(item.otherDemand))
-                errorInfo += "请填写其他要求!";*/
-
             if (stringUtils.IsNullOrEmpty(errorInfo)) {
                 resultList.add(item);
             } else {

+ 7 - 48
src/main/java/com/hz/employmentsite/services/impl/jobUserManager/JobUserServiceImpl.java

@@ -9,10 +9,7 @@ import com.hz.employmentsite.mapper.cquery.LabelCQuery;
 import com.hz.employmentsite.model.*;
 import com.hz.employmentsite.services.service.jobUserManager.JobUserService;
 import com.hz.employmentsite.services.service.system.DictionaryService;
-import com.hz.employmentsite.util.CalculateUtils;
-import com.hz.employmentsite.util.DateUtils;
-import com.hz.employmentsite.util.DesUtils;
-import com.hz.employmentsite.util.StringUtils;
+import com.hz.employmentsite.util.*;
 import com.hz.employmentsite.vo.jobUserManager.JobUserVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -36,6 +33,9 @@ public class JobUserServiceImpl implements JobUserService {
     @Autowired
     private CalculateUtils calculateUtils;
 
+    @Autowired
+    private RegexUtils regexUtils;
+
     @Autowired
     private DictionaryService dictionaryService;
     @Autowired
@@ -571,37 +571,6 @@ public class JobUserServiceImpl implements JobUserService {
         return result;
     }
 
-    //验证身份证号是否合法
-    private boolean identityNumberIsValid(String idCard) {
-        if (idCard.length() != 18) {
-            return false;
-        }
-        // 正则表达式验证身份证格式
-        String regex = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\\d{3}([0-9Xx])$";
-        if (!idCard.matches(regex)) {
-            return false;
-        }
-        // 计算身份证校验码
-        int[] weights = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
-        char[] checkCode = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
-        int sum = 0;
-        for (int i = 0; i < weights.length; i++) {
-            sum += weights[i] * Integer.parseInt(idCard.substring(i, i + 1));
-        }
-        return idCard.charAt(17) == checkCode[sum % 11];
-    }
-
-    //验证手机号是否合法
-    private boolean userMobileIsValid(String mobile) {
-        //String mobile_Regex = "0?(13|14|15|16|18|17|19)[0-9]{9}";
-        String mobile_Regex = "^1[3|4|5|6|7|8|9]\\d{9}$";
-        return mobile.matches(mobile_Regex);
-    }
-
-    private boolean userEmailIsValid(String email){
-        String email_Regex = "^[a-z0-9]+([._\\\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$";
-        return email.matches(email_Regex);
-    }
 
     @Override
     public List<JobUserVo> importJobUser(List<JobUserVo> dataList, String userID) {
@@ -720,7 +689,7 @@ public class JobUserServiceImpl implements JobUserService {
             if (stringUtils.IsNullOrEmpty(item.getIdentityNumber()))
                 errorInfo += "请填写身份证号码!";
             else{
-                if(identityNumberIsValid(item.getIdentityNumber())) {
+                if(regexUtils.theIdCardIsValid(item.getIdentityNumber())) {
                     var birthDay = dateUtils.StrToDate((item.getIdentityNumber().substring(6,10)+"-"+item.getIdentityNumber().substring(10,12)+"-"+item.getIdentityNumber().substring(12,14)),"yyyy-MM-dd");
                     var sexStr = Integer.parseInt(item.getIdentityNumber().substring(16,17));
                     if(!stringUtils.IsNullOrEmpty(item.getBirthDayStr())){
@@ -787,7 +756,7 @@ public class JobUserServiceImpl implements JobUserService {
             if (stringUtils.IsNullOrEmpty(item.getUserMobile()))
                 errorInfo += "请填写联系电话!";
             else{
-                if(!userMobileIsValid(item.getUserMobile())){
+                if(!regexUtils.theMobileIsValid(item.getUserMobile(),false)){
                     errorInfo += "联系电话不合法!";
                 }else{
                     //文本加密
@@ -795,16 +764,6 @@ public class JobUserServiceImpl implements JobUserService {
                 }
             }
 
-            //if (!stringUtils.IsNullOrEmpty(item.getSocialSecurityCard())){
-            //    PcJobuserExample jobUserExp= new PcJobuserExample();
-            //    jobUserExp.or().andSocialSecurityCardEqualTo(item.getSocialSecurityCard());
-            //    if(pcJobuserMapper.selectByExample(jobUserExp).size()>0){
-            //        errorInfo += "社保卡已绑定其他求职人员!";
-            //    }
-            //}
-
-
-
             if (!stringUtils.IsNullOrEmpty(item.getIsFullTimeName())){
                 item.setIsFullTime(dicIsFullTimeList.stream().filter(it -> it.getName().equals(item.getIsFullTimeName().trim()))
                         .findFirst().orElse(new SysDictionaryItem()).getValue());
@@ -869,7 +828,7 @@ public class JobUserServiceImpl implements JobUserService {
             }
 
             if (!stringUtils.IsNullOrEmpty(item.getEmail())) {
-                if (!userEmailIsValid(item.getEmail()))
+                if (!regexUtils.theEmailIsValid(item.getEmail()))
                     errorInfo += "电子邮箱不合法!";
             }
 

+ 116 - 0
src/main/java/com/hz/employmentsite/util/RegexUtils.java

@@ -0,0 +1,116 @@
+package com.hz.employmentsite.util;
+
+import org.springframework.stereotype.Component;
+
+import java.time.LocalDate;
+import java.time.Period;
+import java.time.format.DateTimeFormatter;
+
+@Component
+public class RegexUtils {
+
+    /**
+     *验证统一信用代码/工商注册号是否合法
+     *
+     * @param companyCode 信用代码/工商注册号
+     * @return 是否合法
+     * */
+     public boolean theCodeIsValid(String companyCode) {
+        if (companyCode.length() != 18 && companyCode.length() != 15) {
+            return false;
+        }
+        // 正则表达式验证身份证格式
+        String code_Regex = "^[0-9A-Z]+$";
+        String gsCode_Regex = "^\\d{15}$";
+        if (companyCode.length() == 18) {
+            if(!companyCode.matches(code_Regex)){
+                return false;
+            }else{
+                String aCode;
+                Integer aCodeValue,i;
+                Integer total = 0;
+                int[] weightedFactors = {1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28};
+                String str = "0123456789ABCDEFGHJKLMNPQRTUWXY";
+                for(i = 0 ; i < companyCode.length() - 1; i++) {
+                    aCode =  companyCode.substring(i, i + 1);
+                    aCodeValue = str.indexOf(aCode);
+                    total += aCodeValue * weightedFactors[i];
+                }
+                Integer logicCheckCode = 31 - total % 31;
+                if (logicCheckCode == 31) {
+                    logicCheckCode = 0;
+                }
+                String Str = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,J,K,L,M,N,P,Q,R,T,U,W,X,Y";
+                String[] Array_Str = Str.split(",");
+                String correctCodeStr = Array_Str[logicCheckCode];
+                String currentCodeStr = companyCode.substring(17, 18);
+                if (!correctCodeStr.equals(currentCodeStr)) {
+                    return false;
+                }
+            }
+        }else{
+            if(!companyCode.matches(gsCode_Regex)){
+                return false;
+            }
+        }
+        return true;
+    }
+
+    /**
+     *验证身份证号码是否合法
+     *
+     * @param idCard 身份证号码
+     * @return 是否合法
+     * */
+     public boolean theIdCardIsValid(String idCard) {
+        if (idCard.length() != 18) {
+            return false;
+        }
+        // 正则表达式验证身份证格式
+        String regex = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2][0-9]|3[0-1])\\d{3}([0-9Xx])$";
+        if (!idCard.matches(regex)) {
+            return false;
+        }
+        // 计算身份证校验码
+        int[] weights = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2};
+        char[] checkCode = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'};
+        int sum = 0;
+        for (int i = 0; i < weights.length; i++) {
+            sum += weights[i] * Integer.parseInt(idCard.substring(i, i + 1));
+        }
+        return idCard.charAt(17) == checkCode[sum % 11];
+     }
+
+
+    /**
+     *验证联系电话(包括座机号码)是否合法
+     *
+     * @param mobile 联系电话
+     * @param isCompany 是否允许座机
+     * @return 是否合法
+     * */
+     public boolean theMobileIsValid(String mobile,boolean isCompany) {
+        String mobile_Regex = "^1[3|4|5|6|7|8|9]\\d{9}$";
+        if(isCompany){
+            String landline_Reg = "[0-9-()()]{7,18}";
+            return mobile.matches(mobile_Regex)||mobile.matches(landline_Reg);
+        }
+        return mobile.matches(mobile_Regex);
+    }
+
+    /**
+     *验证邮箱是否合法
+     *
+     * @param email 联系电话
+     * @return 是否合法
+     * */
+    public boolean theEmailIsValid(String email){
+        String email_Regex = "^[a-z0-9]+([._\\\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$";
+        return email.matches(email_Regex);
+    }
+
+
+
+
+
+}