瀏覽代碼

1.新增企业客户列表查询与导出接口

GouGengquan 3 天之前
父節點
當前提交
3c11253339

+ 28 - 0
biz-base/src/main/java/com/dayou/controller/CustomerCompanyController.java

@@ -1,5 +1,7 @@
 package com.dayou.controller;
 
+import com.dayou.dto.CustomerCompanySelectDTO;
+import com.dayou.vo.CustomerCompanyVO;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,11 +18,16 @@ import com.dayou.common.PullDownModel;
 import com.dayou.utils.ConvertUtil;
 import com.dayou.utils.HttpKit;
 import com.dayou.exception.ErrorCode;
+
+import java.io.IOException;
 import java.util.Date;
 import java.util.List;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import org.springframework.http.MediaType;
 import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * 企业客户
  *
@@ -89,5 +96,26 @@ public class CustomerCompanyController extends BaseController {
         List<PullDownModel> ret=ConvertUtil.copyList(list, PullDownModel.class);
         return RestResponse.data(ret);
     }
+
+    /**
+     * 分页查询企业客户列表
+     * @param page 分页
+     * @param dto 查询dto
+     * @return Page<CustomerCompanyVO>
+     */
+    @GetMapping("/getCustomerCompanyPage")
+    public RestResponse<Page<CustomerCompanyVO>> getCustomerCompanyPage(Page page, CustomerCompanySelectDTO dto) {
+        return RestResponse.data(customerCompanyService.getCustomerCompanyPage(page, dto));
+    }
+
+    /**
+     * 导出企业客户列表
+     * @param dto 查询dto
+     */
+    @GetMapping("/getCustomerCompanyPage/export")
+    public void exportCustomerCompanyPage(CustomerCompanySelectDTO dto, HttpServletResponse response) throws IOException {
+        List<CustomerCompanyVO> result = customerCompanyService.exportCustomerCompanyPage(dto);
+        exportPlus(response,"企业客户列表",result,CustomerCompanyVO.class);
+    }
 }
 

+ 21 - 0
dao/src/main/java/com/dayou/mapper/CustomerCompanyMapper.java

@@ -1,9 +1,14 @@
 package com.dayou.mapper;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.dayou.dto.CustomerCompanySelectDTO;
 import com.dayou.entity.CustomerCompany;
 import com.dayou.dao.CustomBaseMapper;
+import com.dayou.vo.CustomerCompanyVO;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 /**
  * <p>
  * 企业客户 Mapper 接口
@@ -15,4 +20,20 @@ import org.apache.ibatis.annotations.Param;
 public interface CustomerCompanyMapper extends CustomBaseMapper<CustomerCompany> {
 
     Long avoidWareHouseApplyByTargetId(@Param("targetId") Long targetId);
+
+    /**
+     * 分页查询企业客户列表
+     * @param page 分页
+     * @param dto 查询dto
+     * @return Page<CustomerCompanyVO>
+     */
+    Page<CustomerCompanyVO> getCustomerCompanyPage(@Param("page") Page page, @Param("dto") CustomerCompanySelectDTO dto);
+
+    /**
+     * 导出企业客户列表
+     * @param dto 查询dto
+     * @return List<CustomerCompanyVO>
+     */
+    List<CustomerCompanyVO> exportCustomerCompanyPage(@Param("dto") CustomerCompanySelectDTO dto);
+
 }

+ 84 - 0
dao/src/main/resources/mapper/CustomerCompanyMapper.xml

@@ -42,4 +42,88 @@
                     id = ( SELECT personal_id FROM personal_target WHERE id = #{targetId} AND deleted = 0 ))
           and terminal = 0 and company_type = '银行及金融机构' and parent_id is null
     </select>
+
+    <sql id="customerCompanyQuerySql">
+        SELECT company.id                                                    AS companyId,
+               company.name                                                  AS companyName,
+               parent.id                                                     AS parentId,
+               parent.name                                                   AS parentCompany,
+               company.company_type                                          AS companyType,
+               company.address                                               AS address,
+               company.phone                                                 AS phone,
+               user.name                                                     AS clientManager,
+               company.terminal                                              AS terminal,
+               ((SELECT COUNT(id)
+                 FROM assets
+                 WHERE assets.deleted = 0
+                   AND assets.clientele_sub_id = company.id) +
+                (SELECT COUNT(id)
+                 FROM major
+                 WHERE major.deleted = 0
+                   AND major.clientele_sub_id = company.id) +
+                (SELECT COUNT(id)
+                 FROM personal
+                 WHERE personal.deleted = 0
+                   AND personal.clientele_sub_id = company.id))              AS orderVolume,
+               (COALESCE((SELECT SUM(order_fund.real_amount)
+                          FROM assets
+                                   LEFT JOIN order_fund
+                                             ON order_fund.business_type = 'ASSET_BUSINESS' AND order_fund.deleted = 0 AND
+                                                business_id = assets.id
+                          WHERE assets.deleted = 0
+                            AND assets.clientele_sub_id = company.id), 0) +
+                COALESCE((SELECT SUM(order_fund.real_amount)
+                          FROM major
+                                   LEFT JOIN order_fund
+                                             ON order_fund.business_type = 'MAJOR_BUSINESS' AND order_fund.deleted = 0 AND
+                                                business_id = major.id
+                          WHERE major.deleted = 0
+                            AND major.clientele_sub_id = company.id), 0) +
+                COALESCE((SELECT SUM(order_fund.real_amount)
+                          FROM personal
+                                   LEFT JOIN order_fund
+                                             ON order_fund.business_type = 'PERSONAL_BUSINESS' AND order_fund.deleted = 0 AND
+                                                business_id = personal.id
+                          WHERE personal.deleted = 0
+                            AND personal.clientele_sub_id = company.id), 0)) AS estimatedRevenue,
+               company.created                                               AS created
+        FROM customer_company AS company
+                 LEFT JOIN customer_company AS parent ON parent.id = company.parent_id
+                 LEFT JOIN user ON user.id = company.client_manager_id
+        WHERE (company.level = 1
+           OR (company.terminal = 1 AND company.level = 0))
+        <if test="dto != null">
+            <if test="dto.companyName != null">
+                AND company.name LIKE CONCAT('%',#{dto.companyName},'%')
+            </if>
+            <if test="dto.parentCompany != null">
+                AND parent.name LIKE CONCAT('%',#{dto.parentCompany},'%')
+            </if>
+            <if test="dto.companyType != null">
+                AND company.company_type = #{dto.companyType}
+            </if>
+            <if test="dto.address != null">
+                AND company.address LIKE CONCAT('%',#{dto.address},'%')
+            </if>
+            <if test="dto.phone != null">
+                AND company.phone LIKE CONCAT('%',#{dto.phone},'%')
+            </if>
+            <if test="dto.clientManagerId != null">
+                AND company.client_manager_id = #{dto.clientManagerId}
+            </if>
+            <if test="dto.terminal != null">
+                AND company.terminal = #{dto.terminal}
+            </if>
+        </if>
+    </sql>
+
+    <!--分页查询企业客户列表-->
+    <select id="getCustomerCompanyPage" resultType="com.dayou.vo.CustomerCompanyVO">
+        <include refid="customerCompanyQuerySql" />
+    </select>
+
+    <!--分页查询企业客户列表-->
+    <select id="exportCustomerCompanyPage" resultType="com.dayou.vo.CustomerCompanyVO">
+        <include refid="customerCompanyQuerySql" />
+    </select>
 </mapper>

+ 43 - 0
domain/src/main/java/com/dayou/dto/CustomerCompanySelectDTO.java

@@ -0,0 +1,43 @@
+package com.dayou.dto;
+
+import lombok.Data;
+
+@Data
+public class CustomerCompanySelectDTO {
+
+    /**
+     * 企业名称
+     */
+    private String companyName;
+
+    /**
+     * 上级企业
+     */
+    private String parentCompany;
+
+    /**
+     * 企业类型
+     */
+    private String companyType;
+
+    /**
+     * 地址
+     */
+    private String address;
+
+    /**
+     * 企业电话
+     */
+    private String phone;
+
+    /**
+     * 维护人id(客户经理id)
+     */
+    private Long clientManagerId;
+
+    /**
+     * 终端客户
+     */
+    private Boolean terminal;
+
+}

+ 84 - 0
domain/src/main/java/com/dayou/vo/CustomerCompanyVO.java

@@ -0,0 +1,84 @@
+package com.dayou.vo;
+
+import com.dayou.annotation.Excel;
+import lombok.Data;
+
+import java.time.LocalDate;
+
+/**
+ * 客户管理-企业客户列表
+ */
+@Data
+public class CustomerCompanyVO {
+
+    /**
+     * 企业id
+     */
+    private Long companyId;
+
+    /**
+     * 企业名称
+     */
+    @Excel(name = "企业名称")
+    private String companyName;
+
+    /**
+     * 上级企业id
+     */
+    private Long parentId;
+
+    /**
+     * 上级企业
+     */
+    @Excel(name = "上级企业")
+    private String parentCompany;
+
+    /**
+     * 企业类型
+     */
+    @Excel(name = "企业类型")
+    private String companyType;
+
+    /**
+     * 地址
+     */
+    @Excel(name = "地址")
+    private String address;
+
+    /**
+     * 企业电话
+     */
+    @Excel(name = "企业电话")
+    private String phone;
+
+    /**
+     * 维护人
+     */
+    @Excel(name = "维护人")
+    private String clientManager;
+
+    /**
+     * 终端客户
+     */
+    @Excel(name = "终端客户", readConverterExp = "true=终端客户,false=非终端客户")
+    private Boolean terminal;
+
+    /**
+     * 来单量
+     */
+    @Excel(name = "来单量")
+    private Integer orderVolume;
+
+    /**
+     * 评估收入
+     */
+    @Excel(name = "评估收入")
+    private Double estimatedRevenue;
+
+    /**
+     * 创建时间
+     */
+    @Excel(name = "创建时间")
+    private LocalDate created;
+
+}

+ 18 - 0
service/src/main/java/com/dayou/service/ICustomerCompanyService.java

@@ -1,8 +1,10 @@
 package com.dayou.service;
+import com.dayou.dto.CustomerCompanySelectDTO;
 import com.dayou.entity.CustomerCompany;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.dayou.vo.CustomerCompanyVO;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -43,4 +45,20 @@ public interface ICustomerCompanyService extends IService<CustomerCompany> {
      * @return
      */
     Boolean avoidWareHouseApplyByTargetId(Long targetId);
+
+
+    /**
+     * 分页查询企业客户列表
+     * @param page 分页
+     * @param dto 查询dto
+     * @return Page<CustomerCompanyVO>
+     */
+    Page<CustomerCompanyVO> getCustomerCompanyPage(Page page, CustomerCompanySelectDTO dto);
+
+    /**
+     * 导出企业客户列表
+     * @param dto 查询dto
+     * @return List<CustomerCompanyVO>
+     */
+    List<CustomerCompanyVO> exportCustomerCompanyPage(CustomerCompanySelectDTO dto);
 }

+ 23 - 0
service/src/main/java/com/dayou/service/impl/CustomerCompanyServiceImpl.java

@@ -2,6 +2,7 @@ package com.dayou.service.impl;
 
 import com.baomidou.dynamic.datasource.annotation.DS;
 import com.dayou.common.BaseEntity;
+import com.dayou.dto.CustomerCompanySelectDTO;
 import com.dayou.entity.CustomerCompany;
 import com.dayou.entity.CustomerLinkman;
 import com.dayou.entity.PersonalTarget;
@@ -10,6 +11,7 @@ import com.dayou.service.ICustomerCompanyService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dayou.service.IPersonalTargetService;
 import com.dayou.utils.LoginContext;
+import com.dayou.vo.CustomerCompanyVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -106,4 +108,25 @@ public class CustomerCompanyServiceImpl extends ServiceImpl<CustomerCompanyMappe
         Long ccId = customerCompanyMapper.avoidWareHouseApplyByTargetId(targetId);
         return ccId!=null;
     }
+
+    /**
+     * 分页查询企业客户列表
+     * @param page 分页
+     * @param dto 查询dto
+     * @return Page<CustomerCompanyVO>
+     */
+    @Override
+    public Page<CustomerCompanyVO> getCustomerCompanyPage(Page page, CustomerCompanySelectDTO dto) {
+        return customerCompanyMapper.getCustomerCompanyPage(page, dto);
+    }
+
+    /**
+     * 导出企业客户列表
+     * @param dto 查询dto
+     * @return List<CustomerCompanyVO>
+     */
+    @Override
+    public List<CustomerCompanyVO> exportCustomerCompanyPage(CustomerCompanySelectDTO dto) {
+        return customerCompanyMapper.exportCustomerCompanyPage(dto);
+    }
 }