|
|
@@ -8,6 +8,7 @@ import com.huyi.service.base.service.ISysCompanyRelService;
|
|
|
import com.huyi.service.base.service.ISysCompanyService;
|
|
|
import com.huyi.service.base.service.ISysCompanySpareService;
|
|
|
import com.huyi.service.base.service.ISysConfigService;
|
|
|
+import com.tianhu.common.core.exception.BaseException;
|
|
|
import com.tianhu.common.core.utils.CommonUtil;
|
|
|
import com.tianhu.common.core.utils.DateUtils;
|
|
|
import com.tianhu.common.core.utils.IdUtils;
|
|
|
@@ -237,6 +238,9 @@ public class CompanyRelImportController extends BaseController
|
|
|
List<SysCompanyRel> relList = new ArrayList<>();
|
|
|
//链属企业信息
|
|
|
List<SysCompanySpare> spareList = new ArrayList<>();
|
|
|
+ List<SysCompanySpare> spareRelList = new ArrayList<>();
|
|
|
+ //校验集合
|
|
|
+ List<String> relSpareList = new ArrayList<>();
|
|
|
//个税详情表集合
|
|
|
//返回结果信息
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
@@ -261,15 +265,26 @@ public class CompanyRelImportController extends BaseController
|
|
|
}else{
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,供应商企业全称不能大于60位");
|
|
|
- log.error("新增" + scyName + "的链属失败,供应商企业全称不能大于60位");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,供应商企业全称不能大于60位");
|
|
|
+ log.error("新增" + scyName + "的链属,供应商企业全称不能大于60位");
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ String checkScyName = "^[\\u4E00-\\u9FFF0-9A-Z《》()()-]+$";
|
|
|
+ Pattern regeScyName = Pattern.compile(checkScyName);
|
|
|
+ Matcher matcherScyName = regeScyName.matcher(scyName);
|
|
|
+ boolean isMatScyName = matcherScyName.matches();
|
|
|
+ if(!isMatScyName){
|
|
|
+ userNameList += scyName+",";
|
|
|
+ failureNum++;
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,企业名称不能存在特殊字符");
|
|
|
+ log.error("新增" + scyName + "的链属,企业名称不能存在特殊字符");
|
|
|
continue;
|
|
|
}
|
|
|
}else{
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,供应商企业全称不能为空");
|
|
|
- log.error("新增" + scyName + "的链属失败,供应商企业全称不能为空");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,供应商企业全称不能为空");
|
|
|
+ log.error("新增" + scyName + "的链属,供应商企业全称不能为空");
|
|
|
continue;
|
|
|
}
|
|
|
//供应商企业社会统一代码
|
|
|
@@ -278,8 +293,8 @@ public class CompanyRelImportController extends BaseController
|
|
|
}else{
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,企业社会统一代码不能大于60位");
|
|
|
- log.error("新增" + scyName + "的链属失败,企业社会统一代码不能大于60位");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,企业社会统一代码不能大于60位");
|
|
|
+ log.error("新增" + scyName + "的链属,企业社会统一代码不能大于60位");
|
|
|
continue;
|
|
|
}
|
|
|
//社会统一代码正则校验
|
|
|
@@ -290,37 +305,37 @@ public class CompanyRelImportController extends BaseController
|
|
|
if(!isMatSocialCode){
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,企业社会统一代码格式错误");
|
|
|
- log.error("新增" + scyName + "的链属失败,企业社会统一代码格式错误");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,企业社会统一代码格式错误");
|
|
|
+ log.error("新增" + scyName + "的链属,企业社会统一代码格式错误");
|
|
|
continue;
|
|
|
}
|
|
|
}else{
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,企业社会统一代码不能为空");
|
|
|
- log.error("新增" + scyName + "的链属失败,企业社会统一代码不能为空");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,企业社会统一代码不能为空");
|
|
|
+ log.error("新增" + scyName + "的链属,企业社会统一代码不能为空");
|
|
|
continue;
|
|
|
}
|
|
|
//联系人
|
|
|
if(CommonUtil.isNotEmpty(scrContarct)){
|
|
|
//联系人正则校验
|
|
|
- String checkNickName = "^([\\u4e00-\\u9fa5]+|[a-zA-Z]+)$";
|
|
|
+ String checkNickName = "^[A-Za-z\\u4e00-\\u9fa5]+$";
|
|
|
Pattern regeNickName = Pattern.compile(checkNickName);
|
|
|
Matcher matcherNickName = regeNickName.matcher(scrContarct);
|
|
|
boolean isMatNickName = matcherNickName.matches();
|
|
|
if (!isMatNickName) {
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,联系人格式错误,不能含有特殊字符");
|
|
|
- log.error("新增" + scyName + "的链属失败,联系人格式错误,不能含有特殊字符");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,联系人格式错误,不能含有特殊字符");
|
|
|
+ log.error("新增" + scyName + "的链属,联系人格式错误,不能含有特殊字符");
|
|
|
continue;
|
|
|
}
|
|
|
if(scrContarct.length() <= 30){
|
|
|
}else{
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,联系人不能大于30位");
|
|
|
- log.error("新增" + scyName + "的链属失败,联系人不能大于30位");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,联系人不能大于30位");
|
|
|
+ log.error("新增" + scyName + "的链属,联系人不能大于30位");
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
@@ -333,15 +348,15 @@ public class CompanyRelImportController extends BaseController
|
|
|
if(!phoneResult){
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,联系人手机号格式不正确");
|
|
|
- log.error("新增" + scyName + "的链属失败,联系人手机号格式不正确");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,联系人手机号格式不正确");
|
|
|
+ log.error("新增" + scyName + "的链属,联系人手机号格式不正确");
|
|
|
continue;
|
|
|
}
|
|
|
if(scrContarctPhone.length() > 11){
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,联系人手机号不能超过11位");
|
|
|
- log.error("新增" + scyName + "的链属失败,联系人手机号不能超过11位");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,联系人手机号不能超过11位");
|
|
|
+ log.error("新增" + scyName + "的链属,联系人手机号不能超过11位");
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
@@ -364,8 +379,8 @@ public class CompanyRelImportController extends BaseController
|
|
|
if(scyId.equals(hId)){
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,不可同自己链属");
|
|
|
- log.error("新增" + scyName + "的链属失败,不可同自己链属");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,不可同自己链属");
|
|
|
+ log.error("新增" + scyName + "的链属,不可同自己链属");
|
|
|
continue;
|
|
|
}
|
|
|
String finalScyId = scyId;
|
|
|
@@ -379,8 +394,8 @@ public class CompanyRelImportController extends BaseController
|
|
|
if(companyRelList.size() > 0){
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,已经和此企业链属,不得重复链属");
|
|
|
- log.error("新增" + scyName + "的链属失败,已经和此企业链属,不得重复链属");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,表格内存在相同企业数据或已与此企业链属");
|
|
|
+ log.error("新增" + scyName + "的链属,表格内存在相同企业数据或已与此企业链属");
|
|
|
continue;
|
|
|
}
|
|
|
SysCompanyRel sysCompanyRel = new SysCompanyRel();
|
|
|
@@ -405,7 +420,8 @@ public class CompanyRelImportController extends BaseController
|
|
|
sysCompanyRel.setCreateBy(userId);
|
|
|
//创建时间
|
|
|
sysCompanyRel.setCreateTime(DateUtils.getNowDate());
|
|
|
- relList.add(sysCompanyRel);
|
|
|
+// relList.add(sysCompanyRel);
|
|
|
+ iSysCompanyRelService.createSysCompanyRel(sysCompanyRel);
|
|
|
//新增链属信息表
|
|
|
SysCompanySpare sysCompanySpare = new SysCompanySpare();
|
|
|
//主键
|
|
|
@@ -430,7 +446,8 @@ public class CompanyRelImportController extends BaseController
|
|
|
sysCompanySpare.setCreateBy(userId);
|
|
|
//创建时间
|
|
|
sysCompanySpare.setCreateTime(DateUtils.getNowDate());
|
|
|
- spareList.add(sysCompanySpare);
|
|
|
+// spareList.add(sysCompanySpare);
|
|
|
+ iSysCompanySpareService.createSysCompanySpare(sysCompanySpare);
|
|
|
}else {
|
|
|
//查询企业名称是否已经存在
|
|
|
LambdaQueryWrapper<SysCompany> companyLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -442,8 +459,8 @@ public class CompanyRelImportController extends BaseController
|
|
|
if(companyListist.size() > 0){
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,企业名称与统一代码不匹配,不可关联此企业");
|
|
|
- log.error("新增" + scyName + "的链属失败,企业名称与统一代码不匹配,不可关联此企业");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,企业名称与统一代码不匹配,不可关联此企业");
|
|
|
+ log.error("新增" + scyName + "的链属,企业名称与统一代码不匹配,不可关联此企业");
|
|
|
continue;
|
|
|
}
|
|
|
LambdaQueryWrapper<SysCompanySpare> spareLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
@@ -458,16 +475,16 @@ public class CompanyRelImportController extends BaseController
|
|
|
if(bigDecimal.compareTo(tow) > -1){
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,此企业已邀请");
|
|
|
- log.error("新增" + scyName + "的链属失败,此企业已邀请");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,此企业已邀请");
|
|
|
+ log.error("新增" + scyName + "的链属,此企业已邀请");
|
|
|
continue;
|
|
|
}
|
|
|
String status = sysCompanySpareList.get(0).getScpStatus();
|
|
|
if("01".equals(status)){
|
|
|
userNameList += scyName+",";
|
|
|
failureNum++;
|
|
|
- failureMsg.append("<br/>第" + (i+1) + "行数据导入失败,与此企业已是链属关系");
|
|
|
- log.error("新增" + scyName + "的链属失败,与此企业已是链属关系");
|
|
|
+ failureMsg.append("<br/>第" + (i+1) + "行,与此企业已是链属关系");
|
|
|
+ log.error("新增" + scyName + "的链属,与此企业已是链属关系");
|
|
|
continue;
|
|
|
}
|
|
|
}
|
|
|
@@ -493,51 +510,40 @@ public class CompanyRelImportController extends BaseController
|
|
|
sysCompanySpare.setCreateBy(userId);
|
|
|
//创建时间
|
|
|
sysCompanySpare.setCreateTime(DateUtils.getNowDate());
|
|
|
- spareList.add(sysCompanySpare);
|
|
|
- }
|
|
|
- successNum++;
|
|
|
- }
|
|
|
- if(CommonUtil.isNotEmpty(userNameList)){
|
|
|
- failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
- return AjaxResult.success(failureMsg.toString());
|
|
|
- }
|
|
|
- //统一校验完成后再进行数据添加
|
|
|
- //链属表表
|
|
|
- for(SysCompanyRel rel : relList){
|
|
|
- iSysCompanyRelService.createSysCompanyRel(rel);
|
|
|
- //TODO 供应商发送消息推送
|
|
|
- }
|
|
|
- //链属企业信息表
|
|
|
- for(SysCompanySpare spare : spareList){
|
|
|
- //创建未认证企业
|
|
|
- iSysCompanySpareService.createSysCompanySpare(spare);
|
|
|
- //邀请操作
|
|
|
- String id = spare.getScpId();
|
|
|
- //联系人
|
|
|
- String scpContarct = spare.getScpContarct();
|
|
|
- //联系人手机号
|
|
|
- String scpContarctPhone = spare.getScpContarctPhone();
|
|
|
- if(CommonUtil.isNotEmpty(scpContarct) && CommonUtil.isNotEmpty(scpContarctPhone)) {
|
|
|
- //获取字典的阿里短信模板
|
|
|
- String templateCode = "SMS_222871823";
|
|
|
+// spareRelList.add(sysCompanySpare);
|
|
|
+ iSysCompanySpareService.createSysCompanySpare(sysCompanySpare);
|
|
|
+ //联系人
|
|
|
+ String scpContarct = sysCompanySpare.getScpContarct();
|
|
|
+ //联系人手机号
|
|
|
+ String scpContarctPhone = sysCompanySpare.getScpContarctPhone();
|
|
|
+ if(CommonUtil.isNotEmpty(scpContarct) && CommonUtil.isNotEmpty(scpContarctPhone)) {
|
|
|
+ //获取字典的阿里短信模板
|
|
|
+ String templateCode = "SMS_222871823";
|
|
|
// List<SysDictData> state = RedisUtils.getDictCache("aliyun_message_code");
|
|
|
// for (SysDictData sysDictData :state){
|
|
|
// if("yaoqing".equals(sysDictData.getDictLabel())) {
|
|
|
// templateCode = sysDictData.getDictValue();
|
|
|
// }
|
|
|
// }
|
|
|
- //获取url
|
|
|
- String url = configService.selectConfigByKey("zc_spare");
|
|
|
- Map msgMap = new HashMap();
|
|
|
- msgMap.put("companyName", scpContarct);
|
|
|
- msgMap.put("url", url);
|
|
|
- //发送短信
|
|
|
+ //获取url
|
|
|
+ String url = configService.selectConfigByKey("zc_spare");
|
|
|
+ Map msgMap = new HashMap();
|
|
|
+ msgMap.put("companyName", scpContarct);
|
|
|
+ msgMap.put("url", url);
|
|
|
+ //发送短信
|
|
|
// iMessageUtilsService.sendMessageCode(scpContarctPhone, templateCode, msgMap,null);
|
|
|
- //邀请次数赋值
|
|
|
- SysCompanySpare spares = iSysCompanySpareService.getById(id);
|
|
|
- spares.setScpInvite("1");
|
|
|
- iSysCompanySpareService.updateById(spares);
|
|
|
+ //邀请次数赋值
|
|
|
+ SysCompanySpare spares = iSysCompanySpareService.getById(id);
|
|
|
+ spares.setScpInvite("1");
|
|
|
+ iSysCompanySpareService.updateById(spares);
|
|
|
+ }
|
|
|
}
|
|
|
+ successNum++;
|
|
|
+ }
|
|
|
+ if(CommonUtil.isNotEmpty(userNameList)){
|
|
|
+ failureMsg.insert(0, "很抱歉,导入!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
+ throw new BaseException(failureMsg.toString());
|
|
|
+// return AjaxResult.success(failureMsg.toString());
|
|
|
}
|
|
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
|
|
|
return AjaxResult.success(successMsg.toString());
|