From 22ae6c453955f85566e8c4899cd54e970fb93e45 Mon Sep 17 00:00:00 2001 From: river <1376754470@qq.com> Date: Mon, 29 Mar 2021 16:13:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E5=B0=8F=E7=A8=8B=E5=BA=8F?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AE=A4=E8=AF=81=E4=BF=A1=E6=81=AF=E6=97=B6?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=85=B3=E8=81=94=E4=BA=BA=E7=A9=BA=E6=8C=87?= =?UTF-8?q?=E9=92=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../financial/crms/dao/CustomerAppletDao.java | 2 ++ .../financial/crms/dao/CustomerDao.java | 2 ++ .../impl/CustomerAppletServiceImpl.java | 35 ++++++++++--------- .../service/impl/CustomerServiceImpl.java | 33 +++++++++++------ .../mapper/crms/CustomerAppletDao.xml | 5 +++ .../resources/mapper/crms/CustomerDao.xml | 8 +++++ .../response/AlCollectionListResponse.java | 6 ++-- .../model/response/AlCollectionResponse.java | 6 ++-- .../domain/crms/ext/CustomerCompanyVO.java | 6 ++-- 9 files changed, 68 insertions(+), 35 deletions(-) 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} + + + + + +