客户资源管理后台管理列表查询...

master
river 4 years ago
parent 96b3466579
commit 033b5dabba
  1. 10
      dq-financial-crms/src/main/java/com/daqing/financial/crms/controller/CustomerController.java
  2. 130
      dq-financial-crms/src/main/java/com/daqing/financial/crms/service/impl/CustomerServiceImpl.java
  3. 7
      dq-financial-crms/src/test/java/com/daqing/financial/crms/DqFinancialCrmsApplicationTests.java
  4. 1
      dq-financial-hrms/src/main/java/com/daqing/financial/hrms/DqFinancialHrmsApplication.java
  5. 34
      dq-framework-model/src/main/java/com/daqing/framework/domain/crms/ext/CrmsConstant.java

@ -4,6 +4,7 @@ import com.daqing.financial.crms.CustomerControllerApi;
import com.daqing.financial.crms.feign.HrmsFeignService; import com.daqing.financial.crms.feign.HrmsFeignService;
import com.daqing.financial.crms.service.CustomerService; import com.daqing.financial.crms.service.CustomerService;
import com.daqing.framework.domain.crms.CustomerEntity; import com.daqing.framework.domain.crms.CustomerEntity;
import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.model.response.ResponseResult; import com.daqing.framework.model.response.ResponseResult;
import com.daqing.framework.utils.PageUtils; import com.daqing.framework.utils.PageUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -39,5 +40,14 @@ public class CustomerController implements CustomerControllerApi {
return hrmsFeignService.list(params); return hrmsFeignService.list(params);
} }
/**
* 查询客户列表(所有)根据创建时间筛选根据客户类型筛选根据客户编号或者名称搜索
*/
@GetMapping("/queryList")
public ResponseResult queryList(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, CustomerRequest customerRequest) {
PageUtils list = customerService.queryList(page, size, customerRequest);
return new ResponseResult<PageUtils>().SUCCESS(list);
}
} }

@ -1,5 +1,6 @@
package com.daqing.financial.crms.service.impl; package com.daqing.financial.crms.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -7,6 +8,7 @@ import com.daqing.financial.crms.dao.CustomerDao;
import com.daqing.financial.crms.feign.HrmsFeignService; import com.daqing.financial.crms.feign.HrmsFeignService;
import com.daqing.financial.crms.service.CustomerService; import com.daqing.financial.crms.service.CustomerService;
import com.daqing.framework.domain.crms.CustomerEntity; import com.daqing.framework.domain.crms.CustomerEntity;
import com.daqing.framework.domain.crms.ext.CrmsConstant;
import com.daqing.framework.domain.crms.ext.CustomerTO; import com.daqing.framework.domain.crms.ext.CustomerTO;
import com.daqing.framework.domain.crms.request.CustomerRequest; import com.daqing.framework.domain.crms.request.CustomerRequest;
import com.daqing.framework.domain.hrms.ext.EmployeeTO; import com.daqing.framework.domain.hrms.ext.EmployeeTO;
@ -18,8 +20,6 @@ import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Service("customerService") @Service("customerService")
@ -31,12 +31,6 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
@Autowired @Autowired
private HrmsFeignService hrmsFeignService; private HrmsFeignService hrmsFeignService;
public void t() {
hrmsFeignService.list(new HashMap<>());
}
/** /**
* 查询客户列表(所有)根据创建时间筛选根据客户类型筛选根据客户编号或者名称搜索 * 查询客户列表(所有)根据创建时间筛选根据客户类型筛选根据客户编号或者名称搜索
* *
@ -48,19 +42,12 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
@Override @Override
public PageUtils queryList(Integer page, Integer size, CustomerRequest customerRequest) { public PageUtils queryList(Integer page, Integer size, CustomerRequest customerRequest) {
// 没有选择自定义时间且选择了固定的"3个月内、6个月内、9个月内...."时间 // 选择某段时间内客户信息的时间参数校验
if (customerRequest.getStartTime() == null && customerRequest.getEndTime() == null && customerRequest.getCreateTime() != null) { timeCheckout(customerRequest.getCreateTime(),customerRequest.getStartTime(),customerRequest.getEndTime(),customerRequest);
if (customerRequest.getCreateTime() != 0) {
String pastTime = pastTime(customerRequest.getCreateTime());
customerRequest.setStartTime(pastTime);
}
}
// 选择了自定义时间且选择了固定时间则固定时间无效 //分页参数校验
if (customerRequest.getCreateTime() != null && (customerRequest.getStartTime() != null || customerRequest.getEndTime() != null)) { Page<Object> pages = pageCheckout(page, size);
customerRequest.setCreateTime(null); //查询所有客户的基本信息
}
Page<Object> pages = new Page<>(page, size);
IPage<CustomerEntity> customerEntityIPage = customerDao.queryList(pages, customerRequest); IPage<CustomerEntity> customerEntityIPage = customerDao.queryList(pages, customerRequest);
// 获取所有的客户基本信息 // 获取所有的客户基本信息
@ -68,13 +55,87 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
// 获取所有的客户经理id // 获取所有的客户经理id
Long[] ids = customers.stream().map(CustomerEntity::getId).toArray(Long[]::new); Long[] ids = customers.stream().map(CustomerEntity::getId).toArray(Long[]::new);
// 用于拼装客户信息和员工及部门信息的集合
List<CustomerTO> customerTOS = new ArrayList<>();
CustomerTO customerTO;
//TODO 远程调用查询客户经理信息的接口 //TODO 远程调用查询客户经理信息的接口
ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(ids); ResponseResult responseResult = hrmsFeignService.getEmployeeAndDeptById(ids);
List<EmployeeTO> employeeTO = (List<EmployeeTO>) responseResult.getData(); List<EmployeeTO> employeeTO = (List<EmployeeTO>) responseResult.getData();
// 将客户信息和客户经理及部门信息拼装起来
List<CustomerTO> customerTOS = jointCustomerEmployee(customers, employeeTO);
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
IPage<CustomerTO> iPage = new Page<>();
BeanUtils.copyProperties(customerEntityIPage, iPage);
iPage.setRecords(customerTOS);
return new PageUtils(iPage);
}
/**
* 选择某段时间内客户信息的时间参数校验
* @param createTime 创建时间
* @param startTime 起始时间
* @param endTime 结束时间
*/
private void timeCheckout(Integer createTime, String startTime, String endTime, CustomerRequest customerRequest){
// 没有选择自定义时间且选择了固定的"3个月内、6个月内、9个月内...."时间
if (startTime == null && endTime == null && createTime != null) {
if (createTime != 0) {
String pastTime = pastTime(createTime);
customerRequest.setStartTime(pastTime);
}
}
// 选择了自定义时间且选择了固定时间则固定时间无效
if (createTime != null && (startTime != null || endTime != null)) {
customerRequest.setCreateTime(null);
}
}
/**
* 得到过去number月内的时间
*
* @param number
* @return 字符串类型
*/
private String pastTime(Integer number) {
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, -number);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
return sdf.format(calendar.getTime());
}
/**
* 分页参数校验
* @param page 当前页
* @param size 每页条数
*/
private Page<Object> pageCheckout(Integer page, Integer size){
Integer count = this.count(new QueryWrapper<CustomerEntity>().eq("del_or_not", CrmsConstant.NOT_DELETE));//查询客户有效总条数
if (size == null || size < 1) {
size = 10;
}
Integer maxPage = count % size == 0 ? count / size : count / size + 1;
if (page == null || page < 1) {
page = 1;
}
if (page > maxPage) {
page = maxPage;
}
Page<Object> pages = new Page<>(page, size);
return pages;
}
/**
* 拼接客户及其对应的客户经理及部门信息
* @param customers 客户基本信息集合
* @param employeeTO 员工及部门信息集合
* @return
*/
private List<CustomerTO> jointCustomerEmployee(List<CustomerEntity> customers, List<EmployeeTO> employeeTO){
List<CustomerTO> customerTOS = new ArrayList<>();// 用于拼装客户信息和员工及部门信息的集合
CustomerTO customerTO;
// 将客户信息和客户经理及部门信息拼装起来 // 将客户信息和客户经理及部门信息拼装起来
for (CustomerEntity customer : customers) { for (CustomerEntity customer : customers) {
// 每一个客户对应一个不同的对象 // 每一个客户对应一个不同的对象
@ -100,27 +161,6 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerDao, CustomerEntity
customerTOS.add(customerTO); customerTOS.add(customerTO);
} }
} }
return customerTOS;
// 属性拷贝,将泛型为CustomerEntity类型的IPage的属性拷贝给泛型为CustomerTO类型的IPage,才能赋值给PageUtils
IPage<CustomerTO> iPage = new Page<>();
BeanUtils.copyProperties(customerEntityIPage, iPage);
iPage.setRecords(customerTOS);
return new PageUtils(iPage);
}
/**
* 得到过去number月内的时间
*
* @param number
* @return 字符串类型
*/
private String pastTime(Integer number) {
Date date = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
calendar.add(Calendar.MONTH, -number);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
return sdf.format(calendar.getTime());
} }
} }

@ -33,11 +33,4 @@ public class DqFinancialCrmsApplicationTests {
List<CustomerTO> list1 = (List<CustomerTO>) list.getList(); List<CustomerTO> list1 = (List<CustomerTO>) list.getList();
list1.forEach(customerEntity -> System.out.println(customerEntity)); list1.forEach(customerEntity -> System.out.println(customerEntity));
} }
@Test
public void t() {
customerServiceimpl.t();
}
} }

@ -15,5 +15,4 @@ public class DqFinancialHrmsApplication {
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication.run(DqFinancialHrmsApplication.class, args); SpringApplication.run(DqFinancialHrmsApplication.class, args);
} }
} }

@ -12,6 +12,40 @@ import lombok.Setter;
*/ */
public class CrmsConstant { public class CrmsConstant {
/**
* 未删除
*/
public static final Integer NOT_DELETE = 0;
// /**
// * 是否删除:1、已删除,0:未删除
// */
// @AllArgsConstructor
// public enum isDel {
// /**
// * 已删除
// */
// DEL(1, "已删除"),
// /**
// * 未删除
// */
// NOT_DEL(0, "未删除");
//
// /**
// * 类型代号
// */
// @Setter
// @Getter
// private Integer code;
//
// /**
// * 类型名称
// */
// @Setter
// @Getter
// private String description;
// }
/** /**
* 客户类型1企业类型0个人类型 * 客户类型1企业类型0个人类型
*/ */

Loading…
Cancel
Save