diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerAppletDao.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerAppletDao.java index bd6adbf7..21cc17ed 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerAppletDao.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerAppletDao.java @@ -29,6 +29,8 @@ public interface CustomerAppletDao extends BaseMapper { Boolean updateCustomer(@Param("customer") CustomerEntity customerEntity); + Long getCompanyIdByCustomerId(Long customerId); + Integer getCompanyId(Integer customerId); IPage getApplicationRecord(Page page, @Param("companyId")Integer companyId, @Param("status")Integer status); diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerDao.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerDao.java index 631968ba..79bc6040 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerDao.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/dao/CustomerDao.java @@ -36,6 +36,8 @@ public interface CustomerDao extends BaseMapper { List listCustomerId(); + List listCompanyCustomerIds(); + List queryCompanyCodeAndName(int type); String getCodeByType(Integer type); diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerAppletServiceImpl.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerAppletServiceImpl.java index 6dd29159..1963e266 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerAppletServiceImpl.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerAppletServiceImpl.java @@ -291,25 +291,28 @@ public class CustomerAppletServiceImpl extends ServiceImpl() .eq("customer_id", companyCustomerEntity.getCustomerId())); + // 添加关联人 + Long companyId = this.getBaseMapper().getCompanyIdByCustomerId((long)customerId); + if (null != companyId) { + companyCustomerEntity.setId(companyId); + //根据企业id删除关联关系 + crmsCustomerRelatedMapper.delete(new QueryWrapper().eq("customer_id", companyCustomerEntity.getId())); - //根据企业id删除关联关系 - crmsCustomerRelatedMapper.delete(new QueryWrapper().eq("customer_id", companyCustomerEntity.getId())); - - //绑定关联关系 - List relatedList = new ArrayList<>(); - List intList = companyAppletRequest.getRelatedId(); + //绑定关联关系 + List relatedList = new ArrayList<>(); + List intList = companyAppletRequest.getRelatedId(); - for (int i = 0; i < intList.size(); i++) { - CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated(); - Integer integer = intList.get(i); - crmsCustomerRelated.setCustomerId(companyCustomerEntity.getId().intValue());//企业id - crmsCustomerRelated.setRelatedId(integer);//关联人/企业id - relatedList.add(crmsCustomerRelated); - } - if (relatedList.size() > 0) { - crmsCustomerRelatedService.insertCustomerRelated(relatedList); + for (int i = 0; i < intList.size(); i++) { + CrmsCustomerRelated crmsCustomerRelated = new CrmsCustomerRelated(); + Integer integer = intList.get(i); + crmsCustomerRelated.setCustomerId(companyCustomerEntity.getId().intValue());//企业id + crmsCustomerRelated.setRelatedId(integer);//关联人/企业id + relatedList.add(crmsCustomerRelated); + } + if (relatedList.size() > 0) { + crmsCustomerRelatedService.insertCustomerRelated(relatedList); + } } - if (customer && company > 0) { return true; } diff --git a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java index 4d1178f3..46e828bb 100644 --- a/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java +++ b/dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java @@ -77,7 +77,7 @@ public class CustomerServiceImpl extends ServiceImpl companyList = new ArrayList<>(); - List personalList = new ArrayList<>(); + /*List personalList = new ArrayList<>(); List longList = customerDao.listCustomerId(); if (longList != null) { for (Long id : longList) { @@ -350,6 +350,17 @@ public class CustomerServiceImpl extends ServiceImpl longList = customerDao.listCompanyCustomerIds(); + if (null != longList) { + for (Long id : longList) { + ResponseResult responseResult = this.getCustomerById(id); + if (null != responseResult) { + companyList.add((CustomerCompanyVO) responseResult.getData()); + } + } + } + ExcelUtil.writeExcelWithSheets(response, companyList,"客户资源信息一览表","企业类型", new CustomerCompanyVO()) .finish(); } catch (Exception e) { ExceptionCast.cast(CrmsCode.CUSTOMER_EXPORT_EXSIT); @@ -363,9 +374,11 @@ public class CustomerServiceImpl extends ServiceImpl companyTemplates = new ArrayList<>(); - List personalTemplates = new ArrayList<>(); + /*List personalTemplates = new ArrayList<>(); ExcelUtil.writeExcelWithSheets(response, personalTemplates, "客户资源信息表模板", "个人类型", new PersonalTemplate()) .write(companyTemplates, "企业类型", new CompanyTemplate()) + .finish();*/ + ExcelUtil.writeExcelWithSheets(response, companyTemplates,"客户资源信息表模板","企业类型", new CompanyTemplate()) .finish(); } catch (Exception e) { ExceptionCast.cast(CrmsCode.CUSTOMER_EXPORTTEMPLATE_EXSIT); @@ -385,17 +398,17 @@ public class CustomerServiceImpl extends ServiceImpl personalList = ExcelUtil.readExcel(excel, new PersonalTemplate(), 1); - List companyList = ExcelUtil.readExcel(excel, new CompanyTemplate(), 2); - /*List nameList = hrmsFeignService.listEmployeeName().getData();*/ + List companyList = ExcelUtil.readExcel(excel, new CompanyTemplate(), 1); + /*List personalList = ExcelUtil.readExcel(excel, new PersonalTemplate(), 1); + List nameList = hrmsFeignService.listEmployeeName().getData(); CustomerPersonalTOI customerPersonalTOI; - /*ManagerName manager; // 客户名称*/ + ManagerName manager; // 客户名称 // 个人类型 for (Object personal : personalList) { customerPersonalTOI = new CustomerPersonalTOI(); customerPersonalTOI.setType(0); BeanUtils.copyProperties(personal, customerPersonalTOI); - /*manager = new ManagerName(); + manager = new ManagerName(); BeanUtils.copyProperties(personal, manager); // 根据客户经理名称找到对应的员工id if (nameList != null && manager.getManager() != null) { @@ -407,9 +420,9 @@ public class CustomerServiceImpl extends ServiceImpl().FAIL("导入数据失败,员工" + manager.getManager() + "不存在"); } - }*/ + } this.saveCustomerPersonal(customerPersonalTOI); - } + }*/ // 企业类型 for (Object company : companyList) { CompanyCustomerRequest companyCustomerRequest = new CompanyCustomerRequest(); diff --git a/dq-financial-crms/src/main/resources/mapper/crms/CustomerAppletDao.xml b/dq-financial-crms/src/main/resources/mapper/crms/CustomerAppletDao.xml index a2196242..321e4a6f 100644 --- a/dq-financial-crms/src/main/resources/mapper/crms/CustomerAppletDao.xml +++ b/dq-financial-crms/src/main/resources/mapper/crms/CustomerAppletDao.xml @@ -30,6 +30,11 @@ WHERE id = #{customer.id} + + + + + +