|
@@ -14,12 +14,15 @@ import com.hz.employmentsite.services.service.system.DictionaryService;
|
|
|
import com.hz.employmentsite.util.StringUtils;
|
|
|
import com.hz.employmentsite.vo.companyService.AppCompanyPostVo;
|
|
|
import com.hz.employmentsite.vo.companyService.CompanyVo;
|
|
|
+import com.hz.employmentsite.vo.jobUserManager.JobUserVo;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service("CompanyService")
|
|
@@ -49,6 +52,9 @@ public class CompanyServiceImpl implements CompanyService {
|
|
|
@Autowired
|
|
|
private PcSiteUserMapper pcSiteUserMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private PcSiteMapper pcSiteMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private FirmService firmService;
|
|
|
|
|
@@ -261,21 +267,99 @@ 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) {
|
|
|
if (dataList.size() <= 0)
|
|
|
throw new BaseException("1004", "请添加导入数据!");
|
|
|
//所属驿站
|
|
|
- List<PcSite> siteList = siteMapper.selectByExample(null);
|
|
|
- //所属县区
|
|
|
- AreaCodeExample reginExp = new AreaCodeExample();
|
|
|
- reginExp.or().andLvEqualTo("3");
|
|
|
- List<AreaCode> regionList = areaCodeMapper.selectByExample(reginExp);
|
|
|
- //所属街道
|
|
|
- AreaCodeExample streetExp = new AreaCodeExample();
|
|
|
- reginExp.or().andLvEqualTo("4");
|
|
|
- List<AreaCode> streetList = areaCodeMapper.selectByExample(streetExp);
|
|
|
- List<CompanyVo> resultList = new ArrayList<>();
|
|
|
+ PcSite curLoginUserSiteInfo = null;
|
|
|
+ PcSiteUserExample siteUserExp = new PcSiteUserExample();
|
|
|
+ siteUserExp.or().andUserIDEqualTo(userID);
|
|
|
+ PcSiteUser curLoginSiteUser = pcSiteUserMapper.selectByExample(siteUserExp).stream().findFirst().orElse(null);
|
|
|
+ if(curLoginSiteUser==null){
|
|
|
+ throw new BaseException("", "未能查询到当前登录人的驿站人员信息!");
|
|
|
+ }else{
|
|
|
+ PcSiteExample siteExp = new PcSiteExample();
|
|
|
+ siteExp.or().andSiteIDEqualTo(curLoginSiteUser.getSiteID());
|
|
|
+ curLoginUserSiteInfo = pcSiteMapper.selectByExample(siteExp).stream().findFirst().orElse(null);
|
|
|
+ }
|
|
|
+ //市/县
|
|
|
+ List<SysDictionaryItem> regionDataList = new ArrayList<>();
|
|
|
+ AreaCodeExample regionExp= new AreaCodeExample();
|
|
|
+ regionExp.or().andFidEqualTo("441300000000000").andLvEqualTo("3");
|
|
|
+ var thirdLevelRegionList = areaCodeMapper.selectByExample(regionExp);
|
|
|
+ for (AreaCode curRegionData : thirdLevelRegionList) {
|
|
|
+ SysDictionaryItem item = new SysDictionaryItem();
|
|
|
+ item.setCode(curRegionData.getCode());
|
|
|
+ item.setName(curRegionData.getName());
|
|
|
+ regionDataList.add(item);
|
|
|
+ }
|
|
|
+ //镇街
|
|
|
+ List<SysDictionaryItem> streetDataList = new ArrayList<>();
|
|
|
+ AreaCodeExample streetExp= new AreaCodeExample();
|
|
|
+ streetExp.or().andLvEqualTo("4");
|
|
|
+ var forthLevelStreetList = areaCodeMapper.selectByExample(streetExp);
|
|
|
+ for (AreaCode curStreetData : forthLevelStreetList) {
|
|
|
+ SysDictionaryItem item = new SysDictionaryItem();
|
|
|
+ item.setCode(curStreetData.getCode());
|
|
|
+ item.setName(curStreetData.getName());
|
|
|
+ streetDataList.add(item);
|
|
|
+ }
|
|
|
//企业规模
|
|
|
List<SysDictionaryItem> dicCompanyModelList = dictionaryService.getDictionaryItemList("CompanyModel");
|
|
|
// 经济类型
|
|
@@ -287,30 +371,52 @@ public class CompanyServiceImpl implements CompanyService {
|
|
|
// 企业产业分类
|
|
|
List<SysDictionaryItem> companyEstateCategory = dictionaryService.getDictionaryItemByCodeList("CompanyEstateCategory");
|
|
|
|
|
|
+ List<CompanyVo> resultList = new ArrayList<>();
|
|
|
+ PcSite finalCurLoginUserSiteInfo = curLoginUserSiteInfo;
|
|
|
+
|
|
|
dataList.forEach(item -> {
|
|
|
String errorInfo = "";
|
|
|
item.companyID = UUID.randomUUID().toString();
|
|
|
- if (stringUtils.IsNullOrEmpty(item.companyCode))
|
|
|
- errorInfo += "请填写统一信用代码!";
|
|
|
+
|
|
|
+ var repeatResult = ifHadRepeatData(item);
|
|
|
+ switch (repeatResult){
|
|
|
+ default:
|
|
|
+ case 0:
|
|
|
+ break;
|
|
|
+ case 1:
|
|
|
+ errorInfo += "企业名称已存在!";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ errorInfo += "统一社会信用代码已存在!";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ errorInfo += "信用代码、企业名称重复!";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
if (stringUtils.IsNullOrEmpty(item.companyName))
|
|
|
errorInfo += "请填写企业名称!";
|
|
|
- if (stringUtils.IsNullOrEmpty(item.regionName)) {
|
|
|
- errorInfo += "请填写所属县区!";
|
|
|
- } else {
|
|
|
- item.regionCode = regionList.stream().filter(it -> it.getName().equals(item.regionName.trim()))
|
|
|
- .findFirst().orElse(new AreaCode()).getCode();
|
|
|
- if (stringUtils.IsNullOrEmpty(item.regionCode))
|
|
|
- errorInfo += "县区名称不存在!";
|
|
|
+
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.companyCode))
|
|
|
+ errorInfo += "请填写统一信用代码!";
|
|
|
+ else{
|
|
|
+ if(!companyCodeIsValid(item.companyCode)){
|
|
|
+ errorInfo +="输入的统一信用代码无效";
|
|
|
+ }
|
|
|
}
|
|
|
- if (stringUtils.IsNullOrEmpty(item.SiteName))
|
|
|
+
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.getSiteName()))
|
|
|
errorInfo += "请填写所属驿站!";
|
|
|
else {
|
|
|
- item.siteID = siteList.stream().filter(it -> it.getSiteName().equals(item.getSiteName().trim()))
|
|
|
- .findFirst().orElse(new PcSite()).getSiteID();
|
|
|
- if (stringUtils.IsNullOrEmpty(item.siteID)) {
|
|
|
- errorInfo += "驿站不存在!";
|
|
|
+ if (finalCurLoginUserSiteInfo!=null){
|
|
|
+ if(!item.getSiteName().equals(finalCurLoginUserSiteInfo.getSiteName())){
|
|
|
+ errorInfo += "请填写您所在的驿站名称!";
|
|
|
+ }else{
|
|
|
+ item.setSiteID(finalCurLoginUserSiteInfo.getSiteID());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if (stringUtils.IsNullOrEmpty(item.companyAddress))
|
|
|
errorInfo += "请填写企业办公地址!";
|
|
|
|
|
@@ -319,9 +425,14 @@ public class CompanyServiceImpl implements CompanyService {
|
|
|
|
|
|
if (stringUtils.IsNullOrEmpty(item.userMobile))
|
|
|
errorInfo += "请填写企业联系电话!";
|
|
|
+ else{
|
|
|
+ if(!companyMobileIsValid(item.userMobile)){
|
|
|
+ errorInfo += "企业联系电话不合法!";
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
if (stringUtils.IsNullOrEmpty(item.recordStatusName))
|
|
|
- errorInfo += "请填写企业状态!";
|
|
|
+ errorInfo += "请选择企业状态!";
|
|
|
else {
|
|
|
item.recordStatus = companyStatusList.stream().filter(it -> it.getName().equals(item.getRecordStatusName().trim()))
|
|
|
.findFirst().orElse(new SysDictionaryItem()).getValue();
|
|
@@ -330,24 +441,39 @@ public class CompanyServiceImpl implements CompanyService {
|
|
|
}
|
|
|
|
|
|
if (stringUtils.IsNullOrEmpty(item.isShortageName))
|
|
|
- errorInfo += "请填写是否缺工!";
|
|
|
+ errorInfo += "请选择是否缺工!";
|
|
|
else {
|
|
|
if (item.isShortageName.equals("是")) item.isShortage = 1;
|
|
|
else item.isShortage = 0;
|
|
|
}
|
|
|
|
|
|
- if (stringUtils.IsNullOrEmpty(errorInfo)) {
|
|
|
- resultList.add(item);
|
|
|
- } else {
|
|
|
- item.setErrorMessage(errorInfo);
|
|
|
+ if (!stringUtils.IsNullOrEmpty(item.getSignInPoliticalAreaName())) {
|
|
|
+ item.signInPoliticalArea = regionDataList.stream().filter(it -> it.getName().equals(item.signInPoliticalAreaName.trim()))
|
|
|
+ .findFirst().orElse(new SysDictionaryItem()).getCode();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!stringUtils.IsNullOrEmpty(item.getIndustryName())) {
|
|
|
+ item.industryID = industryList.stream().filter(it -> it.getIndustryName().equals(item.industryName.trim()))
|
|
|
+ .findFirst().orElse(new PcIndustry()).getIndustryId();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!stringUtils.IsNullOrEmpty(item.getEstateCategoryName())) {
|
|
|
+ item.estateCategoryID = companyEstateCategory.stream().filter(it -> it.getName().equals(item.estateCategoryName.trim()))
|
|
|
+ .findFirst().orElse(new SysDictionaryItem()).getValue();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!stringUtils.IsNullOrEmpty(item.validDateStr))
|
|
|
+ {
|
|
|
+ if(item.validDateStr.trim().equals("至长期")){
|
|
|
+ item.validDate = new Date(2099,12,31);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- if (!stringUtils.IsNullOrEmpty(item.streetName))
|
|
|
+ if (!stringUtils.IsNullOrEmpty(item.companyEmail))
|
|
|
{
|
|
|
- item.streetCode = streetList.stream().filter(it -> it.getName().equals(item.streetName.trim()))
|
|
|
- .findFirst().orElse(new AreaCode()).getCode();
|
|
|
- if (stringUtils.IsNullOrEmpty(item.streetCode))
|
|
|
- errorInfo += "街道名称不存在!";
|
|
|
+ if(!companyEmailIsValid(item.companyEmail)){
|
|
|
+ errorInfo +="企业邮箱不合法!";
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!stringUtils.IsNullOrEmpty(item.companyTypeStr))
|
|
@@ -358,6 +484,39 @@ public class CompanyServiceImpl implements CompanyService {
|
|
|
errorInfo += "经济类型不存在!";
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if (!stringUtils.IsNullOrEmpty(item.getRegionName())) {
|
|
|
+ item.setRegionCode(regionDataList.stream().filter(it -> it.getName().equals(item.getRegionName().trim()))
|
|
|
+ .findFirst().orElse(new SysDictionaryItem()).getCode());
|
|
|
+ if (item.getRegionCode() == null)
|
|
|
+ errorInfo += "所属县区不存在!";
|
|
|
+ else{
|
|
|
+ if(!item.getRegionCode().equals(finalCurLoginUserSiteInfo.getRegionCode())){
|
|
|
+ errorInfo += "请选择您所在驿站的县区!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!stringUtils.IsNullOrEmpty(item.getStreetName())) {
|
|
|
+ item.setStreetCode(streetDataList.stream().filter(it -> it.getName().equals(item.getStreetName().trim()))
|
|
|
+ .findFirst().orElse(new SysDictionaryItem()).getCode());
|
|
|
+ if (item.getStreetCode() == null)
|
|
|
+ errorInfo += "所属街道不存在!";
|
|
|
+ else{
|
|
|
+ if (stringUtils.IsNullOrEmpty(item.getRegionName())){
|
|
|
+ errorInfo += "请选择所属县区!";
|
|
|
+ }else{
|
|
|
+ AreaCodeExample curStreetExp = new AreaCodeExample();
|
|
|
+ curStreetExp.or().andCodeEqualTo(item.getStreetCode());
|
|
|
+ var curStreetReginCode = areaCodeMapper.selectByExample(curStreetExp).get(0).getFid();
|
|
|
+ if(item.getRegionCode()!= null&&!curStreetReginCode.equals(item.getRegionCode())){
|
|
|
+ errorInfo += "所属街道不属于当前所属县区!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
if (!stringUtils.IsNullOrEmpty(item.companyModelStr)) {
|
|
|
item.companyModel = dicCompanyModelList.stream().filter(it -> it.getName().equals(item.companyModelStr.trim()))
|
|
|
.findFirst().orElse(new SysDictionaryItem()).getValue();
|
|
@@ -365,18 +524,14 @@ public class CompanyServiceImpl implements CompanyService {
|
|
|
errorInfo += "企业规模不存在!";
|
|
|
}
|
|
|
|
|
|
- if (!stringUtils.IsNullOrEmpty(item.getSignInPoliticalAreaName())) {
|
|
|
- item.signInPoliticalArea = regionList.stream().filter(it -> it.getName().equals(item.signInPoliticalAreaName.trim()))
|
|
|
- .findFirst().orElse(new AreaCode()).getCode();
|
|
|
- }
|
|
|
- if (!stringUtils.IsNullOrEmpty(item.getIndustryName())) {
|
|
|
- item.industryID = industryList.stream().filter(it -> it.getIndustryName().equals(item.industryName.trim()))
|
|
|
- .findFirst().orElse(new PcIndustry()).getIndustryId();
|
|
|
- }
|
|
|
- if (!stringUtils.IsNullOrEmpty(item.getEstateCategoryName())) {
|
|
|
- item.estateCategoryID = companyEstateCategory.stream().filter(it -> it.getName().equals(item.estateCategoryName.trim()))
|
|
|
- .findFirst().orElse(new SysDictionaryItem()).getValue();
|
|
|
+
|
|
|
+
|
|
|
+ if (stringUtils.IsNullOrEmpty(errorInfo)) {
|
|
|
+ resultList.add(item);
|
|
|
+ } else {
|
|
|
+ item.setErrorMessage(errorInfo);
|
|
|
}
|
|
|
+
|
|
|
});
|
|
|
|
|
|
if (dataList.stream().filter(it -> !stringUtils.IsNullOrEmpty(it.errorMessage)).collect(Collectors.toList()).size() > 0)
|