|
@@ -3,10 +3,12 @@ package cn.ezhizao.project.business.company.service.impl;
|
|
|
import cn.ezhizao.common.constant.HttpStatus;
|
|
|
import cn.ezhizao.common.exception.ServiceException;
|
|
|
import cn.ezhizao.common.utils.StringUtils;
|
|
|
+import cn.ezhizao.common.utils.bean.BeanUtils;
|
|
|
import cn.ezhizao.common.utils.bean.BeanValidators;
|
|
|
import cn.ezhizao.project.business.channel.domain.BizChannel;
|
|
|
import cn.ezhizao.project.business.channel.mapper.BizChannelMapper;
|
|
|
import cn.ezhizao.project.business.company.domain.BizCompany;
|
|
|
+import cn.ezhizao.project.business.company.domain.vo.ExportZero;
|
|
|
import cn.ezhizao.project.business.company.mapper.BizCompanyMapper;
|
|
|
import cn.ezhizao.project.business.company.service.IBizCompanyService;
|
|
|
import cn.ezhizao.project.business.companyContactor.domain.BizCompanyContactor;
|
|
@@ -17,14 +19,19 @@ import cn.ezhizao.project.business.settings.domain.BizSource;
|
|
|
import cn.ezhizao.project.business.settings.mapper.BizSourceMapper;
|
|
|
import cn.ezhizao.project.system.domain.SysUser;
|
|
|
import cn.ezhizao.project.system.mapper.SysUserMapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.validation.Validator;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* companyService业务层处理
|
|
@@ -185,6 +192,57 @@ public class BizCompanyServiceImpl extends ServiceImpl<BizCompanyMapper, BizCom
|
|
|
// return "";
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String importZero(List<ExportZero> companyList, long tenantId) {
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
+ int successNum = 0;
|
|
|
+ int failureNum = 0;
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
+ List<String> name = bizCompanyMapper.selectList(new LambdaQueryWrapper<BizCompany>()
|
|
|
+ .eq(BizCompany::getTenantId, tenantId)
|
|
|
+ ).stream().map(m ->m.getName()).collect(Collectors.toList());
|
|
|
+ for (ExportZero zero : companyList) {
|
|
|
+ try {
|
|
|
+ if (!name.contains(zero.getName())){
|
|
|
+ throw new Exception("不存在");
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ failureNum++;
|
|
|
+ String msg = "<br/>" + failureNum + "、客户 " + zero.getName() ;
|
|
|
+ failureMsg.append(msg + e.getMessage());
|
|
|
+ log.error(msg, e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<BizCompany> bizCompanyList = companyList.stream().map(m -> {
|
|
|
+ BizCompany bizCompany = new BizCompany();
|
|
|
+ bizCompany.setName(m.getName());
|
|
|
+ bizCompany.setIsZero(m.getIsZero().equals("零申报") ? 1 : 0);
|
|
|
+ bizCompany.setTenantId(tenantId);
|
|
|
+ return bizCompany;
|
|
|
+ }
|
|
|
+ ).collect(Collectors.toList());
|
|
|
+ List<BizCompany> list= this.list(new LambdaQueryWrapper<BizCompany>().eq(BizCompany::getTenantId, tenantId));
|
|
|
+ for (BizCompany bizCompany : bizCompanyList) {
|
|
|
+ for (BizCompany company : list) {
|
|
|
+ if(bizCompany.getName().trim().equals(company.getName().trim())) {
|
|
|
+ bizCompany.setId(company.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.updateBatchById(bizCompanyList);
|
|
|
+ if (failureNum > 0)
|
|
|
+ {
|
|
|
+ failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
+ throw new ServiceException(failureMsg.toString());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功!");
|
|
|
+ }
|
|
|
+// successMsg.append("零申报非零申报客户导入成功");
|
|
|
+ return successMsg.toString();
|
|
|
+ }
|
|
|
+
|
|
|
;
|
|
|
|
|
|
@Override
|
|
@@ -203,7 +261,10 @@ public class BizCompanyServiceImpl extends ServiceImpl<BizCompanyMapper, BizCom
|
|
|
}
|
|
|
@Override
|
|
|
public boolean updateById(BizCompany company) {
|
|
|
- if(this.query().eq("name", company.getName()).ne("id", company.getId() == null ? 0L :company.getId()).count() > 0) throw new ServiceException("客户名称重复", HttpStatus.ERROR);
|
|
|
+ if(this.query()
|
|
|
+ .eq("tenant_id",company.getTenantId())
|
|
|
+ .eq("name", company.getName())
|
|
|
+ .ne("id", company.getId() == null ? 0L :company.getId()).count() > 0) throw new ServiceException("客户名称重复", HttpStatus.ERROR);
|
|
|
AtomicBoolean res = new AtomicBoolean(super.updateById(company));
|
|
|
BizCompanyContactor delCondition = new BizCompanyContactor();
|
|
|
delCondition.setCompanyId(company.getId());
|