|
@@ -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 +="企业邮箱不合法!";
|
|
|
}
|
|
|
}
|