|
|
@@ -147,11 +147,6 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
corpsDesc.setIsDeleted(0);
|
|
|
corpsDesc.setStrTenantId(Arrays.asList(AuthUtil.getDeptId().split(",")));
|
|
|
|
|
|
- /*String role = AuthUtil.getUserRole();
|
|
|
- if (!role.contains("管理员")){
|
|
|
-
|
|
|
- }*/
|
|
|
-
|
|
|
IPage<CorpsDescVO> page1 = page.setRecords(baseMapper.selectCorpsDescPage(page, corpsDesc));
|
|
|
return page1;
|
|
|
|
|
|
@@ -242,6 +237,14 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
throw new SecurityException("请输入正确的业务员");
|
|
|
}
|
|
|
}
|
|
|
+ //获得所属公司
|
|
|
+ R<Dept> dept = sysClient.getDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
+ if (ObjectUtil.isNotEmpty(dept)) {
|
|
|
+ corpsDesc.setSalesCompanyId(dept.getData().getId());
|
|
|
+ corpsDesc.setSalesCompanyName(dept.getData().getFullName());
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("数据异常请联系管理员");
|
|
|
+ }
|
|
|
|
|
|
corpsDesc.setCreditLimit(e.getCreditLimit());
|
|
|
corpsDesc.setUseCreditLimit(e.getUseCreditLimit());
|
|
|
@@ -269,7 +272,9 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
corpsDesc.setCreateTime(new Date());
|
|
|
corpsDesc.setCreateUser(AuthUtil.getUserId());
|
|
|
corpsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
+
|
|
|
baseMapper.insert(corpsDesc);
|
|
|
+
|
|
|
PjCorpsTypeDesc middle = new PjCorpsTypeDesc();
|
|
|
middle.setCorpId(corpsDesc.getId());
|
|
|
middle.setCorpTypeId(corpsType.getId());
|
|
|
@@ -319,45 +324,130 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
List<Boolean> countList = new ArrayList<>();
|
|
|
|
|
|
data.forEach(e -> {
|
|
|
- countList.add(true);
|
|
|
- PjCorpsDesc corpsDesc = new PjCorpsDesc();
|
|
|
- corpsDesc.setCname(e.getCname());
|
|
|
- corpsDesc.setTel(e.getTel());
|
|
|
- corpsDesc.setTenantId(AuthUtil.getTenantId());
|
|
|
-
|
|
|
- //获得业务员
|
|
|
- if (StringUtils.isNotBlank(e.getSalesmanName())){
|
|
|
- List<User> user = userClient.userInfoByName(e.getSalesmanName(), AuthUtil.getTenantId());
|
|
|
- if (ObjectUtils.isNotNull(user)) {
|
|
|
- corpsDesc.setSalesmanId(user.get(0).getId());
|
|
|
- corpsDesc.setSalesmanName(user.get(0).getRealName());
|
|
|
- }else {
|
|
|
- throw new SecurityException("请输入正确的业务员");
|
|
|
+ String type = e.getType();
|
|
|
+ PjCorpsType corpsType = corpsTypeMapper.selectCorpsTypeCname(type, AuthUtil.getTenantId());
|
|
|
+ if (corpsType != null){
|
|
|
+ countList.add(true);
|
|
|
+ PjCorpsDesc corpsDesc = new PjCorpsDesc();
|
|
|
+ corpsDesc.setCname(e.getCname());
|
|
|
+ corpsDesc.setTel(e.getTel());
|
|
|
+ corpsDesc.setTenantId(AuthUtil.getTenantId());
|
|
|
+
|
|
|
+ //获得业务员
|
|
|
+ if (StringUtils.isNotBlank(e.getSalesmanName())){
|
|
|
+ List<User> user = userClient.userInfoByName(e.getSalesmanName(), AuthUtil.getTenantId());
|
|
|
+ if (ObjectUtils.isNotNull(user)) {
|
|
|
+ corpsDesc.setSalesmanId(user.get(0).getId());
|
|
|
+ corpsDesc.setSalesmanName(user.get(0).getRealName());
|
|
|
+ }else {
|
|
|
+ throw new SecurityException("请输入正确的业务员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获得所属公司
|
|
|
+ R<Dept> dept = sysClient.getDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
+ if (ObjectUtil.isNotEmpty(dept)) {
|
|
|
+ corpsDesc.setSalesCompanyId(dept.getData().getId());
|
|
|
+ corpsDesc.setSalesCompanyName(dept.getData().getFullName());
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("数据异常请联系管理员");
|
|
|
+ }
|
|
|
+
|
|
|
+ corpsDesc.setCorpsTypeId(String.valueOf(corpsType.getId()));
|
|
|
+ corpsDesc.setCorpType("GYS");
|
|
|
+ //名称相等视为重复数据
|
|
|
+ LambdaQueryWrapper<PjCorpsDesc> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(PjCorpsDesc::getCname, corpsDesc.getCname());
|
|
|
+ queryWrapper.like(PjCorpsDesc::getCorpType, "GYS");
|
|
|
+ queryWrapper.eq(PjCorpsDesc::getIsDeleted, 0);
|
|
|
+ PjCorpsDesc selectOne = baseMapper.selectOne(queryWrapper);
|
|
|
+ if (selectOne == null) {
|
|
|
+ corpsDesc.setCreateTime(new Date());
|
|
|
+ corpsDesc.setCreateUser(AuthUtil.getUserId());
|
|
|
+ corpsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
+ baseMapper.insert(corpsDesc);
|
|
|
+
|
|
|
+ PjCorpsTypeDesc middle = new PjCorpsTypeDesc();
|
|
|
+ middle.setCorpId(corpsDesc.getId());
|
|
|
+ middle.setCorpTypeId(corpsType.getId());
|
|
|
+ middle.setCreateTime(new Date());
|
|
|
+ middle.setCreateUser(AuthUtil.getUserId());
|
|
|
+ middle.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
+ corpsTypeDescMapper.insert(middle);
|
|
|
+ } else {
|
|
|
+ corpsDesc.setId(selectOne.getId());
|
|
|
+ corpsDesc.setUpdateTime(new Date());
|
|
|
+ corpsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ baseMapper.updateById(corpsDesc);
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存联系人
|
|
|
+ if (ObjectUtil.isEmpty(e.getAttnCname())){
|
|
|
+ LambdaQueryWrapper<PjCorpsAttn> corpsAttnLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ corpsAttnLambdaQueryWrapper.eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjCorpsAttn::getCname, e.getAttnCname())
|
|
|
+ .eq(PjCorpsAttn::getPid, corpsDesc.getId())
|
|
|
+ .eq(PjCorpsAttn::getIsDeleted, 0);
|
|
|
+ PjCorpsAttn corpsAttn = corpsAttnService.getOne(corpsAttnLambdaQueryWrapper);
|
|
|
+
|
|
|
+ corpsAttn.setPid(corpsDesc.getId());
|
|
|
+ corpsAttn.setCname(e.getAttnCname());
|
|
|
+ corpsAttn.setTel(e.getAttnTel());
|
|
|
+ if (corpsAttn.getId() == null) {
|
|
|
+ corpsAttn.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAttn.setCreateTime(new Date());
|
|
|
+ corpsAttn.setCreateUser(AuthUtil.getUserId());
|
|
|
+ corpsAttnService.save(corpsAttn);
|
|
|
+ } else {
|
|
|
+ corpsAttn.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAttn.setUpdateTime(new Date());
|
|
|
+ corpsAttn.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ corpsAttnService.updateById(corpsAttn);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //保存地址
|
|
|
+ if (ObjectUtil.isEmpty(e.getDetailedAddress())){
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(e.getDefaultAddres()) && "是".equals(e.getDefaultAddres())){
|
|
|
+ LambdaQueryWrapper<PjCorpsAddr> corpsAttnLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ corpsAttnLambdaQueryWrapper.eq(PjCorpsAddr::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjCorpsAddr::getDefaultAddres, "1")
|
|
|
+ .eq(PjCorpsAddr::getPid, corpsDesc.getId())
|
|
|
+ .eq(PjCorpsAddr::getIsDeleted, 0);
|
|
|
+ PjCorpsAddr corpsAddr = corpsAddrService.getOne(corpsAttnLambdaQueryWrapper);
|
|
|
+ if (ObjectUtil.isEmpty(corpsAddr)){
|
|
|
+ corpsAddr.setPid(corpsDesc.getId());
|
|
|
+ corpsAddr.setBelongtoarea(e.getBelongtoarea());
|
|
|
+ corpsAddr.setDetailedAddress(e.getDetailedAddress());
|
|
|
+ corpsAddr.setDefaultAddres("1");
|
|
|
+ corpsAddr.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAddr.setCreateTime(new Date());
|
|
|
+ corpsAddr.setCreateUser(AuthUtil.getUserId());
|
|
|
+ corpsAddrService.save(corpsAddr);
|
|
|
+ }else {
|
|
|
+ throw new RuntimeException(corpsDesc.getCname() + "已存在默认地址");
|
|
|
+ }
|
|
|
+ }else if (ObjectUtil.isNotEmpty(e.getDefaultAddres()) && "否".equals(e.getDefaultAddres())){
|
|
|
+ PjCorpsAddr corpsAddr = new PjCorpsAddr();
|
|
|
+ corpsAddr.setPid(corpsDesc.getId());
|
|
|
+ corpsAddr.setBelongtoarea(e.getBelongtoarea());
|
|
|
+ corpsAddr.setDetailedAddress(e.getDetailedAddress());
|
|
|
+ corpsAddr.setDefaultAddres("0");
|
|
|
+ corpsAddr.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAddr.setCreateTime(new Date());
|
|
|
+ corpsAddr.setCreateUser(AuthUtil.getUserId());
|
|
|
+ corpsAddrService.save(corpsAddr);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- corpsDesc.setCorpType("GYS");
|
|
|
- //名称相等视为重复数据
|
|
|
- LambdaQueryWrapper<PjCorpsDesc> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(PjCorpsDesc::getCname, corpsDesc.getCname());
|
|
|
- queryWrapper.like(PjCorpsDesc::getCorpType, "GYS");
|
|
|
- queryWrapper.eq(PjCorpsDesc::getIsDeleted, 0);
|
|
|
- PjCorpsDesc selectOne = baseMapper.selectOne(queryWrapper);
|
|
|
- if (selectOne == null) {
|
|
|
- corpsDesc.setCreateTime(new Date());
|
|
|
- corpsDesc.setCreateUser(AuthUtil.getUserId());
|
|
|
- corpsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
- baseMapper.insert(corpsDesc);
|
|
|
} else {
|
|
|
- corpsDesc.setId(selectOne.getId());
|
|
|
- corpsDesc.setUpdateTime(new Date());
|
|
|
- corpsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
- baseMapper.updateById(corpsDesc);
|
|
|
+ countList.add(false);
|
|
|
}
|
|
|
-
|
|
|
});
|
|
|
List<Boolean> booleanList = countList.stream().filter(e -> e == true).collect(Collectors.toList());
|
|
|
- if (data.size() == booleanList.size()) {
|
|
|
+ if (data.size() > booleanList.size()) {
|
|
|
+ return R.fail("导入中的数据,分类字段不存在或者未填分类字段");
|
|
|
+ } else if (data.size() == booleanList.size()) {
|
|
|
return R.success("导入成功");
|
|
|
} else {
|
|
|
throw new SecurityException("导入失败,请仔细检查导入数据");
|