|
|
@@ -39,8 +39,6 @@ import org.springblade.salesPart.excel.CorpsDescImportExcel;
|
|
|
import org.springblade.salesPart.excel.CorpsImportBrandExcel;
|
|
|
import org.springblade.salesPart.excel.SupplierImportExcel;
|
|
|
import org.springblade.salesPart.order.mapper.OrderMapper;
|
|
|
-import org.springblade.salesPart.settlement.mapper.SettlementMapper;
|
|
|
-import org.springblade.salesPart.ship.mapper.ShipMapper;
|
|
|
import org.springblade.salesPart.storage.service.IStorageDescService;
|
|
|
import org.springblade.salesPart.vo.CorpsDescVO;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
@@ -83,11 +81,6 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
|
|
|
private final OrderMapper orderMapper;
|
|
|
|
|
|
- private final ShipMapper shipMapper;
|
|
|
-
|
|
|
- private final SettlementMapper settlementMapper;
|
|
|
-
|
|
|
-
|
|
|
static final int GB_SP_DIFF = 160;
|
|
|
// 存放国标一级汉字不同读音的起始区位码
|
|
|
static final int[] secPosValueList = {1601, 1637, 1833, 2078, 2274, 2302, 2433, 2594, 2787, 3106, 3212, 3472, 3635,
|
|
|
@@ -307,219 +300,219 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R importUser(List<CorpsDescImportExcel> data) {
|
|
|
// try {
|
|
|
- if (CollectionUtils.isEmpty(data)) {
|
|
|
- throw new SecurityException("导入数据不能为空");
|
|
|
- }
|
|
|
- List<Boolean> countList = new ArrayList<>();
|
|
|
- List<String> typeList = data.stream().map(CorpsDescImportExcel::getType).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
- String type = String.join(",", typeList);
|
|
|
- List<PjCorpsType> pjCorpsTypeList = corpsTypeMapper.selectList(new LambdaQueryWrapper<PjCorpsType>()
|
|
|
- .eq(PjCorpsType::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjCorpsType::getIsDeleted, 0)
|
|
|
- .eq(PjCorpsType::getSalesCompanyId, Long.parseLong(AuthUtil.getDeptId()))
|
|
|
- .apply("find_in_set(cname,'" + type + "')")
|
|
|
- );
|
|
|
- if (typeList.isEmpty()) {
|
|
|
- throw new RuntimeException("分类不能为空");
|
|
|
- }
|
|
|
- if (pjCorpsTypeList.isEmpty()) {
|
|
|
- throw new RuntimeException("分类不能为空");
|
|
|
- }
|
|
|
- if (pjCorpsTypeList.size() < typeList.size()) {
|
|
|
- throw new RuntimeException("导入中的数据,分类字段不存在或者未填分类字段");
|
|
|
- }
|
|
|
- List<User> user = userClient.getUserByRole();
|
|
|
- if (user.isEmpty()) {
|
|
|
- throw new RuntimeException("未查到业务员信息");
|
|
|
- }
|
|
|
- //获得所属公司
|
|
|
- Long salesCompanyId;
|
|
|
- String salesCompanyName;
|
|
|
- String appletsId;
|
|
|
- R<Dept> dept = sysClient.getDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
- if (ObjectUtil.isNotEmpty(dept)) {
|
|
|
- salesCompanyId = dept.getData().getId();
|
|
|
- salesCompanyName = dept.getData().getFullName();
|
|
|
- appletsId = dept.getData().getAppletsId();
|
|
|
- } else {
|
|
|
- throw new SecurityException("数据异常请联系管理员");
|
|
|
- }
|
|
|
- String deliveryWarehouse = data.stream().map(CorpsDescImportExcel::getDeliveryWarehouseName).filter(Objects::nonNull).distinct().collect(Collectors.joining(","));
|
|
|
- List<PjStorageDesc> storageDescList = storageDescService.list(new LambdaQueryWrapper<PjStorageDesc>()
|
|
|
- .eq(PjStorageDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjStorageDesc::getIsDeleted, 0)
|
|
|
- .apply("find_in_set(cname,'" + deliveryWarehouse + "')"));
|
|
|
- if (storageDescList.isEmpty()) {
|
|
|
- throw new RuntimeException("未查到仓库信息");
|
|
|
- }
|
|
|
- String brandName = data.stream().map(CorpsDescImportExcel::getBrandName).filter(Objects::nonNull).distinct().collect(Collectors.joining(","));
|
|
|
- List<PjBrandDesc> pjBrandDescList = brandDescService.list(new LambdaQueryWrapper<PjBrandDesc>()
|
|
|
- .eq(PjBrandDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjBrandDesc::getIsDeleted, 0)
|
|
|
- .apply("find_in_set(cname,'" + brandName + "')"));
|
|
|
- R<String> r = sysClient.getRoleIds(AuthUtil.getTenantId(), "客户");
|
|
|
- for (CorpsDescImportExcel e : data) {
|
|
|
- PjCorpsType corpsType = pjCorpsTypeList.stream().filter(item -> item.getCname().equals(e.getType())).findFirst().orElse(null);
|
|
|
- if (corpsType != null) {
|
|
|
- countList.add(true);
|
|
|
- PjCorpsDesc corpsDesc = new PjCorpsDesc();
|
|
|
- corpsDesc.setCname(e.getCname());
|
|
|
- corpsDesc.setTel(e.getTel());
|
|
|
- corpsDesc.setTenantId(AuthUtil.getTenantId());
|
|
|
- corpsDesc.setPriceSystem(e.getPriceSystem());
|
|
|
- corpsDesc.setAccountPeriod(e.getAccountPeriod());
|
|
|
- //获得业务员
|
|
|
- if (StringUtils.isNotBlank(e.getSalesmanName())) {
|
|
|
- User user1 = user.stream().filter(item -> item.getRealName().equals(e.getSalesmanName())).findFirst().orElse(null);
|
|
|
- if (user1 != null) {
|
|
|
- corpsDesc.setSalesmanId(user1.getId());
|
|
|
- corpsDesc.setSalesmanName(user1.getRealName());
|
|
|
- } else {
|
|
|
- throw new SecurityException("请输入正确的业务员");
|
|
|
- }
|
|
|
+ if (CollectionUtils.isEmpty(data)) {
|
|
|
+ throw new SecurityException("导入数据不能为空");
|
|
|
+ }
|
|
|
+ List<Boolean> countList = new ArrayList<>();
|
|
|
+ List<String> typeList = data.stream().map(CorpsDescImportExcel::getType).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
|
|
+ String type = String.join(",", typeList);
|
|
|
+ List<PjCorpsType> pjCorpsTypeList = corpsTypeMapper.selectList(new LambdaQueryWrapper<PjCorpsType>()
|
|
|
+ .eq(PjCorpsType::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjCorpsType::getIsDeleted, 0)
|
|
|
+ .eq(PjCorpsType::getSalesCompanyId, Long.parseLong(AuthUtil.getDeptId()))
|
|
|
+ .apply("find_in_set(cname,'" + type + "')")
|
|
|
+ );
|
|
|
+ if (typeList.isEmpty()) {
|
|
|
+ throw new RuntimeException("分类不能为空");
|
|
|
+ }
|
|
|
+ if (pjCorpsTypeList.isEmpty()) {
|
|
|
+ throw new RuntimeException("分类不能为空");
|
|
|
+ }
|
|
|
+ if (pjCorpsTypeList.size() < typeList.size()) {
|
|
|
+ throw new RuntimeException("导入中的数据,分类字段不存在或者未填分类字段");
|
|
|
+ }
|
|
|
+ List<User> user = userClient.getUserByRole();
|
|
|
+ if (user.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到业务员信息");
|
|
|
+ }
|
|
|
+ //获得所属公司
|
|
|
+ Long salesCompanyId;
|
|
|
+ String salesCompanyName;
|
|
|
+ String appletsId;
|
|
|
+ R<Dept> dept = sysClient.getDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
+ if (ObjectUtil.isNotEmpty(dept)) {
|
|
|
+ salesCompanyId = dept.getData().getId();
|
|
|
+ salesCompanyName = dept.getData().getFullName();
|
|
|
+ appletsId = dept.getData().getAppletsId();
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("数据异常请联系管理员");
|
|
|
+ }
|
|
|
+ String deliveryWarehouse = data.stream().map(CorpsDescImportExcel::getDeliveryWarehouseName).filter(Objects::nonNull).distinct().collect(Collectors.joining(","));
|
|
|
+ List<PjStorageDesc> storageDescList = storageDescService.list(new LambdaQueryWrapper<PjStorageDesc>()
|
|
|
+ .eq(PjStorageDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjStorageDesc::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(cname,'" + deliveryWarehouse + "')"));
|
|
|
+ if (storageDescList.isEmpty()) {
|
|
|
+ throw new RuntimeException("未查到仓库信息");
|
|
|
+ }
|
|
|
+ String brandName = data.stream().map(CorpsDescImportExcel::getBrandName).filter(Objects::nonNull).distinct().collect(Collectors.joining(","));
|
|
|
+ List<PjBrandDesc> pjBrandDescList = brandDescService.list(new LambdaQueryWrapper<PjBrandDesc>()
|
|
|
+ .eq(PjBrandDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjBrandDesc::getIsDeleted, 0)
|
|
|
+ .apply("find_in_set(cname,'" + brandName + "')"));
|
|
|
+ R<String> r = sysClient.getRoleIds(AuthUtil.getTenantId(), "客户");
|
|
|
+ for (CorpsDescImportExcel e : data) {
|
|
|
+ PjCorpsType corpsType = pjCorpsTypeList.stream().filter(item -> item.getCname().equals(e.getType())).findFirst().orElse(null);
|
|
|
+ if (corpsType != null) {
|
|
|
+ countList.add(true);
|
|
|
+ PjCorpsDesc corpsDesc = new PjCorpsDesc();
|
|
|
+ corpsDesc.setCname(e.getCname());
|
|
|
+ corpsDesc.setTel(e.getTel());
|
|
|
+ corpsDesc.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsDesc.setPriceSystem(e.getPriceSystem());
|
|
|
+ corpsDesc.setAccountPeriod(e.getAccountPeriod());
|
|
|
+ //获得业务员
|
|
|
+ if (StringUtils.isNotBlank(e.getSalesmanName())) {
|
|
|
+ User user1 = user.stream().filter(item -> item.getRealName().equals(e.getSalesmanName())).findFirst().orElse(null);
|
|
|
+ if (user1 != null) {
|
|
|
+ corpsDesc.setSalesmanId(user1.getId());
|
|
|
+ corpsDesc.setSalesmanName(user1.getRealName());
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("请输入正确的业务员");
|
|
|
}
|
|
|
- corpsDesc.setSalesCompanyId(salesCompanyId);
|
|
|
- corpsDesc.setSalesCompanyName(salesCompanyName);
|
|
|
- corpsDesc.setCreditLimit(e.getCreditLimit());
|
|
|
- corpsDesc.setUseCreditLimit(e.getUseCreditLimit());
|
|
|
-
|
|
|
- //获得仓库
|
|
|
- if (StringUtils.isNotBlank(e.getDeliveryWarehouseName())) {
|
|
|
- PjStorageDesc storageDesc = storageDescList.stream().filter(item -> item.getCname().equals(e.getDeliveryWarehouseName())).findFirst().orElse(null);
|
|
|
- if (storageDesc != null) {
|
|
|
- corpsDesc.setDeliveryWarehouseId(storageDesc.getId());
|
|
|
- corpsDesc.setDeliveryWarehouseName(storageDesc.getCname());
|
|
|
- } else {
|
|
|
- throw new SecurityException("请输入正确的仓库");
|
|
|
- }
|
|
|
+ }
|
|
|
+ corpsDesc.setSalesCompanyId(salesCompanyId);
|
|
|
+ corpsDesc.setSalesCompanyName(salesCompanyName);
|
|
|
+ corpsDesc.setCreditLimit(e.getCreditLimit());
|
|
|
+ corpsDesc.setUseCreditLimit(e.getUseCreditLimit());
|
|
|
+
|
|
|
+ //获得仓库
|
|
|
+ if (StringUtils.isNotBlank(e.getDeliveryWarehouseName())) {
|
|
|
+ PjStorageDesc storageDesc = storageDescList.stream().filter(item -> item.getCname().equals(e.getDeliveryWarehouseName())).findFirst().orElse(null);
|
|
|
+ if (storageDesc != null) {
|
|
|
+ corpsDesc.setDeliveryWarehouseId(storageDesc.getId());
|
|
|
+ corpsDesc.setDeliveryWarehouseName(storageDesc.getCname());
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("请输入正确的仓库");
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- corpsDesc.setCorpsTypeId(String.valueOf(corpsType.getId()));
|
|
|
- corpsDesc.setCorpType("KH");
|
|
|
- if (ObjectUtils.isNotNull(e.getBrandName())){
|
|
|
- List<String> list = Arrays.asList(e.getBrandName().split(","));
|
|
|
- if (!pjBrandDescList.isEmpty()) {
|
|
|
- List<PjBrandDesc> pjBrandDescs = pjBrandDescList.stream().filter(item -> list.contains(item.getCname())).distinct().collect(Collectors.toList());
|
|
|
- if (!pjBrandDescs.isEmpty()) {
|
|
|
- corpsDesc.setBrandName(pjBrandDescList.stream().map(PjBrandDesc::getCname).distinct().collect(Collectors.joining(",")));
|
|
|
- StringBuilder brandIds = new StringBuilder();
|
|
|
- for (PjBrandDesc item : pjBrandDescList) {
|
|
|
- brandIds.append(item.getId()).append(",");
|
|
|
- }
|
|
|
- if (ObjectUtils.isNotNull(brandIds.toString())) {
|
|
|
- corpsDesc.setBrandId(brandIds.substring(0, brandIds.length() - 1));
|
|
|
- }
|
|
|
- corpsDesc.setBrandName(pjBrandDescList.stream().map(PjBrandDesc::getCname).distinct().collect(Collectors.joining(",")));
|
|
|
+ corpsDesc.setCorpsTypeId(String.valueOf(corpsType.getId()));
|
|
|
+ corpsDesc.setCorpType("KH");
|
|
|
+ if (ObjectUtils.isNotNull(e.getBrandName())) {
|
|
|
+ List<String> list = Arrays.asList(e.getBrandName().split(","));
|
|
|
+ if (!pjBrandDescList.isEmpty()) {
|
|
|
+ List<PjBrandDesc> pjBrandDescs = pjBrandDescList.stream().filter(item -> list.contains(item.getCname())).distinct().collect(Collectors.toList());
|
|
|
+ if (!pjBrandDescs.isEmpty()) {
|
|
|
+ corpsDesc.setBrandName(pjBrandDescList.stream().map(PjBrandDesc::getCname).distinct().collect(Collectors.joining(",")));
|
|
|
+ StringBuilder brandIds = new StringBuilder();
|
|
|
+ for (PjBrandDesc item : pjBrandDescList) {
|
|
|
+ brandIds.append(item.getId()).append(",");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(brandIds.toString())) {
|
|
|
+ corpsDesc.setBrandId(brandIds.substring(0, brandIds.length() - 1));
|
|
|
}
|
|
|
+ corpsDesc.setBrandName(pjBrandDescList.stream().map(PjBrandDesc::getCname).distinct().collect(Collectors.joining(",")));
|
|
|
}
|
|
|
}
|
|
|
- //名称相等视为重复数据
|
|
|
- LambdaQueryWrapper<PjCorpsDesc> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(PjCorpsDesc::getCname, corpsDesc.getCname());
|
|
|
- queryWrapper.like(PjCorpsDesc::getCorpType, "KH");
|
|
|
- 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()));
|
|
|
- corpsDesc.setCheckStatus("通过");
|
|
|
- baseMapper.insert(corpsDesc);
|
|
|
- PjCorpsTypeDesc middle = new PjCorpsTypeDesc();
|
|
|
- middle.setCorpId(corpsDesc.getId());
|
|
|
- middle.setCorpTypeId(corpsType.getId());
|
|
|
- middle.setCreateTime(new Date());
|
|
|
- middle.setTenantId(AuthUtil.getTenantId());
|
|
|
- middle.setCreateUser(AuthUtil.getUserId());
|
|
|
- middle.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
- corpsTypeDescMapper.insert(middle);
|
|
|
- if (ObjectUtils.isNotNull(corpsDesc.getTel())){
|
|
|
- User userData = userClient.loginByAccount("", corpsDesc.getTel(), "4", AuthUtil.getTenantId(), appletsId);
|
|
|
- if (ObjectUtils.isNull(userData)) {
|
|
|
- //用户不存在,注册用户
|
|
|
- User saveUser = new User();
|
|
|
- saveUser.setAppletsId(appletsId);
|
|
|
- saveUser.setTenantId(AuthUtil.getTenantId());
|
|
|
- saveUser.setAccount(corpsDesc.getTel());
|
|
|
- saveUser.setName(corpsDesc.getTel());
|
|
|
- saveUser.setRealName(corpsDesc.getTel());
|
|
|
- saveUser.setUserType(4);
|
|
|
- saveUser.setPhone(corpsDesc.getTel());
|
|
|
- saveUser.setDeptId(AuthUtil.getDeptId());
|
|
|
- //获取注册用户类型
|
|
|
- if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
- saveUser.setRoleId(r.getData());
|
|
|
- } else {
|
|
|
- saveUser.setRoleId("");
|
|
|
- }
|
|
|
- saveUser.setPassword("123456");
|
|
|
- R<Boolean> result = userClient.saveUser(saveUser);
|
|
|
- if (!result.isSuccess()) {
|
|
|
- throw new RuntimeException(result.getMsg());
|
|
|
- }
|
|
|
- R<UserInfo> resu = userClient.userInfo(AuthUtil.getTenantId(), corpsDesc.getTel(), UserEnum.WECHAT.getName());
|
|
|
- if (resu.isSuccess()) {
|
|
|
- userData = resu.getData().getUser();
|
|
|
- } else {
|
|
|
- throw new RuntimeException("创建用户失败");
|
|
|
- }
|
|
|
+ }
|
|
|
+ //名称相等视为重复数据
|
|
|
+ LambdaQueryWrapper<PjCorpsDesc> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(PjCorpsDesc::getCname, corpsDesc.getCname());
|
|
|
+ queryWrapper.like(PjCorpsDesc::getCorpType, "KH");
|
|
|
+ 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()));
|
|
|
+ corpsDesc.setCheckStatus("通过");
|
|
|
+ baseMapper.insert(corpsDesc);
|
|
|
+ PjCorpsTypeDesc middle = new PjCorpsTypeDesc();
|
|
|
+ middle.setCorpId(corpsDesc.getId());
|
|
|
+ middle.setCorpTypeId(corpsType.getId());
|
|
|
+ middle.setCreateTime(new Date());
|
|
|
+ middle.setTenantId(AuthUtil.getTenantId());
|
|
|
+ middle.setCreateUser(AuthUtil.getUserId());
|
|
|
+ middle.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
+ corpsTypeDescMapper.insert(middle);
|
|
|
+ if (ObjectUtils.isNotNull(corpsDesc.getTel())) {
|
|
|
+ User userData = userClient.loginByAccount("", corpsDesc.getTel(), "4", AuthUtil.getTenantId(), appletsId);
|
|
|
+ if (ObjectUtils.isNull(userData)) {
|
|
|
+ //用户不存在,注册用户
|
|
|
+ User saveUser = new User();
|
|
|
+ saveUser.setAppletsId(appletsId);
|
|
|
+ saveUser.setTenantId(AuthUtil.getTenantId());
|
|
|
+ saveUser.setAccount(corpsDesc.getTel());
|
|
|
+ saveUser.setName(corpsDesc.getTel());
|
|
|
+ saveUser.setRealName(corpsDesc.getTel());
|
|
|
+ saveUser.setUserType(4);
|
|
|
+ saveUser.setPhone(corpsDesc.getTel());
|
|
|
+ saveUser.setDeptId(AuthUtil.getDeptId());
|
|
|
+ //获取注册用户类型
|
|
|
+ if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
|
|
|
+ saveUser.setRoleId(r.getData());
|
|
|
+ } else {
|
|
|
+ saveUser.setRoleId("");
|
|
|
}
|
|
|
- //保存客户联系人信息
|
|
|
- PjCorpsAttn corpsAttn = new PjCorpsAttn();
|
|
|
- if (ObjectUtils.isNotNull(userData)) {
|
|
|
- long count = corpsAttnService.count(new LambdaQueryWrapper<PjCorpsAttn>()
|
|
|
- .eq(PjCorpsAttn::getUserId, userData.getId())
|
|
|
- .eq(PjCorpsAttn::getTel, corpsDesc.getTel())
|
|
|
- .eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjCorpsAttn::getIsDeleted, 0));
|
|
|
- if (count > 0) {
|
|
|
- throw new RuntimeException("手机号已存在,提交失败");
|
|
|
- }
|
|
|
- corpsAttn.setUserId(userData.getId());
|
|
|
+ saveUser.setPassword("123456");
|
|
|
+ R<Boolean> result = userClient.saveUser(saveUser);
|
|
|
+ if (!result.isSuccess()) {
|
|
|
+ throw new RuntimeException(result.getMsg());
|
|
|
+ }
|
|
|
+ R<UserInfo> resu = userClient.userInfo(AuthUtil.getTenantId(), corpsDesc.getTel(), UserEnum.WECHAT.getName());
|
|
|
+ if (resu.isSuccess()) {
|
|
|
+ userData = resu.getData().getUser();
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("创建用户失败");
|
|
|
}
|
|
|
- corpsAttn.setCname(e.getContacts());
|
|
|
- corpsAttn.setTel(e.getTel());
|
|
|
- corpsAttn.setTenantId(AuthUtil.getTenantId());
|
|
|
- corpsAttn.setPid(corpsDesc.getId());
|
|
|
- corpsAttn.setCreateTime(new Date());
|
|
|
- corpsAttn.setTenantId(AuthUtil.getTenantId());
|
|
|
- corpsAttn.setCreateUser(AuthUtil.getUserId());
|
|
|
- corpsAttn.setSalesCompanyId(salesCompanyId);
|
|
|
- corpsAttn.setSalesCompanyName(salesCompanyName);
|
|
|
- corpsAttnService.save(corpsAttn);
|
|
|
-
|
|
|
- //保存客户地址信息
|
|
|
- PjCorpsAddr corpsAddr = new PjCorpsAddr();
|
|
|
- corpsAddr.setContacts(e.getContacts());
|
|
|
- corpsAddr.setTel(e.getTel());
|
|
|
- corpsAddr.setBelongtoarea(e.getAddress());
|
|
|
- corpsAddr.setDetailedAddress(e.getAddress());
|
|
|
- corpsAddr.setTenantId(AuthUtil.getTenantId());
|
|
|
- corpsAddr.setPid(corpsDesc.getId());
|
|
|
- corpsAddr.setCreateTime(new Date());
|
|
|
- corpsAddr.setTenantId(AuthUtil.getTenantId());
|
|
|
- corpsAddr.setCreateUser(AuthUtil.getUserId());
|
|
|
- corpsAddr.setDefaultAddres("1");
|
|
|
- corpsAddrService.save(corpsAddr);
|
|
|
}
|
|
|
- } else {
|
|
|
- corpsDesc.setId(selectOne.getId());
|
|
|
- corpsDesc.setUpdateTime(new Date());
|
|
|
- corpsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
- baseMapper.updateById(corpsDesc);
|
|
|
+ //保存客户联系人信息
|
|
|
+ PjCorpsAttn corpsAttn = new PjCorpsAttn();
|
|
|
+ if (ObjectUtils.isNotNull(userData)) {
|
|
|
+ long count = corpsAttnService.count(new LambdaQueryWrapper<PjCorpsAttn>()
|
|
|
+ .eq(PjCorpsAttn::getUserId, userData.getId())
|
|
|
+ .eq(PjCorpsAttn::getTel, corpsDesc.getTel())
|
|
|
+ .eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjCorpsAttn::getIsDeleted, 0));
|
|
|
+ if (count > 0) {
|
|
|
+ throw new RuntimeException("手机号已存在,提交失败");
|
|
|
+ }
|
|
|
+ corpsAttn.setUserId(userData.getId());
|
|
|
+ }
|
|
|
+ corpsAttn.setCname(e.getContacts());
|
|
|
+ corpsAttn.setTel(e.getTel());
|
|
|
+ corpsAttn.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAttn.setPid(corpsDesc.getId());
|
|
|
+ corpsAttn.setCreateTime(new Date());
|
|
|
+ corpsAttn.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAttn.setCreateUser(AuthUtil.getUserId());
|
|
|
+ corpsAttn.setSalesCompanyId(salesCompanyId);
|
|
|
+ corpsAttn.setSalesCompanyName(salesCompanyName);
|
|
|
+ corpsAttnService.save(corpsAttn);
|
|
|
+
|
|
|
+ //保存客户地址信息
|
|
|
+ PjCorpsAddr corpsAddr = new PjCorpsAddr();
|
|
|
+ corpsAddr.setContacts(e.getContacts());
|
|
|
+ corpsAddr.setTel(e.getTel());
|
|
|
+ corpsAddr.setBelongtoarea(e.getAddress());
|
|
|
+ corpsAddr.setDetailedAddress(e.getAddress());
|
|
|
+ corpsAddr.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAddr.setPid(corpsDesc.getId());
|
|
|
+ corpsAddr.setCreateTime(new Date());
|
|
|
+ corpsAddr.setTenantId(AuthUtil.getTenantId());
|
|
|
+ corpsAddr.setCreateUser(AuthUtil.getUserId());
|
|
|
+ corpsAddr.setDefaultAddres("1");
|
|
|
+ corpsAddrService.save(corpsAddr);
|
|
|
}
|
|
|
} else {
|
|
|
- countList.add(false);
|
|
|
+ corpsDesc.setId(selectOne.getId());
|
|
|
+ corpsDesc.setUpdateTime(new Date());
|
|
|
+ corpsDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
+ baseMapper.updateById(corpsDesc);
|
|
|
}
|
|
|
- }
|
|
|
- List<Boolean> booleanList = countList.stream().filter(e -> e).collect(Collectors.toList());
|
|
|
- if (data.size() > booleanList.size()) {
|
|
|
- return R.fail("导入中的数据,分类字段不存在或者未填分类字段");
|
|
|
- } else if (data.size() == booleanList.size()) {
|
|
|
- return R.success("导入成功");
|
|
|
} else {
|
|
|
- throw new SecurityException("导入失败,请仔细检查导入数据");
|
|
|
+ countList.add(false);
|
|
|
}
|
|
|
+ }
|
|
|
+ List<Boolean> booleanList = countList.stream().filter(e -> e).collect(Collectors.toList());
|
|
|
+ if (data.size() > booleanList.size()) {
|
|
|
+ return R.fail("导入中的数据,分类字段不存在或者未填分类字段");
|
|
|
+ } else if (data.size() == booleanList.size()) {
|
|
|
+ return R.success("导入成功");
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("导入失败,请仔细检查导入数据");
|
|
|
+ }
|
|
|
|
|
|
/*} catch (Exception exception) {
|
|
|
throw new SecurityException("请检查导入数据" + exception.getMessage());
|
|
|
@@ -610,7 +603,7 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
.eq(PjCorpsAttn::getIsDeleted, 0);
|
|
|
PjCorpsAttn corpsAttn = corpsAttnService.getOne(corpsAttnLambdaQueryWrapper);
|
|
|
if (corpsAttn == null) {
|
|
|
- if (ObjectUtils.isNotNull(e.getAttnCname())){
|
|
|
+ if (ObjectUtils.isNotNull(e.getAttnCname())) {
|
|
|
corpsAttn = new PjCorpsAttn();
|
|
|
corpsAttn.setPid(corpsDesc.getId());
|
|
|
corpsAttn.setCname(e.getAttnCname());
|
|
|
@@ -1200,6 +1193,35 @@ public class CorpsDescServiceImpl extends ServiceImpl<CorpsDescMapper, PjCorpsDe
|
|
|
return baseMapper.selectCorpList(tenantId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public IPage<PjCorpsDesc> appCustomerAnalysis(IPage<PjCorpsDesc> page, PjCorpsDesc corpsDescDto) {
|
|
|
+ List<PjCorpsDesc> corpsDescList = baseMapper.appCustomerAnalysis(page, corpsDescDto);
|
|
|
+ Date date = new Date();
|
|
|
+ for (PjCorpsDesc item : corpsDescList) {
|
|
|
+ if (ObjectUtils.isNotNull(item.getBusinesDate())) {
|
|
|
+ long msNum = date.getTime() - item.getBusinesDate().getTime();
|
|
|
+ long dayNum = msNum / (24 * 60 * 60 * 1000);
|
|
|
+ item.setDays(dayNum);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return page.setRecords(corpsDescList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PjCorpsDesc appCustomerAnalysisDetail(Long id) {
|
|
|
+ PjCorpsDesc corpsDesc = baseMapper.selectById(id);
|
|
|
+ List<PjCorpsAttn> corpsAttnList = corpsAttnService.list(new LambdaQueryWrapper<PjCorpsAttn>()
|
|
|
+ .eq(PjCorpsAttn::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjCorpsAttn::getIsDeleted, 0)
|
|
|
+ .eq(PjCorpsAttn::getPid, id));
|
|
|
+ if (!corpsAttnList.isEmpty()) {
|
|
|
+ List<PjCorpsAttn> attnList = corpsAttnList.stream().filter(e -> e.getPid().equals(id))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ corpsDesc.setCorpsAttnList(attnList.isEmpty() ? new ArrayList<>() : attnList);
|
|
|
+ }
|
|
|
+ return corpsDesc;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 小程序新增或修改 客户详情
|
|
|
*
|